xtc_free(3)

---

xtc_free(3)

public allocation, clock, sleep, and atomic helpers

XTC_FREE(3) Library Functions Manual XTC_FREE(3)

xtc_free, xtc_malloc, xtc_calloc, xtc_realloc, xtc_aligned_alloc, xtc_aligned_free, xtc_clock_mono, xtc_clock_real, xtc_sleep_ns, xtc_atomic_i64_load, xtc_atomic_i64_addpublic allocation, clock, sleep, and atomic helpers

#include <xtc.h>

void
xtc_free(void *p);

void *
xtc_malloc(size_t size);

void *
xtc_calloc(size_t n, size_t size);

void *
xtc_realloc(void *p, size_t size);

void *
xtc_aligned_alloc(size_t align, size_t size);

void
xtc_aligned_free(void *p);

int64_t
xtc_clock_mono(void);

int64_t
xtc_clock_real(void);

int
xtc_sleep_ns(int64_t ns);

int64_t
xtc_atomic_i64_load(const int64_t *p);

int64_t
xtc_atomic_i64_add(int64_t *p, int64_t delta);

These are the public complement to the library's internal portability layer: a CONSUMER of libxtc uses only these () entry points and never the internal () wrappers.

() releases a heap buffer that a libxtc call allocated and handed to the caller to own. Several APIs return caller-owned buffers and document that they must be released with xtc_free():

These buffers are allocated by libxtc's own allocator, which is not necessarily the C library malloc(3)/free(3), so they must be released through () rather than plain free(3). Passing NULL is a no-op. xtc_free() is safe to call from any thread.

(), (), and () allocate through libxtc's allocator (the same one xtc_free() releases, overridable via the allocator hook), returning the pointer directly and NULL on failure; the result is released with xtc_free(). A zero size yields a unique freeable pointer, not NULL. () returns memory aligned to align (a power of two), released ONLY with () (never xtc_free()).

() and () read the monotonic and real clocks in nanoseconds (returning 0 on the rare query failure). () sleeps the calling OS THREAD; inside a fiber use xtc_proc_sleep(3) instead, which parks the fiber without blocking the loop. () and () (which returns the prior value) are the minimal public atomics for a shared 64-bit counter.

xtc_free() and xtc_aligned_free() return no value. xtc_malloc(), xtc_calloc(), xtc_realloc(), and xtc_aligned_alloc() return the allocated pointer, or NULL on failure. xtc_clock_mono() and xtc_clock_real() return a nanosecond count (0 on failure). xtc_sleep_ns() returns XTC_OK or a negative XTC_E_* code. xtc_atomic_i64_load() returns the current value; xtc_atomic_i64_add() returns the value before the add.

xtc_proc(3), xtc_net(3), xtc_osproc(3), xtc_svr(3)

July 6, 2026 Debian

View the mdoc source