MCPcopy Create free account
hub / github.com/antirez/botlib / cJSON_DetachItemViaPointer

Function cJSON_DetachItemViaPointer

cJSON.c:2183–2217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2181}
2182
2183CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
2184{
2185 if ((parent == NULL) || (item == NULL))
2186 {
2187 return NULL;
2188 }
2189
2190 if (item != parent->child)
2191 {
2192 /* not the first element */
2193 item->prev->next = item->next;
2194 }
2195 if (item->next != NULL)
2196 {
2197 /* not the last element */
2198 item->next->prev = item->prev;
2199 }
2200
2201 if (item == parent->child)
2202 {
2203 /* first element */
2204 parent->child = item->next;
2205 }
2206 else if (item->next == NULL)
2207 {
2208 /* last element */
2209 parent->child->prev = item->prev;
2210 }
2211
2212 /* make sure the detached item doesn't point anywhere anymore */
2213 item->prev = NULL;
2214 item->next = NULL;
2215
2216 return item;
2217}
2218
2219CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
2220{

Calls

no outgoing calls

Tested by

no test coverage detected