mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
reformatting: create_reference
This commit is contained in:
parent
17e13946fe
commit
09545c0eb2
21
cJSON.c
21
cJSON.c
@ -1621,9 +1621,26 @@ int cJSON_HasObjectItem(cJSON *object,const char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Utility for array list handling. */
|
/* Utility for array list handling. */
|
||||||
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
static void suffix_object(cJSON *prev, cJSON *item)
|
||||||
|
{
|
||||||
|
prev->next = item;
|
||||||
|
item->prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
/* Utility for handling references. */
|
/* Utility for handling references. */
|
||||||
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
|
static cJSON *create_reference(cJSON *item)
|
||||||
|
{
|
||||||
|
cJSON *ref = cJSON_New_Item();
|
||||||
|
if (!ref)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memcpy(ref, item, sizeof(cJSON));
|
||||||
|
ref->string = 0;
|
||||||
|
ref->type |= cJSON_IsReference;
|
||||||
|
ref->next = ref->prev = 0;
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add item to array/object. */
|
/* Add item to array/object. */
|
||||||
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
||||||
|
Loading…
Reference in New Issue
Block a user