MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / DetachItemFromArray

Function DetachItemFromArray

lib/cJSON.c:1955–1985  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1953}
1954
1955static cJSON *DetachItemFromArray(cJSON *array, size_t which)
1956{
1957 cJSON *c = array->child;
1958 while (c && (which > 0))
1959 {
1960 c = c->next;
1961 which--;
1962 }
1963 if (!c)
1964 {
1965 /* item doesn't exist */
1966 return NULL;
1967 }
1968 if (c->prev)
1969 {
1970 /* not the first element */
1971 c->prev->next = c->next;
1972 }
1973 if (c->next)
1974 {
1975 c->next->prev = c->prev;
1976 }
1977 if (c==array->child)
1978 {
1979 array->child = c->next;
1980 }
1981 /* make sure the detached item doesn't point anywhere anymore */
1982 c->prev = c->next = NULL;
1983
1984 return c;
1985}
1986cJSON *cJSON_DetachItemFromArray(cJSON *array, int which)
1987{
1988 if (which < 0)

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected