diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-05-31 13:18:43 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-05-31 13:18:43 +0000 |
commit | 1e3e062b2434d728c518cc1e0f8ef1c7e6f49e9f (patch) | |
tree | 1e4706f229a3d7439972a7b6ff40ff166c7e30da /src/fe-common/core/hilight-text.c | |
parent | 278dfd7f76860a9a7f2b51e658a1869e23caf7d2 (diff) | |
download | irssi-1e3e062b2434d728c518cc1e0f8ef1c7e6f49e9f.zip |
Simplify, append directly to GString rather than allocating a
temporary string.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4854 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/hilight-text.c')
-rw-r--r-- | src/fe-common/core/hilight-text.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 1f3bb4ce..3b8f39ef 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -353,7 +353,7 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text, } else { /* hilight part of the line */ GString *tmp; - char *middle, *lastcolor; + char *middle; int pos, color_pos, color_len; tmp = g_string_new(NULL); @@ -377,16 +377,13 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text, pos = strip_real_length(text, hilight_end, &color_pos, &color_len); if (color_pos > 0) - lastcolor = g_strndup(text+color_pos, color_len); + g_string_append_len(tmp, text+color_pos, color_len); else { /* no colors in line, change back to default */ - lastcolor = g_malloc0(3); - lastcolor[0] = 4; - lastcolor[1] = FORMAT_STYLE_DEFAULTS; + g_string_append_c(tmp, 4); + g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS); } - g_string_append(tmp, lastcolor); g_string_append(tmp, text+pos); - g_free(lastcolor); newstr = tmp->str; g_string_free(tmp, FALSE); |