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