MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / add_item_to_array

Function add_item_to_array

TheForceEngine/TFE_System/cJSON.c:1961–1992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1959}
1960
1961static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
1962{
1963 cJSON *child = NULL;
1964
1965 if ((item == NULL) || (array == NULL) || (array == item))
1966 {
1967 return false;
1968 }
1969
1970 child = array->child;
1971 /*
1972 * To find the last item in array quickly, we use prev in array
1973 */
1974 if (child == NULL)
1975 {
1976 /* list is empty, start new one */
1977 array->child = item;
1978 item->prev = item;
1979 item->next = NULL;
1980 }
1981 else
1982 {
1983 /* append to the end */
1984 if (child->prev)
1985 {
1986 suffix_object(child->prev, item);
1987 array->child->prev = item;
1988 }
1989 }
1990
1991 return true;
1992}
1993
1994/* Add item to array/object. */
1995CJSON_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