From: Vsevolod Stakhov Date: Mon, 16 Jul 2018 14:13:29 +0000 (+0100) Subject: [Minor] Optimise allocation size slightly X-Git-Tag: 1.7.9~111 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=86c9af08233e9892312d573e8e35084093b40679;p=rspamd.git [Minor] Optimise allocation size slightly --- diff --git a/src/libserver/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend_redis.c index 14976a5d9..7bb442a27 100644 --- a/src/libserver/fuzzy_backend_redis.c +++ b/src/libserver/fuzzy_backend_redis.c @@ -1009,7 +1009,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, key = g_string_sized_new (klen); g_string_append (key, session->backend->redis_object); g_string_append_len (key, cmd->digest, sizeof (cmd->digest)); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("4294967296")); rspamd_printf_gstring (value, "%d", cmd->flag); session->argv[cur_shift] = g_strdup ("HSET"); session->argv_lens[cur_shift++] = sizeof ("HSET") - 1; @@ -1036,7 +1036,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, key = g_string_sized_new (klen); g_string_append (key, session->backend->redis_object); g_string_append_len (key, cmd->digest, sizeof (cmd->digest)); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("18446744073709551616")); rspamd_printf_gstring (value, "%L", (gint64)rspamd_get_calendar_ticks ()); session->argv[cur_shift] = g_strdup ("HSETNX"); session->argv_lens[cur_shift++] = sizeof ("HSETNX") - 1; @@ -1061,7 +1061,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, key = g_string_sized_new (klen); g_string_append (key, session->backend->redis_object); g_string_append_len (key, cmd->digest, sizeof (cmd->digest)); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("4294967296")); rspamd_printf_gstring (value, "%d", cmd->value); session->argv[cur_shift] = g_strdup ("HINCRBY"); session->argv_lens[cur_shift++] = sizeof ("HINCRBY") - 1; @@ -1086,7 +1086,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, key = g_string_sized_new (klen); g_string_append (key, session->backend->redis_object); g_string_append_len (key, cmd->digest, sizeof (cmd->digest)); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("4294967296")); rspamd_printf_gstring (value, "%d", (gint)rspamd_fuzzy_backend_get_expire (bk)); session->argv[cur_shift] = g_strdup ("EXPIRE"); @@ -1178,7 +1178,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, key = g_string_sized_new (klen); g_string_append (key, session->backend->redis_object); g_string_append_len (key, cmd->digest, sizeof (cmd->digest)); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("4294967296")); rspamd_printf_gstring (value, "%d", (gint)rspamd_fuzzy_backend_get_expire (bk)); session->argv[cur_shift] = g_strdup ("EXPIRE"); @@ -1223,7 +1223,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, session->backend->redis_object, i, io_cmd->cmd.shingle.sgl.hashes[i]); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("4294967296")); rspamd_printf_gstring (value, "%d", (gint)rspamd_fuzzy_backend_get_expire (bk)); hval = g_malloc (sizeof (io_cmd->cmd.shingle.basic.digest)); @@ -1290,7 +1290,7 @@ rspamd_fuzzy_update_append_command (struct rspamd_fuzzy_backend *bk, session->backend->redis_object, i, io_cmd->cmd.shingle.sgl.hashes[i]); - value = g_string_sized_new (30); + value = g_string_sized_new (sizeof ("18446744073709551616")); rspamd_printf_gstring (value, "%d", (gint)rspamd_fuzzy_backend_get_expire (bk)); session->argv[cur_shift] = g_strdup ("EXPIRE");