diff --git a/lib/bufferpool.c b/lib/bufferpool.c index 08e0cfbaa..8e988e479 100644 --- a/lib/bufferpool.c +++ b/lib/bufferpool.c @@ -3,8 +3,6 @@ #include #include "obj.h" -#define ALIGN 8 // bytes - struct bufferpool { void *(*alloc)(size_t); void (*dealloc)(void *); @@ -154,7 +152,7 @@ void *bufferpool_alloc(struct bufferpool *bp, size_t len) { void *ret = shard->head; shard->refs++; - shard->head += ((len + ALIGN - 1) / ALIGN) * ALIGN; + shard->head += BUFFERPOOL_ALIGN(len); return ret; } diff --git a/lib/bufferpool.h b/lib/bufferpool.h index aef2e87e4..ad2070505 100644 --- a/lib/bufferpool.h +++ b/lib/bufferpool.h @@ -3,6 +3,9 @@ #include "obj.h" +#define BUFFERPOOL_ALIGNMENT (sizeof(void *)) // bytes +#define BUFFERPOOL_ALIGN(x) (((x + BUFFERPOOL_ALIGNMENT - 1) / BUFFERPOOL_ALIGNMENT) * BUFFERPOOL_ALIGNMENT) + struct bufferpool; struct bpool_shard;