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

Function cJSON_DetachItemViaPointer

external/cJSON/cJSON.c:2258–2292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2256}
2257
2258CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
2259{
2260 if ((parent == NULL) || (item == NULL) || (item != parent->child && item->prev == NULL))
2261 {
2262 return NULL;
2263 }
2264
2265 if (item != parent->child)
2266 {
2267 /* not the first element */
2268 item->prev->next = item->next;
2269 }
2270 if (item->next != NULL)
2271 {
2272 /* not the last element */
2273 item->next->prev = item->prev;
2274 }
2275
2276 if (item == parent->child)
2277 {
2278 /* first element */
2279 parent->child = item->next;
2280 }
2281 else if (item->next == NULL)
2282 {
2283 /* last element */
2284 parent->child->prev = item->prev;
2285 }
2286
2287 /* make sure the detached item doesn't point anywhere anymore */
2288 item->prev = NULL;
2289 item->next = NULL;
2290
2291 return item;
2292}
2293
2294CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
2295{

Calls

no outgoing calls

Tested by

no test coverage detected