MCPcopy Index your code
hub / github.com/antirez/botlib / cJSON_strdup

Function cJSON_strdup

cJSON.c:188–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
187
188static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
189{
190 size_t length = 0;
191 unsigned char *copy = NULL;
192
193 if (string == NULL)
194 {
195 return NULL;
196 }
197
198 length = strlen((const char*)string) + sizeof("");
199 copy = (unsigned char*)hooks->allocate(length);
200 if (copy == NULL)
201 {
202 return NULL;
203 }
204 memcpy(copy, string, length);
205
206 return copy;
207}
208
209CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
210{

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