Mercurial > pidgin
changeset 15464:2399c5295a14
Avoid allocating and freeing the color string excessively.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 30 Jan 2007 15:45:55 +0000 |
parents | bb3bf2f88406 |
children | cc1721b06dc6 |
files | pidgin/gtkconv.c |
diffstat | 1 files changed, 7 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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);