diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-21 16:28:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-05-21 16:28:08 +0100 |
commit | d444d10095936cd246a41d3eeda66d279efec612 (patch) | |
tree | 92c8da95996408b219808c43e5f3cd2c9ddc5e60 /src/libutil | |
parent | 9f3b009464f883f70e7faf67ade43c6579951e95 (diff) | |
download | rspamd-d444d10095936cd246a41d3eeda66d279efec612.tar.gz rspamd-d444d10095936cd246a41d3eeda66d279efec612.zip |
[Minor] Allow typed mempool alloc
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/mem_pool.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h index a908af1ee..eea1c6358 100644 --- a/src/libutil/mem_pool.h +++ b/src/libutil/mem_pool.h @@ -153,7 +153,8 @@ void *rspamd_mempool_alloc_ (rspamd_mempool_t *pool, gsize size, const gchar *lo RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; #define rspamd_mempool_alloc(pool, size) \ rspamd_mempool_alloc_((pool), (size), (G_STRLOC)) - +#define rspamd_mempool_alloc_type(pool, type) \ + (type *)(rspamd_mempool_alloc_((pool), sizeof(type), (G_STRLOC))) /** * Notify external memory usage for memory pool * @param pool @@ -174,6 +175,8 @@ void *rspamd_mempool_alloc0_ (rspamd_mempool_t *pool, gsize size, const gchar *l RSPAMD_ATTR_ALLOC_SIZE(2) RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT) RSPAMD_ATTR_RETURNS_NONNUL; #define rspamd_mempool_alloc0(pool, size) \ rspamd_mempool_alloc0_((pool), (size), (G_STRLOC)) +#define rspamd_mempool_alloc0_type(pool, type) \ + (type *)(rspamd_mempool_alloc0_((pool), sizeof(type), (G_STRLOC))) /** * Make a copy of string in pool |