MCPcopy Create free account
hub / github.com/ByConity/ByConity / cJSON_strdup

Function cJSON_strdup

contrib/cJSON/cJSON.cpp:149–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
148
149static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
150{
151 size_t length = 0;
152 unsigned char *copy = NULL;
153
154 if (string == NULL)
155 {
156 return NULL;
157 }
158
159 length = strlen((const char*)string) + sizeof("");
160 copy = (unsigned char*)hooks->allocate(length);
161 if (copy == NULL)
162 {
163 return NULL;
164 }
165 memcpy(copy, string, length);
166
167 return copy;
168}
169
170CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
171{

Callers 7

parse_numberFunction · 0.85
add_item_to_objectFunction · 0.85
replace_item_in_objectFunction · 0.85
cJSON_CreateInt64Function · 0.85
cJSON_CreateStringFunction · 0.85
cJSON_CreateRawFunction · 0.85
cJSON_DuplicateFunction · 0.85

Calls 2

memcpyFunction · 0.85
allocateMethod · 0.45

Tested by

no test coverage detected