docs/Writerside/topics/memory.md

Sat, 08 Feb 2025 20:38:05 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 08 Feb 2025 20:38:05 +0100
branch
docs/3.1
changeset 1171
155bc3b0dcb3
parent 1170
49cc0bbea6a9
permissions
-rw-r--r--

adds documentation for destructor functions and collections

also invented some new macros for the collection.h

relates to #451

# Memory Management

With the `CxAllocator` interface UCX provides the possibility to use custom allocator functions for different purposes.
Many UCX functions support the use of specialized allocators or provide a second function suffixed with `_a`.

For convenience, functions that are not explicitly requesting an allocator - like e.g. `cx_strdup_a()` - also accept
`NULL` as an allocator, in which case the `cxDefaultAllocator` and stdlib functions are used.

Additionally, UCX also provides a [memory pool](mempool.h.md) implementation of the allocator interface.

> Although not part of the public API, UCX is also implementing the allocator interface
> in its own test suite: `CxTestingAllocator`. This allocator keeps track of memory allocations
> and de-allocations with the goal to detect memory management errors.  

mercurial