From f4f1480e2b4101ab44ae39c57e314d94fb1aa221 Mon Sep 17 00:00:00 2001 From: Eric Albright Date: Fri, 21 Dec 2007 03:53:02 +0000 Subject: allocate the exact size of the matcher path git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@22380 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6 --- src/pwl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pwl.c b/src/pwl.c index 0a6ede8..4a4b8fa 100644 --- a/src/pwl.c +++ b/src/pwl.c @@ -1075,10 +1075,11 @@ static EnchantTrieMatcher* enchant_trie_matcher_init(const char* const word, char * normalized_word, * pattern; normalized_word = g_utf8_normalize (word, len, G_NORMALIZE_NFD); + len = strlen(normalized_word); if(mode == case_insensitive) { - pattern = g_utf8_strdown (normalized_word, -1); + pattern = g_utf8_strdown (normalized_word, len); g_free(normalized_word); } else @@ -1089,9 +1090,9 @@ static EnchantTrieMatcher* enchant_trie_matcher_init(const char* const word, matcher->max_errors = maxerrs; matcher->word = pattern; matcher->word_pos = 0; - matcher->path = g_new0(char,10); + matcher->path = g_new0(char,len+maxerrs+1); matcher->path[0] = '\0'; - matcher->path_len = 10; + matcher->path_len = len+maxerrs+1; matcher->path_pos = 0; matcher->mode = mode; matcher->cbfunc = cbfunc; @@ -1189,3 +1190,4 @@ static int edit_dist(const char* utf8word1, const char* utf8word2) } + -- cgit v1.2.1