| 2203 | } |
| 2204 | |
| 2205 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) |
| 2206 | { |
| 2207 | if ((parent == NULL) || (item == NULL)) |
| 2208 | { |
| 2209 | return NULL; |
| 2210 | } |
| 2211 | |
| 2212 | if (item != parent->child) |
| 2213 | { |
| 2214 | /* not the first element */ |
| 2215 | item->prev->next = item->next; |
| 2216 | } |
| 2217 | if (item->next != NULL) |
| 2218 | { |
| 2219 | /* not the last element */ |
| 2220 | item->next->prev = item->prev; |
| 2221 | } |
| 2222 | |
| 2223 | if (item == parent->child) |
| 2224 | { |
| 2225 | /* first element */ |
| 2226 | parent->child = item->next; |
| 2227 | } |
| 2228 | else if (item->next == NULL) |
| 2229 | { |
| 2230 | /* last element */ |
| 2231 | parent->child->prev = item->prev; |
| 2232 | } |
| 2233 | |
| 2234 | /* make sure the detached item doesn't point anywhere anymore */ |
| 2235 | item->prev = NULL; |
| 2236 | item->next = NULL; |
| 2237 | |
| 2238 | return item; |
| 2239 | } |
| 2240 | |
| 2241 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) |
| 2242 | { |
no outgoing calls
no test coverage detected