aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-08-15 12:32:23 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-08-15 12:32:23 +0100
commit6a6536afd9c12b70c66bc9e53623eb6530b2ca73 (patch)
tree6c97014baa4be8358c388bfaef3e104ddf82955d /src/libutil
parent028a29f991f98aff5c838145e6dd6fbebd07d187 (diff)
downloadrspamd-6a6536afd9c12b70c66bc9e53623eb6530b2ca73.tar.gz
rspamd-6a6536afd9c12b70c66bc9e53623eb6530b2ca73.zip
[Rework] Further conversion routines
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/mem_pool.c8
-rw-r--r--src/libutil/mem_pool.h4
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;