diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-06 04:39:52 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-02-06 04:39:52 +0300 |
commit | da99f5b139d699ec89a4b36bfa4d592c41b56342 (patch) | |
tree | 834c1e1ab6e5e364a71160b925db6c49d7e7174b /src/mem_pool.c | |
parent | 267c8bf962fbfd5ab7384ba25043ae649dfbe928 (diff) | |
download | rspamd-da99f5b139d699ec89a4b36bfa4d592c41b56342.tar.gz rspamd-da99f5b139d699ec89a4b36bfa4d592c41b56342.zip |
* Fix alignment in memory_pool library (thanks to Marcin Rzewucki)
Diffstat (limited to 'src/mem_pool.c')
-rw-r--r-- | src/mem_pool.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mem_pool.c b/src/mem_pool.c index 63fe77809..38e45e662 100644 --- a/src/mem_pool.c +++ b/src/mem_pool.c @@ -74,7 +74,7 @@ pool_chain_new (gsize size) } chain->len = size; - chain->pos = chain->begin; + chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT); chain->next = NULL; STAT_LOCK (); mem_pool_stat->chunks_allocated++; @@ -116,6 +116,7 @@ pool_chain_new_shared (gsize size) #endif chain->len = size; chain->pos = chain->begin; + chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT); chain->lock = NULL; chain->next = NULL; STAT_LOCK (); @@ -215,8 +216,8 @@ memory_pool_alloc (memory_pool_t * pool, gsize size) STAT_UNLOCK (); return new->begin; } - tmp = cur->pos; - cur->pos += size; + tmp = align_ptr (cur->pos, MEM_ALIGNMENT); + cur->pos = tmp + size; STAT_LOCK (); mem_pool_stat->bytes_allocated += size; STAT_UNLOCK (); @@ -332,8 +333,8 @@ memory_pool_alloc_shared (memory_pool_t * pool, gsize size) STAT_UNLOCK (); return new->begin; } - tmp = cur->pos; - cur->pos += size; + tmp = align_ptr (cur->pos, MEM_ALIGNMENT); + cur->pos = tmp + size; STAT_LOCK (); mem_pool_stat->bytes_allocated += size; STAT_UNLOCK (); |