MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / add_item_to_object

Function add_item_to_object

libapp2sys/src/main/cpp/cjson/cJSON.c:1903–1938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1901
1902
1903static 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)
1904{
1905 char *new_key = NULL;
1906 int new_type = cJSON_Invalid;
1907
1908 if ((object == NULL) || (string == NULL) || (item == NULL))
1909 {
1910 return false;
1911 }
1912
1913 if (constant_key)
1914 {
1915 new_key = (char*)cast_away_const(string);
1916 new_type = item->type | cJSON_StringIsConst;
1917 }
1918 else
1919 {
1920 new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks);
1921 if (new_key == NULL)
1922 {
1923 return false;
1924 }
1925
1926 new_type = item->type & ~cJSON_StringIsConst;
1927 }
1928
1929 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
1930 {
1931 hooks->deallocate(item->string);
1932 }
1933
1934 item->string = new_key;
1935 item->type = new_type;
1936
1937 return add_item_to_array(object, item);
1938}
1939
1940CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
1941{

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 4

cast_away_constFunction · 0.85
cJSON_strdupFunction · 0.85
add_item_to_arrayFunction · 0.85
deallocateMethod · 0.80

Tested by

no test coverage detected