From d8a89b0b159077c83ba872903039afacac6fb903 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 23 Nov 2016 13:04:11 +0000 Subject: [PATCH] [Minor] Adjust multipattern sizes --- src/libserver/url.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libserver/url.c b/src/libserver/url.c index acddc464f..a4f82cd9e 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -439,10 +439,21 @@ rspamd_url_init (const gchar *tld_file) if (url_scanner == NULL) { url_scanner = g_malloc (sizeof (struct url_match_scanner)); - url_scanner->matchers = g_array_sized_new (FALSE, TRUE, - sizeof (struct url_matcher), 512); - url_scanner->search_trie = rspamd_multipattern_create_sized (512, + + if (tld_file) { + /* Reserve larger multipattern */ + url_scanner->matchers = g_array_sized_new (FALSE, TRUE, + sizeof (struct url_matcher), 13000); + url_scanner->search_trie = rspamd_multipattern_create_sized (13000, RSPAMD_MULTIPATTERN_TLD | RSPAMD_MULTIPATTERN_ICASE); + } + else { + url_scanner->matchers = g_array_sized_new (FALSE, TRUE, + sizeof (struct url_matcher), 128); + url_scanner->search_trie = rspamd_multipattern_create_sized (128, + RSPAMD_MULTIPATTERN_TLD | RSPAMD_MULTIPATTERN_ICASE); + } + rspamd_url_add_static_matchers (url_scanner); if (tld_file != NULL) { -- 2.39.5