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