Merge 311c82adc860b954852b540f05b3d5dec20501ac into d6c46342693205f0dae441b45742d9c85d41cf33

This commit is contained in:
Yan Naing Tun 2025-05-09 20:37:00 +08:00 committed by GitHub
commit 3efeb4bd98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2138,20 +2138,24 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const
}
/* Replace array/object items with new ones. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem)
{
cJSON *after_inserted = NULL;
if ((array == NULL) || (newitem == NULL))
{
return false;
}
if (which < 0)
{
return;
return false;
}
after_inserted = get_array_item(array, (size_t)which);
if (after_inserted == NULL)
{
add_item_to_array(array, newitem);
return;
return add_item_to_array(array, newitem);
}
newitem->next = after_inserted;
@ -2165,6 +2169,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
{
newitem->prev->next = newitem;
}
return true;
}
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)