MCPcopy Create free account
hub / github.com/esnet/iperf / cJSON_strdup

Function cJSON_strdup

src/cjson.c:199–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
198
199static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
200{
201 size_t length = 0;
202 unsigned char *copy = NULL;
203
204 if (string == NULL)
205 {
206 return NULL;
207 }
208
209 length = strlen((const char*)string) + sizeof("");
210 copy = (unsigned char*)hooks->allocate(length);
211 if (copy == NULL)
212 {
213 return NULL;
214 }
215 memcpy(copy, string, length);
216
217 return copy;
218}
219
220CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
221{

Callers 6

cJSON_SetValuestringFunction · 0.85
add_item_to_objectFunction · 0.85
replace_item_in_objectFunction · 0.85
cJSON_CreateStringFunction · 0.85
cJSON_CreateRawFunction · 0.85
cJSON_DuplicateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…