---
name: "xo_set_allocator"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/xo_set_allocator"
---

# xo\_set\_allocator(3)

set allocation functions for libxo

## NAME

**xo\_set\_allocator** – set allocation functions for libxo

## LIBRARY

library “libxo”

## SYNOPSIS

**#include \<libxo/xo.h\>**

**typedef** **void** **\*(\*xo\_realloc\_func\_t)(void** **\*,** **size\_t);**

**typedef** **void** **(\*xo\_free\_func\_t)(void** **\*);**

*void*\

**xo\_set\_allocator**(*xo\_realloc\_func\_t realloc\_func*, *xo\_free\_func\_t free\_func*);

## DESCRIPTION

The **xo\_set\_allocator**() function allows **libxo** to be used in environments where the standard [realloc(3)](/realloc/3.md) and [free(3)](/free/3.md) functions are not available.

*realloc\_func* should expect the same arguments as [realloc(3)](/realloc/3.md) and return a pointer to memory following the same convention. *free\_func* will receive the same argument as [free(3)](/free/3.md) and should release it, as appropriate for the environment.

By default, the standard [realloc(3)](/realloc/3.md) and [free(3)](/free/3.md) functions are used.

## SEE ALSO

[xo\_emit(3)](/xo_emit/3.md), [libxo(3)](/libxo/3.md)

## HISTORY

The **libxo** library first appeared in FreeBSD 11.0.

## AUTHORS

**libxo** was written by Phil Shafer ⟨*phil@freebsd.org*⟩.
