Skip to content

Commit a6fbd7e

Browse files
committed
README: Mention alignment
Remove "Caveats" section, since now that only applies when compiling with 'LIBPOOL_NO_ALIGNMENT' defined.
1 parent 6242eef commit a6fbd7e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

README.org

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ support, we will see 111 allocations because it also checked the calls to
113113
You might need to install some =valgrind-devel= package in your system in order to
114114
include 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

118134
Clone 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

155171
You 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

Comments
 (0)