MCPcopy Create free account
hub / github.com/Tencent/Hardcoder / cJSON_InitHooks

Function cJSON_InitHooks

libapp2sys/src/main/cpp/cjson/cJSON.c:171–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
172{
173 if (hooks == NULL)
174 {
175 /* Reset hooks */
176 global_hooks.allocate = malloc;
177 global_hooks.deallocate = free;
178 global_hooks.reallocate = realloc;
179 return;
180 }
181
182 global_hooks.allocate = malloc;
183 if (hooks->malloc_fn != NULL)
184 {
185 global_hooks.allocate = hooks->malloc_fn;
186 }
187
188 global_hooks.deallocate = free;
189 if (hooks->free_fn != NULL)
190 {
191 global_hooks.deallocate = hooks->free_fn;
192 }
193
194 /* use realloc only if both free and malloc are used */
195 global_hooks.reallocate = NULL;
196 if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
197 {
198 global_hooks.reallocate = realloc;
199 }
200}
201
202/* Internal constructor. */
203static cJSON *cJSON_New_Item(const internal_hooks * const hooks)

Callers 1

cJSON.hFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected