MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / cJSON_DetachItemViaPointer

Function cJSON_DetachItemViaPointer

framework/utils/cJSON.c:2071–2099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2069}
2070
2071CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
2072{
2073if ((parent == NULL) || (item == NULL))
2074{
2075return NULL;
2076}
2077
2078if (item->prev != NULL)
2079{
2080/* not the first element */
2081item->prev->next = item->next;
2082}
2083if (item->next != NULL)
2084{
2085/* not the last element */
2086item->next->prev = item->prev;
2087}
2088
2089if (item == parent->child)
2090{
2091/* first element */
2092parent->child = item->next;
2093}
2094/* make sure the detached item doesn't point anywhere anymore */
2095item->prev = NULL;
2096item->next = NULL;
2097
2098return item;
2099}
2100
2101CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
2102{

Calls

no outgoing calls

Tested by

no test coverage detected