@@ -113,6 +113,22 @@ support, we will see 111 allocations because it also checked the calls to
113113You might need to install some =valgrind-devel= package in your system in order to
114114include the necessary headers.
115115
116+ * Alignment
117+
118+ By default, when initializing a new pool with =pool_new=, the chunk sizes will be
119+ internally aligned to the size of a =void*=, so that all pointers returned by
120+ =pool_alloc= are also aligned.
121+
122+ In some specific cases, this can lead to unexpected pool sizes, so this behavior
123+ can be disabled at compile-time by defining =LIBPOOL_NO_ALIGNMENT=.
124+
125+ However, note that, when compiling the library with alignment disabled, the
126+ =pool_new= function will expect a chunk size greater or equal to the size of a
127+ =void*=. This is necessary because the implementation uses free chunks to build a
128+ linked list, which is what makes the library so efficient. If the =chunk_sz=
129+ parameter of =pool_new= is smaller than =sizeof(void*)=, the function will return
130+ =NULL=.
131+
116132* Building the example
117133
118134Clone the repository and build the project using =make=.
@@ -153,10 +169,3 @@ Without using a logarithmic scale in the Y axis:
153169[[file:assets/benchmark.svg]]
154170
155171You can adjust these values in the [[file:benchmark.sh][benchmark.sh]] script.
156-
157- * Caveats
158-
159- When creating a new pool, each element needs to be greater or equal to the size
160- of =void*=. This is necessary because the implementation uses free chunks to build
161- a linked list, which is what makes the library so efficient. If the =chunk_sz=
162- parameter of =pool_new= is smaller than =sizeof(void*)=, it will return =NULL=.
0 commit comments