jansson
jansson copied to clipboard
Added support for passing a user argument to custom memory allocation functions
I have added support for passing a user argument to custom memory allocation functions as discussed in https://github.com/akheron/jansson/issues/225
In particular:
- Two additional types have been created: json_malloc_arg_t and json_free_arg_t, which are similar to their json_malloc_t and json_free_t counterparts but the former ones get an extra argument (the user argument).
- A new function has been defined: json_set_alloc_funcs_arg. It does the same as its counterpart json_set_alloc_funcs but also accepts the user argument that will be passed to custom memory allocation functions.
Passing NULL as the user argument of json_set_alloc_funcs_arg treats the specified functions as user argument-less.
LGTM. It would be better to add some example about usage.