logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

gd_alloc_funcs — specify an alternate memory manager for GetData's use

Description

       The gd_alloc_funcs() function allows the caller to specify an alternate memory manager for GetData to use
       when providing dynamically allocated data to the caller.  The caller should specify pointers to two func‐
       tions  which mimic the behaviour of the Standard Library's malloc(3) and free(3) functions.  Passing NULL
       is equivalent to passing a pointer to the corresponding Standard Library function, so the default  memory
       manager can be restored by passing all NULLs to this function.

       The   functions   gd_entry(3),   gd_error_string(3),   gd_fragment_affixes(3),   gd_linterp_tablename(3),
       gd_raw_filename(3), and gd_strtok(3) will use malloc_func to allocate the buffers they return.  The func‐
       tion gd_free_entry_strings(3) will use the specified free_func to deallocate entry strings, and that same
       function will also be used by GetData to deallocate strings returned by any  registered  parser  callback
       function (see gd_cbopen(3)).

       Internally, GetData may still allocate buffers on a different heap, and the caller should not assume that
       any  other  pointer returned by the library were allocated with the functions specified by this function.
       Neither should the caller assume that these functions won't be used by GetData library functions to allo‐
       cate and deallocate temporary buffers.

       Changes made to the memory manager are global across GetData.  The caller should only call this  function
       when it is certain that no object allocated with the old memory manager still exists.

       This function always succeeds and returns no value.

History

       The gd_alloc_funcs() function appeared in GetData-0.10.0.

Name

       gd_alloc_funcs — specify an alternate memory manager for GetData's use

See Also

free(3),  gd_cbopen(3), gd_entry(3), gd_error_string(3), gd_fragment_affixes(3), gd_free_entry_strings(3)
       gd_linterp_tablename(3), gd_raw_filename(3), gd_strtok(3), malloc(3)

Version 0.10.1                                    5 April 2017                                 gd_alloc_funcs(3)

Synopsis

#include<getdata.h>voidgd_alloc_funcs(void*(*malloc_func)(size_t),void(*free_func)(void*));

See Also