mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Reverse cJSON_ArrayFirst arguments
This commit is contained in:
parent
127875c997
commit
dc58a6e2a1
2
cJSON.h
2
cJSON.h
@ -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 */
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user