# HG changeset patch # User Daniel Atallah # Date 1170171955 0 # Node ID 2399c5295a1432c1e7e9ea29dffef066ac5c2334 # Parent bb3bf2f88406908913f7077f89c29f05d4b8aa0a Avoid allocating and freeing the color string excessively. diff -r bb3bf2f88406 -r 2399c5295a14 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Tue Jan 30 15:43:16 2007 +0000 +++ b/pidgin/gtkconv.c Tue Jan 30 15:45:55 2007 +0000 @@ -260,7 +260,7 @@ if (conv->features & GAIM_CONNECTION_HTML) { - char *color; + char color[8]; GdkColor fg_color, bg_color; if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) @@ -281,42 +281,35 @@ /* 3 is the default. */ if (size != 3) - { gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), size); - } } if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) { gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), &fg_color); - color = g_strdup_printf("#%02x%02x%02x", + g_snprintf(color, sizeof(color), "#%02x%02x%02x", fg_color.red / 256, fg_color.green / 256, fg_color.blue / 256); - } - else - color = g_strdup(""); + } else + strcpy(color, ""); gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); - g_free(color); if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) { gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), &bg_color); - color = g_strdup_printf("#%02x%02x%02x", + g_snprintf(color, sizeof(color), "#%02x%02x%02x", bg_color.red / 256, bg_color.green / 256, bg_color.blue / 256); - } - else - color = g_strdup(""); + } else + strcpy(color, ""); gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); - g_free(color); - if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE);