non-broken cJSON_DetachItemFromArray */
| 391 | |
| 392 | /* non-broken cJSON_DetachItemFromArray */ |
| 393 | static 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 */ |
| 430 | static cJSON *detach_path(cJSON *object, const unsigned char *path, const cJSON_bool case_sensitive) |
no outgoing calls
no test coverage detected
searching dependent graphs…