MCPcopy Create free account
hub / github.com/Netis/cloud-probe / add_item_to_object

Function add_item_to_object

cpworker/src/cJSON/cJSON.c:2029–2064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2027
2028
2029static cJSON_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_bool constant_key)
2030{
2031 char *new_key = NULL;
2032 int new_type = cJSON_Invalid;
2033
2034 if ((object == NULL) || (string == NULL) || (item == NULL) || (object == item))
2035 {
2036 return false;
2037 }
2038
2039 if (constant_key)
2040 {
2041 new_key = (char*)cast_away_const(string);
2042 new_type = item->type | cJSON_StringIsConst;
2043 }
2044 else
2045 {
2046 new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks);
2047 if (new_key == NULL)
2048 {
2049 return false;
2050 }
2051
2052 new_type = item->type & ~cJSON_StringIsConst;
2053 }
2054
2055 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
2056 {
2057 hooks->deallocate(item->string);
2058 }
2059
2060 item->string = new_key;
2061 item->type = new_type;
2062
2063 return add_item_to_array(object, item);
2064}
2065
2066CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
2067{

Callers 12

cJSON_AddItemToObjectFunction · 0.85
cJSON_AddItemToObjectCSFunction · 0.85
cJSON_AddNullToObjectFunction · 0.85
cJSON_AddTrueToObjectFunction · 0.85
cJSON_AddFalseToObjectFunction · 0.85
cJSON_AddBoolToObjectFunction · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_AddStringToObjectFunction · 0.85
cJSON_AddRawToObjectFunction · 0.85
cJSON_AddObjectToObjectFunction · 0.85
cJSON_AddArrayToObjectFunction · 0.85

Calls 3

cast_away_constFunction · 0.85
cJSON_strdupFunction · 0.85
add_item_to_arrayFunction · 0.85

Tested by

no test coverage detected