| 2048 | } |
| 2049 | |
| 2050 | static void ReplaceItemInArray(cJSON *array, size_t which, cJSON *newitem) |
| 2051 | { |
| 2052 | cJSON *c = array->child; |
| 2053 | while (c && (which > 0)) |
| 2054 | { |
| 2055 | c = c->next; |
| 2056 | which--; |
| 2057 | } |
| 2058 | if (!c) |
| 2059 | { |
| 2060 | return; |
| 2061 | } |
| 2062 | newitem->next = c->next; |
| 2063 | newitem->prev = c->prev; |
| 2064 | if (newitem->next) |
| 2065 | { |
| 2066 | newitem->next->prev = newitem; |
| 2067 | } |
| 2068 | if (c == array->child) |
| 2069 | { |
| 2070 | array->child = newitem; |
| 2071 | } |
| 2072 | else |
| 2073 | { |
| 2074 | newitem->prev->next = newitem; |
| 2075 | } |
| 2076 | c->next = c->prev = NULL; |
| 2077 | cJSON_Delete(c); |
| 2078 | } |
| 2079 | void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2080 | { |
| 2081 | if (which < 0) |
no test coverage detected