MCPcopy Create free account
hub / github.com/Netis/cloud-probe / add_item_to_array

Function add_item_to_array

cpworker/src/cJSON/cJSON.c:1974–2005  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1972}
1973
1974static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
1975{
1976 cJSON *child = NULL;
1977
1978 if ((item == NULL) || (array == NULL) || (array == item))
1979 {
1980 return false;
1981 }
1982
1983 child = array->child;
1984 /*
1985 * To find the last item in array quickly, we use prev in array
1986 */
1987 if (child == NULL)
1988 {
1989 /* list is empty, start new one */
1990 array->child = item;
1991 item->prev = item;
1992 item->next = NULL;
1993 }
1994 else
1995 {
1996 /* append to the end */
1997 if (child->prev)
1998 {
1999 suffix_object(child->prev, item);
2000 array->child->prev = item;
2001 }
2002 }
2003
2004 return true;
2005}
2006
2007/* Add item to array/object. */
2008CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)

Callers 4

cJSON_AddItemToArrayFunction · 0.85
add_item_to_objectFunction · 0.85
cJSON_InsertItemInArrayFunction · 0.85

Calls 1

suffix_objectFunction · 0.85

Tested by

no test coverage detected