MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / cJSON_InitHooks

Function cJSON_InitHooks

cJSON.c:209–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks)
210{
211 if (hooks == NULL)
212 {
213 /* Reset hooks */
214 global_hooks.allocate = malloc;
215 global_hooks.deallocate = free;
216 global_hooks.reallocate = realloc;
217 return;
218 }
219
220 global_hooks.allocate = malloc;
221 if (hooks->malloc_fn != NULL)
222 {
223 global_hooks.allocate = hooks->malloc_fn;
224 }
225
226 global_hooks.deallocate = free;
227 if (hooks->free_fn != NULL)
228 {
229 global_hooks.deallocate = hooks->free_fn;
230 }
231
232 /* use realloc only if both free and malloc are used */
233 global_hooks.reallocate = NULL;
234 if ((global_hooks.allocate == malloc) && (global_hooks.deallocate == free))
235 {
236 global_hooks.reallocate = realloc;
237 }
238}
239
240/* Internal constructor. */
241static cJSON *cJSON_New_Item(const internal_hooks * const hooks)

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…