Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int case_insensitive_strcmp(const unsigned char *string1, const unsigned
return 0;
}

for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
{
if (*string1 == '\0')
{
Expand Down Expand Up @@ -608,7 +608,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
{
length = sprintf((char*)number_buffer, "null");
}
else if(d == (double)item->valueint)
else if (d == (double)item->valueint)
{
length = sprintf((char*)number_buffer, "%d", item->valueint);
}
Expand Down Expand Up @@ -1626,7 +1626,7 @@ static cJSON_bool print_array(const cJSON * const item, printbuffer * const outp
return false;
}
*output_pointer++ = ',';
if(output_buffer->format)
if (output_buffer->format)
{
*output_pointer++ = ' ';
}
Expand Down Expand Up @@ -2446,7 +2446,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, c
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_NULL;
}
Expand All @@ -2457,7 +2457,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_True;
}
Expand All @@ -2468,7 +2468,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_False;
}
Expand All @@ -2479,7 +2479,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void)
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = boolean ? cJSON_True : cJSON_False;
}
Expand All @@ -2490,7 +2490,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean)
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_Number;
item->valuedouble = num;
Expand All @@ -2516,11 +2516,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_String;
item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
if(!item->valuestring)
if (!item->valuestring)
{
cJSON_Delete(item);
return NULL;
Expand Down Expand Up @@ -2566,11 +2566,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) {
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type = cJSON_Raw;
item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks);
if(!item->valuestring)
if (!item->valuestring)
{
cJSON_Delete(item);
return NULL;
Expand All @@ -2583,7 +2583,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw)
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void)
{
cJSON *item = cJSON_New_Item(&global_hooks);
if(item)
if (item)
{
item->type=cJSON_Array;
}
Expand Down Expand Up @@ -2617,15 +2617,15 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)

a = cJSON_CreateArray();

for(i = 0; a && (i < (size_t)count); i++)
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
if (!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
if (!i)
{
a->child = n;
}
Expand Down Expand Up @@ -2657,15 +2657,15 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)

a = cJSON_CreateArray();

for(i = 0; a && (i < (size_t)count); i++)
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber((double)numbers[i]);
if(!n)
if (!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
if (!i)
{
a->child = n;
}
Expand Down Expand Up @@ -2697,15 +2697,15 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)

a = cJSON_CreateArray();

for(i = 0; a && (i < (size_t)count); i++)
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateNumber(numbers[i]);
if(!n)
n = cJSON_CreateNumber(numbers[i], dec);
if (!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
if (!i)
{
a->child = n;
}
Expand Down Expand Up @@ -2740,12 +2740,12 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
for (i = 0; a && (i < (size_t)count); i++)
{
n = cJSON_CreateString(strings[i]);
if(!n)
if (!n)
{
cJSON_Delete(a);
return NULL;
}
if(!i)
if (!i)
{
a->child = n;
}
Expand Down Expand Up @@ -2818,7 +2818,7 @@ cJSON * cJSON_Duplicate_rec(const cJSON *item, size_t depth, cJSON_bool recurse)
child = item->child;
while (child != NULL)
{
if(depth >= CJSON_CIRCULAR_LIMIT) {
if (depth >= CJSON_CIRCULAR_LIMIT) {
goto fail;
}
newchild = cJSON_Duplicate_rec(child, depth + 1, true); /* Duplicate (with recurse) each item in the ->next chain */
Expand Down
8 changes: 4 additions & 4 deletions cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ typedef struct cJSON

typedef struct cJSON_Hooks
{
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks;

typedef int cJSON_bool;
Expand Down Expand Up @@ -261,7 +261,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);

/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
* The input pointer json cannot point to a read-only address area, such as a string constant,
* The input pointer json cannot point to a read-only address area, such as a string constant,
* but should point to a readable and writable address area. */
CJSON_PUBLIC(void) cJSON_Minify(char *json);

Expand Down
4 changes: 2 additions & 2 deletions cJSON_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int compare_strings(const unsigned char *string1, const unsigned char *st
return strcmp((const char*)string1, (const char*)string2);
}

for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
{
if (*string1 == '\0')
{
Expand Down Expand Up @@ -147,7 +147,7 @@ static cJSON_bool compare_pointers(const unsigned char *name, const unsigned cha
if (((*pointer != 0) && (*pointer != '/')) != (*name != 0))
{
/* one string has ended, the other not */
return false;;
return false;
}

return true;
Expand Down