jansson icon indicating copy to clipboard operation
jansson copied to clipboard

Added support for passing a user argument to custom memory allocation functions

Open claudix opened this issue 9 years ago • 1 comments

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.

claudix avatar Mar 05 '15 10:03 claudix

LGTM. It would be better to add some example about usage.

harkue avatar Sep 29 '19 07:09 harkue