changeset 2065:391440022697

[gaim-migrate @ 2075] minor one-time leak committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 03 Jul 2001 19:08:48 +0000
parents 1f51e772a05c
children 05df89293018
files src/gtkimhtml.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkimhtml.c	Thu Jun 28 19:53:48 2001 +0000
+++ b/src/gtkimhtml.c	Tue Jul 03 19:08:48 2001 +0000
@@ -1541,12 +1541,19 @@
 get_font_names ()
 {
 	gint num_fonts = 0;
-	gchar **xfontnames = XListFonts (GDK_DISPLAY (), "-*", MAX_FONTS, &num_fonts);
-	gchar **fonts = NULL;
+	gchar **xfontnames;
+	static gchar **fonts = NULL;
 	gint i;
 
-	if (!num_fonts)
+	if (fonts)
+		return fonts;
+
+	xfontnames = XListFonts (GDK_DISPLAY (), "-*", MAX_FONTS, &num_fonts);
+
+	if (!num_fonts) {
+		XFreeFontNames(xfontnames);
 		return g_new0 (char *, 1);
+	}
 
 	fonts = g_new0 (char *, num_fonts + 1);
 
@@ -1566,6 +1573,7 @@
 		fonts [i] = g_strndup (t1, (long) t2 - (long) t1);
 	}
 
+	XFreeFontNames(xfontnames);
 	return fonts;
 }