]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Optimise allocation size slightly
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Jul 2018 14:13:29 +0000 (15:13 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 16 Jul 2018 14:13:29 +0000 (15:13 +0100)
src/libserver/fuzzy_backend_redis.c

index 14976a5d92620ec6cea91164024cbb9ecfcd1665..7bb442a27e4d926447f4be9326386931922fdd06 100644 (file)
@@ -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");