| 186 | static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; |
| 187 | |
| 188 | static 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 | |
| 209 | CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) |
| 210 | { |
no outgoing calls
no test coverage detected