Replace array/object items with new ones. */
| 2139 | |
| 2140 | /* Replace array/object items with new ones. */ |
| 2141 | CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) |
| 2142 | { |
| 2143 | cJSON *after_inserted = NULL; |
| 2144 | |
| 2145 | if (which < 0) |
| 2146 | { |
| 2147 | return; |
| 2148 | } |
| 2149 | |
| 2150 | after_inserted = get_array_item(array, (size_t)which); |
| 2151 | if (after_inserted == NULL) |
| 2152 | { |
| 2153 | add_item_to_array(array, newitem); |
| 2154 | return; |
| 2155 | } |
| 2156 | |
| 2157 | newitem->next = after_inserted; |
| 2158 | newitem->prev = after_inserted->prev; |
| 2159 | after_inserted->prev = newitem; |
| 2160 | if (after_inserted == array->child) |
| 2161 | { |
| 2162 | array->child = newitem; |
| 2163 | } |
| 2164 | else |
| 2165 | { |
| 2166 | newitem->prev->next = newitem; |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) |
| 2171 | { |
nothing calls this directly
no test coverage detected