reformatting: cJSON_strdup

This commit is contained in:
Max Bruckner 2016-09-27 23:39:22 +07:00
parent 542ed727d7
commit 18081c03c4

16
cJSON.c
View File

@ -66,13 +66,17 @@ static void (*cJSON_free)(void *ptr) = free;
static char* cJSON_strdup(const char* str) static char* cJSON_strdup(const char* str)
{ {
size_t len; size_t len;
char* copy; char* copy;
len = strlen(str) + 1; len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0; if (!(copy = (char*)cJSON_malloc(len)))
memcpy(copy,str,len); {
return copy; return 0;
}
memcpy(copy, str, len);
return copy;
} }
void cJSON_InitHooks(cJSON_Hooks* hooks) void cJSON_InitHooks(cJSON_Hooks* hooks)