|
@@ -2171,20 +2171,19 @@ CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const
|
|
}
|
|
}
|
|
|
|
|
|
/* Replace array/object items with new ones. */
|
|
/* 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;
|
|
cJSON *after_inserted = NULL;
|
|
|
|
|
|
if (which < 0)
|
|
if (which < 0)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
after_inserted = get_array_item(array, (size_t)which);
|
|
after_inserted = get_array_item(array, (size_t)which);
|
|
if (after_inserted == NULL)
|
|
if (after_inserted == NULL)
|
|
{
|
|
{
|
|
- add_item_to_array(array, newitem);
|
|
|
|
- return;
|
|
|
|
|
|
+ return add_item_to_array(array, newitem);
|
|
}
|
|
}
|
|
|
|
|
|
newitem->next = after_inserted;
|
|
newitem->next = after_inserted;
|
|
@@ -2198,6 +2197,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
|
|
{
|
|
{
|
|
newitem->prev->next = newitem;
|
|
newitem->prev->next = newitem;
|
|
}
|
|
}
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
|
|
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement)
|
|
@@ -2241,14 +2241,14 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
-CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
|
|
|
|
|
|
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem)
|
|
{
|
|
{
|
|
if (which < 0)
|
|
if (which < 0)
|
|
{
|
|
{
|
|
- return;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
- cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
|
|
|
|
|
|
+ return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem);
|
|
}
|
|
}
|
|
|
|
|
|
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
|
|
static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
|
|
@@ -2266,19 +2266,17 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO
|
|
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
|
|
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks);
|
|
replacement->type &= ~cJSON_StringIsConst;
|
|
replacement->type &= ~cJSON_StringIsConst;
|
|
|
|
|
|
- cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
|
|
+ return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement);
|
|
}
|
|
}
|
|
|
|
|
|
-CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
|
|
|
|
|
|
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem)
|
|
{
|
|
{
|
|
- replace_item_in_object(object, string, newitem, false);
|
|
|
|
|
|
+ return replace_item_in_object(object, string, newitem, false);
|
|
}
|
|
}
|
|
|
|
|
|
-CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
|
|
|
|
|
|
+CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem)
|
|
{
|
|
{
|
|
- replace_item_in_object(object, string, newitem, true);
|
|
|
|
|
|
+ return replace_item_in_object(object, string, newitem, true);
|
|
}
|
|
}
|
|
|
|
|
|
/* Create basic types: */
|
|
/* Create basic types: */
|