commit d444d10: [Minor] Allow typed mempool alloc
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri May 21 15:35:10 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-05-21 16:28:08 +0100
URL: https://github.com/rspamd/rspamd/commit/d444d10095936cd246a41d3eeda66d279efec612
[Minor] Allow typed mempool alloc
---
src/libutil/mem_pool.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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
More information about the Commits
mailing list