]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some alignment issues
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 Dec 2021 14:45:30 +0000 (14:45 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 4 Dec 2021 14:45:30 +0000 (14:45 +0000)
src/libserver/maps/map_helpers.c
src/libutil/mem_pool.h

index 9ac84a81efe8b95b5e4f232d5c835b9dafd6313c..a29467497f80a789378228129a4885f880618e70 100644 (file)
@@ -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 ();
index 1847980bb359f768c90deb9d156f535048216f7b..2db36e03a4c8b783c36b66575d0565f0a070159d 100644 (file)
@@ -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