| 197 | static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; |
| 198 | |
| 199 | static 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 | |
| 220 | CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) |
| 221 | { |
no outgoing calls
no test coverage detected
searching dependent graphs…