Reverse cJSON_ArrayFirst arguments

This commit is contained in:
Dominick C. Pastore 2020-05-09 12:32:45 -04:00
parent 127875c997
commit dc58a6e2a1
2 changed files with 4 additions and 4 deletions

View File

@ -281,7 +281,7 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
/* Macros for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
#define cJSON_ArrayFirst(element, array) (element = (array != NULL) ? (array)->child : NULL)
#define cJSON_ArrayFirst(array, element) (element = (array != NULL) ? (array)->child : NULL)
#define cJSON_ArrayNext(element) (element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */

View File

@ -84,7 +84,7 @@ static void cjson_array_first_should_get_first(void)
elements[i + 1].prev = &elements[i];
}
cJSON_ArrayFirst(element_pointer, array);
cJSON_ArrayFirst(array, element_pointer);
TEST_ASSERT_TRUE_MESSAGE(element_pointer == &elements[0], "Failed to store first.");
}
@ -92,7 +92,7 @@ static void cjson_array_first_should_not_dereference_null_pointer(void)
{
cJSON *array = NULL;
cJSON *element = NULL;
cJSON_ArrayFirst(element, array);
cJSON_ArrayFirst(array, element);
/* suppress unused var warning */
if (element)
{
@ -119,7 +119,7 @@ static void cjson_array_next_should_iterate(void)
elements[i + 1].prev = &elements[i];
}
cJSON_ArrayFirst(element_pointer, array);
cJSON_ArrayFirst(array, element_pointer);
if (cJSON_ArrayNext(element_pointer))
{