MCPcopy Create free account
hub / github.com/OpenIPC/firmware / cJSON_DetachItemViaPointer

Function cJSON_DetachItemViaPointer

general/package/xmdp/src/cjson/cJSON.c:2190–2224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2188}
2189
2190CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item)
2191{
2192 if ((parent == NULL) || (item == NULL))
2193 {
2194 return NULL;
2195 }
2196
2197 if (item != parent->child)
2198 {
2199 /* not the first element */
2200 item->prev->next = item->next;
2201 }
2202 if (item->next != NULL)
2203 {
2204 /* not the last element */
2205 item->next->prev = item->prev;
2206 }
2207
2208 if (item == parent->child)
2209 {
2210 /* first element */
2211 parent->child = item->next;
2212 }
2213 else if (item->next == NULL)
2214 {
2215 /* last element */
2216 parent->child->prev = item->prev;
2217 }
2218
2219 /* make sure the detached item doesn't point anywhere anymore */
2220 item->prev = NULL;
2221 item->next = NULL;
2222
2223 return item;
2224}
2225
2226CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which)
2227{

Calls

no outgoing calls

Tested by

no test coverage detected