summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Albright <eric_albright@sil.org>2007-12-21 03:53:02 +0000
committerEric Albright <eric_albright@sil.org>2007-12-21 03:53:02 +0000
commitf4f1480e2b4101ab44ae39c57e314d94fb1aa221 (patch)
treeeb437927bf223b7561c391283a9502d177330c78
parent2ab92e740131866a07fa0faf79741f88e99ce5ab (diff)
downloadenchant-f4f1480e2b4101ab44ae39c57e314d94fb1aa221.tar.gz
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
-rw-r--r--src/pwl.c8
1 files 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)
}
+