| 2077 | } |
| 2078 | |
| 2079 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) |
| 2080 | { |
| 2081 | if ((parent == NULL) || (item == NULL)) |
| 2082 | { |
| 2083 | return NULL; |
| 2084 | } |
| 2085 | |
| 2086 | if (item->prev != NULL) |
| 2087 | { |
| 2088 | /* not the first element */ |
| 2089 | item->prev->next = item->next; |
| 2090 | } |
| 2091 | if (item->next != NULL) |
| 2092 | { |
| 2093 | /* not the last element */ |
| 2094 | item->next->prev = item->prev; |
| 2095 | } |
| 2096 | |
| 2097 | if (item == parent->child) |
| 2098 | { |
| 2099 | /* first element */ |
| 2100 | parent->child = item->next; |
| 2101 | } |
| 2102 | /* make sure the detached item doesn't point anywhere anymore */ |
| 2103 | item->prev = NULL; |
| 2104 | item->next = NULL; |
| 2105 | |
| 2106 | return item; |
| 2107 | } |
| 2108 | |
| 2109 | CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) |
| 2110 | { |
no outgoing calls
no test coverage detected