docs/Writerside/topics/allocator.h.md

changeset 1424
563033aa998c
parent 1420
c6f55a2b3495
equal deleted inserted replaced
1423:9a72258446cd 1424:563033aa998c
1 # Allocator 1 # Allocator
2 2
3 The allocator interface provides a mechanism to implement own custom allocators 3 The allocator interface provides a mechanism to implement own custom allocators
4 that can also be used in many other function in UCX. 4 that can also be used in many other functions in UCX.
5 5
6 A default allocator implementation using the stdlib functions is 6 A default allocator implementation using the stdlib functions is
7 available via the global symbol `cxStdlibAllocator`, 7 available via the global symbol `cxStdlibAllocator`,
8 and UCX also provides a [memory pool](mempool.h.md) implementation. 8 and UCX also provides a [memory pool](mempool.h.md) implementation.
9 You are free to add your additional, own custom implementations. 9 You are free to add your additional, own custom implementations.
10 A general sketch that illustrates how to do this can be found [below](#custom-allocator). 10 A general sketch that illustrates how to do this can be found [below](#custom-allocator).
11 11
12 ## Default Allocator 12 ## Default Allocator
13 13
14 The global default allocator which is used by UCX, 14 The global default allocator which is used by UCX
15 when no specific allocator is specified, 15 when no specific allocator is specified
16 can be configured via the `cxDefaultAllocator`. 16 can be configured via the `cxDefaultAllocator`.
17 It is by default set to the `cxStdlibAllocator`. 17 It is by default set to the `cxStdlibAllocator`.
18 18
19 ## Overview 19 ## Overview
20 20
154 The first one is called _simple_ destructor (e.g. in the context of [collections](collection.h.md)), 154 The first one is called _simple_ destructor (e.g. in the context of [collections](collection.h.md)),
155 and the second one is called _advanced_ destructor. 155 and the second one is called _advanced_ destructor.
156 The only difference is that you can pass additional custom `data` to an advanced destructor function. 156 The only difference is that you can pass additional custom `data` to an advanced destructor function.
157 157
158 Destructor functions play a vital role in deep deallocations. 158 Destructor functions play a vital role in deep deallocations.
159 Another scenarios, besides destroying elements in a collection, are the deallocation of objects 159 Another scenario, besides destroying elements in a collection, is the deallocation of objects
160 stored in a [memory pool](mempool.h.md) or deallocations of deeply nested [JSON](json.h.md) objects. 160 stored in a [memory pool](mempool.h.md) or deallocations of deeply nested [JSON](json.h.md) objects.
161 161
162 > Destructor functions are not to be confused with `free()`-like functions. 162 > Destructor functions are not to be confused with `free()`-like functions.
163 > The fundamental differences are that 163 > The fundamental differences are that
164 > * it is not safe to pass `NULL` to a destructor function 164 > * it is not safe to pass `NULL` to a destructor function

mercurial