MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / add_item_to_array

Function add_item_to_array

external/cJSON/cJSON.c:2027–2058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2025}
2026
2027static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
2028{
2029 cJSON *child = NULL;
2030
2031 if ((item == NULL) || (array == NULL) || (array == item))
2032 {
2033 return false;
2034 }
2035
2036 child = array->child;
2037 /*
2038 * To find the last item in array quickly, we use prev in array
2039 */
2040 if (child == NULL)
2041 {
2042 /* list is empty, start new one */
2043 array->child = item;
2044 item->prev = item;
2045 item->next = NULL;
2046 }
2047 else
2048 {
2049 /* append to the end */
2050 if (child->prev)
2051 {
2052 suffix_object(child->prev, item);
2053 array->child->prev = item;
2054 }
2055 }
2056
2057 return true;
2058}
2059
2060/* Add item to array/object. */
2061CJSON_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