Revision: 837 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=837&view=rev Author: frlan Date: 2009-07-18 00:15:19 +0000 (Sat, 18 Jul 2009)
Log Message: ----------- GeanyLaTeX: Rework of previous try to fix memory leak
Modified Paths: -------------- trunk/geanylatex/src/bibtex.c
Modified: trunk/geanylatex/src/bibtex.c =================================================================== --- trunk/geanylatex/src/bibtex.c 2009-07-18 00:11:47 UTC (rev 836) +++ trunk/geanylatex/src/bibtex.c 2009-07-18 00:15:19 UTC (rev 837) @@ -133,10 +133,13 @@ void glatex_bibtex_write_entry(GPtrArray *entry, gint doctype) { gint i; - gchar *output = NULL; + GString *output = NULL; + gchar *tmp = NULL;
/* Adding the doctype to entry */ - output = g_strconcat("@", glatex_label_types[doctype], "{ \n",NULL); + output = g_string_new("@"); + g_string_append(output, glatex_label_types[doctype]); + g_string_append(output, "{ \n");
/* Adding the keywords and values to entry */ for (i = 0; i < GLATEX_BIBTEX_N_ENTRIES; i++) @@ -147,21 +150,23 @@ /* Check whether a field was only set for being used ... */ if (utils_str_equal(g_ptr_array_index (entry, i), "\0")) { - output = g_strconcat(output, - glatex_label_entry_keywords[i], " = {},\n", NULL); + g_string_append(output, glatex_label_entry_keywords[i]); + g_string_append(output," = {},\n"); } /* ... or has some real value inside. */ else { - output = g_strconcat(output, - glatex_label_entry_keywords[i], " = {", g_ptr_array_index(entry, i), - "},\n", NULL); + g_string_append(output, glatex_label_entry_keywords[i]); + g_string_append(output, " = {"); + g_string_append(output, g_ptr_array_index(entry, i)); + g_string_append(output, "},\n"); } } }
- output = g_strconcat(output, "}\n", NULL); - glatex_insert_string(output, FALSE); - + g_string_append(output, "}\n"); + tmp = g_string_free(output, FALSE); + glatex_insert_string(tmp, FALSE); + g_free(tmp); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org