diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/mem_pool.c | 8 | ||||
-rw-r--r-- | src/libutil/mem_pool.h | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c index 12fb761b1..edfb3c016 100644 --- a/src/libutil/mem_pool.c +++ b/src/libutil/mem_pool.c @@ -605,14 +605,18 @@ rspamd_mempool_alloc_shared_(rspamd_mempool_t *pool, gsize size, gsize alignment gchar * rspamd_mempool_strdup_(rspamd_mempool_t *pool, const gchar *src, const gchar *loc) { - gsize len; + return rspamd_mempool_strdup_len_(pool, src, strlen(src), loc); +} + +gchar * +rspamd_mempool_strdup_len_(rspamd_mempool_t *pool, const gchar *src, gsize len, const gchar *loc) +{ gchar *newstr; if (src == NULL) { return NULL; } - len = strlen(src); newstr = rspamd_mempool_alloc_(pool, len + 1, MIN_MEM_ALIGNMENT, loc); memcpy(newstr, src, len); newstr[len] = '\0'; diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h index e3bb2b5cd..425a6b297 100644 --- a/src/libutil/mem_pool.h +++ b/src/libutil/mem_pool.h @@ -216,6 +216,10 @@ gchar *rspamd_mempool_strdup_(rspamd_mempool_t *pool, const gchar *src, const gc RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT); #define rspamd_mempool_strdup(pool, src) \ rspamd_mempool_strdup_((pool), (src), (G_STRLOC)) +gchar *rspamd_mempool_strdup_len_(rspamd_mempool_t *pool, const gchar *src, gsize len, const gchar *loc) + RSPAMD_ATTR_ALLOC_ALIGN(MIN_MEM_ALIGNMENT); +#define rspamd_mempool_strdup_len(pool, src, len) \ + rspamd_mempool_strdup_len_((pool), (src), (len), (G_STRLOC)) struct f_str_tok; |