MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / add_item_to_array

Function add_item_to_array

cJSON.c:2012–2043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010}
2011
2012static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
2013{
2014 cJSON *child = NULL;
2015
2016 if ((item == NULL) || (array == NULL) || (array == item))
2017 {
2018 return false;
2019 }
2020
2021 child = array->child;
2022 /*
2023 * To find the last item in array quickly, we use prev in array
2024 */
2025 if (child == NULL)
2026 {
2027 /* list is empty, start new one */
2028 array->child = item;
2029 item->prev = item;
2030 item->next = NULL;
2031 }
2032 else
2033 {
2034 /* append to the end */
2035 if (child->prev)
2036 {
2037 suffix_object(child->prev, item);
2038 array->child->prev = item;
2039 }
2040 }
2041
2042 return true;
2043}
2044
2045/* Add item to array/object. */
2046CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item)

Calls 1

suffix_objectFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…