From: Daiki Ueno Date: Sun, 6 Jan 2013 03:50:27 +0000 (+0900) Subject: Don't use float-derived integer SHORT_MSG_MAX to define array. X-Git-Tag: v0.18.3~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b90c26c8641b043d87af92e563da31a63858572;p=thirdparty%2Fgettext.git Don't use float-derived integer SHORT_MSG_MAX to define array. --- diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 2faff73ad..fc37e3fc6 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2013-01-06 Daiki Ueno + + * msgl-fsearch.c (message_fuzzy_index_ty): Don't use float-derived + integer SHORT_MSG_MAX to define array. + (message_fuzzy_index_alloc): Allocate memory for 'short_messages' + field dynamically. + (message_fuzzy_index_free): Free it. + 2013-01-03 Daiki Ueno * xgettext.c (construct_header): Fix memory leak. diff --git a/gettext-tools/src/msgl-fsearch.c b/gettext-tools/src/msgl-fsearch.c index 4cacf398c..d2aa8656b 100644 --- a/gettext-tools/src/msgl-fsearch.c +++ b/gettext-tools/src/msgl-fsearch.c @@ -197,7 +197,7 @@ struct message_fuzzy_index_ty character_iterator_t iterator; hash_table gram4; size_t firstfew; - message_list_ty *short_messages[SHORT_MSG_MAX + 1]; + message_list_ty **short_messages; }; /* Allocate a fuzzy index corresponding to a given list of messages. @@ -304,6 +304,7 @@ message_fuzzy_index_alloc (const message_list_ty *mlp, findex->firstfew = 10; /* Setup lists of short messages. */ + findex->short_messages = XNMALLOC (SHORT_MSG_MAX + 1, message_list_ty *); for (l = 0; l <= SHORT_MSG_MAX; l++) findex->short_messages[l] = message_list_alloc (false); for (j = 0; j < count; j++) @@ -654,6 +655,7 @@ message_fuzzy_index_free (message_fuzzy_index_ty *findex) /* Free the short lists. */ for (l = 0; l <= SHORT_MSG_MAX; l++) message_list_free (findex->short_messages[l], 1); + free (findex->short_messages); /* Free the index lists occurring as values in the hash tables. */ iter = NULL;