| 2241 | } |
| 2242 | |
| 2243 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) |
| 2244 | { |
| 2245 | if ((parent == NULL) || (item == NULL) || (item != parent->child && item->prev == NULL)) |
| 2246 | { |
| 2247 | return NULL; |
| 2248 | } |
| 2249 | |
| 2250 | if (item != parent->child) |
| 2251 | { |
| 2252 | /* not the first element */ |
| 2253 | item->prev->next = item->next; |
| 2254 | } |
| 2255 | if (item->next != NULL) |
| 2256 | { |
| 2257 | /* not the last element */ |
| 2258 | item->next->prev = item->prev; |
| 2259 | } |
| 2260 | |
| 2261 | if (item == parent->child) |
| 2262 | { |
| 2263 | /* first element */ |
| 2264 | parent->child = item->next; |
| 2265 | } |
| 2266 | else if (item->next == NULL) |
| 2267 | { |
| 2268 | /* last element */ |
| 2269 | parent->child->prev = item->prev; |
| 2270 | } |
| 2271 | |
| 2272 | /* make sure the detached item doesn't point anywhere anymore */ |
| 2273 | item->prev = NULL; |
| 2274 | item->next = NULL; |
| 2275 | |
| 2276 | return item; |
| 2277 | } |
| 2278 | |
| 2279 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) |
| 2280 | { |
no outgoing calls
searching dependent graphs…