Function

judo_free

Free the in-memory tree.

Since v1.0
enum judo_result judo_free(
judo_value *root, void *udata, judo_memfunc memfunc)

Parameters 🔗

root in

Root of the in-memory JSON tree.

udata in

User pointer to pass through to memfunc.

memfunc in

Memory allocator callback.

Return Value 🔗

JUDO_RESULT_SUCCESS

If root was freed successfully.

JUDO_RESULT_INVALID_OPERATION

If memfunc is NULL.

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 user_data 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.