Use a GString instead of static buffer to reduce .bss by 8kb. (#336784)

2006-04-01  Behdad Esfahbod  <behdad@gnome.org>

        * gtk/gtkfilesel.c (gtk_file_selection_get_filename): Use a GString
        instead of static buffer to reduce .bss by 8kb. (#336784)
This commit is contained in:
Behdad Esfahbod 2006-04-01 20:06:15 +00:00 committed by Behdad Esfahbod
parent 68d222c757
commit 6da22af993
3 changed files with 17 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2006-04-01 Behdad Esfahbod <behdad@gnome.org>
* 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 <cinamod@hotmail.com> 2006-04-01 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's * modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's

View File

@ -1,3 +1,8 @@
2006-04-01 Behdad Esfahbod <behdad@gnome.org>
* 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 <cinamod@hotmail.com> 2006-04-01 Dom Lachowicz <cinamod@hotmail.com>
* modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's * modules/engines/ms-windows/msw_style.c (draw_hline): Emulate WinXP's

View File

@ -1243,7 +1243,7 @@ G_CONST_RETURN gchar*
gtk_file_selection_get_filename (GtkFileSelection *filesel) gtk_file_selection_get_filename (GtkFileSelection *filesel)
{ {
static const gchar nothing[2] = ""; static const gchar nothing[2] = "";
static gchar something[MAXPATHLEN*2+1]; static GString *something;
char *sys_filename; char *sys_filename;
const char *text; const char *text;
@ -1260,10 +1260,14 @@ gtk_file_selection_get_filename (GtkFileSelection *filesel)
g_free (fullname); g_free (fullname);
if (!sys_filename) if (!sys_filename)
return nothing; return nothing;
if (!something)
something = g_string_new (sys_filename);
else
g_string_assign (something, sys_filename);
strncpy (something, sys_filename, sizeof (something) - 1); strncpy (something, sys_filename, sizeof (something) - 1);
something[sizeof (something) - 1] = '\0';
g_free (sys_filename); g_free (sys_filename);
return something;
return something->str;
} }
return nothing; return nothing;