| 2256 | } |
| 2257 | |
| 2258 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) |
| 2259 | { |
| 2260 | if ((parent == NULL) || (item == NULL) || (item != parent->child && item->prev == NULL)) |
| 2261 | { |
| 2262 | return NULL; |
| 2263 | } |
| 2264 | |
| 2265 | if (item != parent->child) |
| 2266 | { |
| 2267 | /* not the first element */ |
| 2268 | item->prev->next = item->next; |
| 2269 | } |
| 2270 | if (item->next != NULL) |
| 2271 | { |
| 2272 | /* not the last element */ |
| 2273 | item->next->prev = item->prev; |
| 2274 | } |
| 2275 | |
| 2276 | if (item == parent->child) |
| 2277 | { |
| 2278 | /* first element */ |
| 2279 | parent->child = item->next; |
| 2280 | } |
| 2281 | else if (item->next == NULL) |
| 2282 | { |
| 2283 | /* last element */ |
| 2284 | parent->child->prev = item->prev; |
| 2285 | } |
| 2286 | |
| 2287 | /* make sure the detached item doesn't point anywhere anymore */ |
| 2288 | item->prev = NULL; |
| 2289 | item->next = NULL; |
| 2290 | |
| 2291 | return item; |
| 2292 | } |
| 2293 | |
| 2294 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) |
| 2295 | { |
no outgoing calls
no test coverage detected