aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-21 17:28:48 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-21 17:29:18 +0100
commit977aa1d0d29b5b48b31279d7709a7209001ee309 (patch)
tree11ea8495917124a6cbdb106bfaece6ab87c80e28 /lib
parentb575a98826184fc34750ef2cce4fa1503938b7f2 (diff)
Force 64 bit alignment of blocks managed by the pool allocator
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/mempool.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/util/mempool.c b/lib/util/mempool.c
index dd2d692..57aab4d 100644
--- a/lib/util/mempool.c
+++ b/lib/util/mempool.c
@@ -14,6 +14,7 @@
#include <sys/mman.h>
#define DEF_POOL_SIZE (65536)
+#define MEM_ALIGN (8)
typedef struct pool_t {
struct pool_t *next;
@@ -99,6 +100,9 @@ mem_pool_t *mem_pool_create(size_t obj_size)
if (mem == NULL)
return NULL;
+ if (obj_size % MEM_ALIGN)
+ obj_size += MEM_ALIGN - obj_size % MEM_ALIGN;
+
for (;;) {
total = pool_size_from_bitmap_count(count, obj_size);
if (total > DEF_POOL_SIZE)