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

Function detach_item_from_array

cJSON_Utils.c:393–427  ·  view source on GitHub ↗

non-broken cJSON_DetachItemFromArray */

Source from the content-addressed store, hash-verified

391
392/* non-broken cJSON_DetachItemFromArray */
393static cJSON *detach_item_from_array(cJSON *array, size_t which)
394{
395 cJSON *c = array->child;
396 while (c && (which > 0))
397 {
398 c = c->next;
399 which--;
400 }
401 if (!c)
402 {
403 /* item doesn't exist */
404 return NULL;
405 }
406 if (c != array->child)
407 {
408 /* not the first element */
409 c->prev->next = c->next;
410 }
411 if (c->next)
412 {
413 c->next->prev = c->prev;
414 }
415 if (c == array->child)
416 {
417 array->child = c->next;
418 }
419 else if (c->next == NULL)
420 {
421 array->child->prev = c->prev;
422 }
423 /* make sure the detached item doesn't point anywhere anymore */
424 c->prev = c->next = NULL;
425
426 return c;
427}
428
429/* detach an item at the given path */
430static cJSON *detach_path(cJSON *object, const unsigned char *path, const cJSON_bool case_sensitive)

Callers 1

detach_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…