---
name: "gd_alloc_funcs"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_alloc_funcs"
---

# gd\_alloc\_funcs(3)

specify an alternate memory manager for GetData's use

## NAME

gd\_alloc\_funcs — specify an alternate memory manager for GetData's use

## SYNOPSIS

**#include \<getdata.h\>**

**void gd\_alloc\_funcs(void \*(\****malloc\_func***)(size\_t),** **void (\****free\_func***)(void\*));**

## 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 functions which mimic the behaviour of the Standard Library's [**malloc**(3)](/malloc/3.md) and [**free**(3)](/free/3.md) 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_entry/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_fragment\_affixes**(3)](/gd_fragment_affixes/3.md), [**gd\_linterp\_tablename**(3)](/gd_linterp_tablename/3.md), [**gd\_raw\_filename**(3)](/gd_raw_filename/3.md), and [**gd\_strtok**(3)](/gd_strtok/3.md) will use *malloc\_func* to allocate the buffers they return.  The function [**gd\_free\_entry\_strings**(3)](/gd_free_entry_strings/3.md) 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)](/gd_cbopen/3.md)).

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

## SEE ALSO

[**free**(3)](/free/3.md), [**gd\_cbopen**(3)](/gd_cbopen/3.md), [**gd\_entry**(3)](/gd_entry/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_fragment\_affixes**(3)](/gd_fragment_affixes/3.md), [**gd\_free\_entry\_strings**(3)](/gd_free_entry_strings/3.md) [**gd\_linterp\_tablename**(3)](/gd_linterp_tablename/3.md), [**gd\_raw\_filename**(3)](/gd_raw_filename/3.md), [**gd\_strtok**(3)](/gd_strtok/3.md), [**malloc**(3)](/malloc/3.md)
