commit 35179d9: [Minor] Allocate variable in the pool and avoid malloc

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Mar 10 16:00:09 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-03-10 15:59:20 +0000
URL: https://github.com/rspamd/rspamd/commit/35179d94a8af87c5b86e45d0bd1ba9a276d34844 (HEAD -> master)

[Minor] Allocate variable in the pool and avoid malloc

---
 src/libstat/learn_cache/redis_cache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index 301232d28..a73a79b8c 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -222,7 +222,10 @@ rspamd_stat_cache_redis_generate_id (struct rspamd_task *task)
 
 	rspamd_cryptobox_hash_final (&st, out);
 
-	b32out = rspamd_encode_base32 (out, sizeof (out));
+	b32out = rspamd_mempool_alloc (task->task_pool,
+			sizeof (out) * 8 / 5 + 2);
+	rspamd_encode_base32_buf (out, sizeof (out), b32out,
+			sizeof (out) * 8 / 5 + 2);
 	g_assert (b32out != NULL);
 	rspamd_mempool_set_variable (task->task_pool, "words_hash", b32out, g_free);
 }


More information about the Commits mailing list