summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-01-28 07:03:44 +0100
committerSébastien Helleu <flashcode@flashtux.org>2022-01-28 07:03:44 +0100
commita62f8f6f75279396e218204a6ee8d58bd0b6995b (patch)
tree59867e807243a58146962c6d64f7401a7bceaf1a /src
parent05eb89777162378f7f772538bcf5d7c86c69f2eb (diff)
downloadweechat-a62f8f6f75279396e218204a6ee8d58bd0b6995b.zip
core: use dynamic string in function gui_chat_build_string_prefix_message
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui-chat.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index e8838b72c..9cecf6121 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -588,39 +588,23 @@ gui_chat_change_time_format ()
char *
gui_chat_build_string_prefix_message (struct t_gui_line *line)
{
- char *string, *string_without_colors;
- int length;
+ char **string, *string_without_colors;
+
+ string = string_dyn_alloc (256);
+ if (!string)
+ return NULL;
- length = 0;
if (line->data->prefix)
- length += strlen (line->data->prefix);
- length++;
+ string_dyn_concat (string, line->data->prefix, -1);
+ string_dyn_concat (string, "\t", -1);
if (line->data->message)
- length += strlen (line->data->message);
- length++;
+ string_dyn_concat (string, line->data->message, -1);
- string = malloc (length);
- if (string)
- {
- string[0] = '\0';
- if (line->data->prefix)
- strcat (string, line->data->prefix);
- strcat (string, "\t");
- if (line->data->message)
- strcat (string, line->data->message);
- }
+ string_without_colors = gui_color_decode (*string, NULL);
- if (string)
- {
- string_without_colors = gui_color_decode (string, NULL);
- if (string_without_colors)
- {
- free (string);
- string = string_without_colors;
- }
- }
+ string_dyn_free (string, 1);
- return string;
+ return string_without_colors;
}
/*