| 2176 | } |
| 2177 | |
| 2178 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) |
| 2179 | { |
| 2180 | if ((parent == NULL) || (replacement == NULL) || (item == NULL)) |
| 2181 | { |
| 2182 | return false; |
| 2183 | } |
| 2184 | |
| 2185 | if (replacement == item) |
| 2186 | { |
| 2187 | return true; |
| 2188 | } |
| 2189 | |
| 2190 | replacement->next = item->next; |
| 2191 | replacement->prev = item->prev; |
| 2192 | |
| 2193 | if (replacement->next != NULL) |
| 2194 | { |
| 2195 | replacement->next->prev = replacement; |
| 2196 | } |
| 2197 | if (replacement->prev != NULL) |
| 2198 | { |
| 2199 | replacement->prev->next = replacement; |
| 2200 | } |
| 2201 | if (parent->child == item) |
| 2202 | { |
| 2203 | parent->child = replacement; |
| 2204 | } |
| 2205 | |
| 2206 | item->next = NULL; |
| 2207 | item->prev = NULL; |
| 2208 | cJSON_Delete(item); |
| 2209 | |
| 2210 | return true; |
| 2211 | } |
| 2212 | |
| 2213 | CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2214 | { |
no test coverage detected