Replace array/object items with new ones. */
| 745 | |
| 746 | /* Replace array/object items with new ones. */ |
| 747 | void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { |
| 748 | cJSON *c = array->child; |
| 749 | while (c && which > 0) c = c->next, which--; |
| 750 | if (!c) return; |
| 751 | newitem->next = c->next; |
| 752 | newitem->prev = c->prev; |
| 753 | if (newitem->next) newitem->next->prev = newitem; |
| 754 | if (c == array->child) { |
| 755 | array->child = newitem; |
| 756 | } else { |
| 757 | newitem->prev->next = newitem; |
| 758 | } |
| 759 | c->next = c->prev = 0; |
| 760 | cJSON_Delete(c); |
| 761 | } |
| 762 | void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) { |
| 763 | int i = 0; |
| 764 | cJSON *c = object->child; |
no test coverage detected