gok r2524 - in trunk: . gok
- From: gerdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gok r2524 - in trunk: . gok
- Date: Thu, 7 Aug 2008 09:22:56 +0000 (UTC)
Author: gerdk
Date: Thu Aug 7 09:22:56 2008
New Revision: 2524
URL: http://svn.gnome.org/viewvc/gok?rev=2524&view=rev
Log:
2008-08-07 Gerd Kohlberger <gerdk svn gnome org>
* gok/gok-utf8-word-complete.c:
(utf8_wordcomplete_write_line): Remove unused return values.
(utf8_wordcomplete_close): Fix crash on g_list_free. Release
additional memory.
Fixes bug #546559
Modified:
trunk/ChangeLog
trunk/gok/gok-utf8-word-complete.c
Modified: trunk/gok/gok-utf8-word-complete.c
==============================================================================
--- trunk/gok/gok-utf8-word-complete.c (original)
+++ trunk/gok/gok-utf8-word-complete.c Thu Aug 7 09:22:56 2008
@@ -69,6 +69,7 @@
static GList *utf8_add_to_list_from_lines (GList *list, gchar **lines, gboolean read_freqs, gboolean in_primary);
static void utf8_wordcomplete_create_unicode_hash (GokUTF8WordComplete *complete);
static void utf8_apply_case (const gchar *word, gchar **predictions);
+static void utf8_word_prediction_free (WordPrediction *prediction);
/*
* This macro initializes GokUtf8WordComplete with the GType system
@@ -174,39 +175,39 @@
utf8_wordcomplete_write_line (gpointer data, gpointer user_data)
{
GIOChannel *io = user_data;
- GError *error = NULL;
- gsize bytes;
WordPrediction *word_info = data;
gchar line[256];
+
snprintf (line, 255, "%s\t%d\t%d\n", word_info->string, word_info->priority, 2);
- g_io_channel_write_chars (io, line, -1, &bytes, &error);
+ g_io_channel_write_chars (io, line, -1, NULL, NULL);
}
static void
utf8_wordcomplete_close (GokWordComplete *complete)
{
GIOChannel *io;
- GError *error = NULL;
- gsize bytes;
+ GList *l;
GokUTF8WordComplete *ucomplete = GOK_UTF8WORDCOMPLETE (complete);
+
/* open for writing */
- io = g_io_channel_new_file (ucomplete->primary_dict_filename, "w", &error);
- /* write the header */
- if (!error)
- g_io_channel_write_chars (io, "WPDictFile\n", -1, &bytes, &error);
- if (!error)
- {
- /* write entries*/
- g_list_foreach (ucomplete->word_list, utf8_wordcomplete_write_line, io);
+ io = g_io_channel_new_file (ucomplete->primary_dict_filename, "w", NULL);
+ if (io) {
+ /* write the header */
+ if (g_io_channel_write_chars (io, "WPDictFile\n", -1,
+ NULL, NULL) == G_IO_STATUS_NORMAL) {
+ /* write entries*/
+ g_list_foreach (ucomplete->word_list,
+ utf8_wordcomplete_write_line, io);
+ }
+ g_io_channel_unref (io);
}
+ for (l = ucomplete->word_list; l; l = l->next)
+ utf8_word_prediction_free (l->data);
+
g_list_free (ucomplete->word_list);
- g_list_free (ucomplete->word_list_end);
- g_list_free (ucomplete->start_search);
- g_list_free (ucomplete->end_search);
g_hash_table_destroy (ucomplete->unicode_start_hash);
g_hash_table_destroy (ucomplete->unicode_end_hash);
g_free (ucomplete->primary_dict_filename);
- g_io_channel_shutdown (io, TRUE, &error);
}
static gchar**
@@ -305,6 +306,15 @@
return prediction;
}
+static void
+utf8_word_prediction_free (WordPrediction *prediction)
+{
+ if (prediction) {
+ g_free (prediction->string);
+ g_free (prediction);
+ }
+}
+
static gboolean
utf8_wordcomplete_add_new_word (GokWordComplete *complete, const gchar *word)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]