From 6da22af993502fb6323c31000c38b334e38a10e9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 1 Apr 2006 20:06:15 +0000 Subject: [PATCH] Use a GString instead of static buffer to reduce .bss by 8kb. (#336784) 2006-04-01 Behdad Esfahbod * gtk/gtkfilesel.c (gtk_file_selection_get_filename): Use a GString instead of static buffer to reduce .bss by 8kb. (#336784) --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ gtk/gtkfilesel.c | 10 +++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b07962d15..4a118a3a8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-04-01 Behdad Esfahbod + + * gtk/gtkfilesel.c (gtk_file_selection_get_filename): Use a GString + instead of static buffer to reduce .bss by 8kb. (#336784) + 2006-04-01 Dom Lachowicz * modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2b07962d15..4a118a3a8c 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2006-04-01 Behdad Esfahbod + + * gtk/gtkfilesel.c (gtk_file_selection_get_filename): Use a GString + instead of static buffer to reduce .bss by 8kb. (#336784) + 2006-04-01 Dom Lachowicz * modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c index 0d7325d1b2..a7e6e18125 100644 --- a/gtk/gtkfilesel.c +++ b/gtk/gtkfilesel.c @@ -1243,7 +1243,7 @@ G_CONST_RETURN gchar* gtk_file_selection_get_filename (GtkFileSelection *filesel) { static const gchar nothing[2] = ""; - static gchar something[MAXPATHLEN*2+1]; + static GString *something; char *sys_filename; const char *text; @@ -1260,10 +1260,14 @@ gtk_file_selection_get_filename (GtkFileSelection *filesel) g_free (fullname); if (!sys_filename) return nothing; + if (!something) + something = g_string_new (sys_filename); + else + g_string_assign (something, sys_filename); strncpy (something, sys_filename, sizeof (something) - 1); - something[sizeof (something) - 1] = '\0'; g_free (sys_filename); - return something; + + return something->str; } return nothing;