From 553bd31ac240a9c2eff73133f9427ce090d9a6bb Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 4 Dec 2021 14:45:30 +0000 Subject: [PATCH] [Minor] Fix some alignment issues --- src/libserver/maps/map_helpers.c | 6 +++--- src/libutil/mem_pool.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libserver/maps/map_helpers.c b/src/libserver/maps/map_helpers.c index 9ac84a81e..a29467497 100644 --- a/src/libserver/maps/map_helpers.c +++ b/src/libserver/maps/map_helpers.c @@ -741,7 +741,7 @@ rspamd_map_helper_new_hash (struct rspamd_map *map) NULL, 0); } - htb = rspamd_mempool_alloc0 (pool, sizeof (*htb)); + htb = rspamd_mempool_alloc0_type(pool, struct rspamd_hash_map_helper); htb->htb = kh_init (rspamd_map_hash); htb->pool = pool; htb->map = map; @@ -801,7 +801,7 @@ rspamd_map_helper_new_radix (struct rspamd_map *map) NULL, 0); } - r = rspamd_mempool_alloc0 (pool, sizeof (*r)); + r = rspamd_mempool_alloc0_type (pool, struct rspamd_radix_map_helper); r->trie = radix_create_compressed_with_pool (pool, name); r->htb = kh_init (rspamd_map_hash); r->pool = pool; @@ -855,7 +855,7 @@ rspamd_map_helper_new_regexp (struct rspamd_map *map, pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), map->tag, 0); - re_map = rspamd_mempool_alloc0 (pool, sizeof (*re_map)); + re_map = rspamd_mempool_alloc0_type (pool, struct rspamd_regexp_map_helper); re_map->pool = pool; re_map->values = g_ptr_array_new (); re_map->regexps = g_ptr_array_new (); diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h index 1847980bb..2db36e03a 100644 --- a/src/libutil/mem_pool.h +++ b/src/libutil/mem_pool.h @@ -161,7 +161,8 @@ void *rspamd_mempool_alloc_ (rspamd_mempool_t *pool, gsize size, gsize alignment #define rspamd_mempool_alloc(pool, size) \ rspamd_mempool_alloc_((pool), (size), MIN_MEM_ALIGNMENT, (G_STRLOC)) #define rspamd_mempool_alloc_type(pool, type) \ - (type *)(rspamd_mempool_alloc_((pool), sizeof(type), RSPAMD_ALIGNOF(type), (G_STRLOC))) + (type *)(rspamd_mempool_alloc_((pool), sizeof(type), \ + MAX(MIN_MEM_ALIGNMENT, RSPAMD_ALIGNOF(type)), (G_STRLOC))) #define rspamd_mempool_alloc_buffer(pool, buflen) \ (char *)(rspamd_mempool_alloc_((pool), sizeof(char) * (buflen), MIN_MEM_ALIGNMENT, (G_STRLOC))) /** @@ -185,7 +186,8 @@ void *rspamd_mempool_alloc0_ (rspamd_mempool_t *pool, gsize size, gsize alignmen #define rspamd_mempool_alloc0(pool, size) \ rspamd_mempool_alloc0_((pool), (size), MIN_MEM_ALIGNMENT, (G_STRLOC)) #define rspamd_mempool_alloc0_type(pool, type) \ - (type *)(rspamd_mempool_alloc0_((pool), sizeof(type), RSPAMD_ALIGNOF(type), (G_STRLOC))) + (type *)(rspamd_mempool_alloc0_((pool), sizeof(type), \ + MAX(MIN_MEM_ALIGNMENT, RSPAMD_ALIGNOF(type)), (G_STRLOC))) /** * Make a copy of string in pool -- 2.39.5