Function
judo_free
Free the in-memory tree.
Parameters 🔗
| root | in | Root of the in-memory JSON tree. |
| udata | in | User pointer to pass through to |
| memfunc | in | Memory allocator callback. |
Return Value 🔗
| JUDO_RESULT_SUCCESS | If |
| JUDO_RESULT_INVALID_OPERATION | If |
| JUDO_RESULT_MALFUNCTION | If there is a defect in the implementation. |
Discussion 🔗
The judo_free function releases memory associated with root using memfunc. The argument root must reference the root value of the JSON tree as returned by judo_parse otherwise the behavior is undefined.
The memfunc function must implement a memory allocator as described in judo_memfunc. The udata pointer is passed to memfunc as-is.
The judo_free function is intended for a memfunc implementation that utilizes general purpose memory allocators, like malloc and free. If a specialized allocator is implemented where allocated objects can be efficiently deallocated all at once (e.g. a region-based memory allocator), then judo_free does not need to be called as the caller can perform deallocation themselves.