summaryrefslogtreecommitdiff
path: root/src/gui/gui-line.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui-line.c')
-rw-r--r--src/gui/gui-line.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c
index a283312e0..760a72b9c 100644
--- a/src/gui/gui-line.c
+++ b/src/gui/gui-line.c
@@ -87,6 +87,40 @@ gui_lines_free (struct t_gui_lines *lines)
}
/*
+ * Allocates array with tags in a line_data.
+ */
+
+void
+gui_line_tags_alloc (struct t_gui_line_data *line_data, const char *tags)
+{
+ if (tags)
+ {
+ line_data->tags_array = string_split_shared (tags, ",", 0, 0,
+ &line_data->tags_count);
+ }
+ else
+ {
+ line_data->tags_count = 0;
+ line_data->tags_array = NULL;
+ }
+}
+
+/*
+ * Frees array with tags in a line_data.
+ */
+
+void
+gui_line_tags_free (struct t_gui_line_data *line_data)
+{
+ if (line_data->tags_array)
+ {
+ string_free_split_shared (line_data->tags_array);
+ line_data->tags_count = 0;
+ line_data->tags_array = NULL;
+ }
+}
+
+/*
* Checks if prefix on line is a nick and is the same as nick on previous line.
*
* Returns:
@@ -838,8 +872,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
{
if (line->data->str_time)
free (line->data->str_time);
- if (line->data->tags_array)
- string_free_split (line->data->tags_array);
+ gui_line_tags_free (line->data);
if (line->data->prefix)
free (line->data->prefix);
if (line->data->message)
@@ -1057,16 +1090,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
new_line->data->date = date;
new_line->data->date_printed = date_printed;
new_line->data->str_time = gui_chat_get_time_string (date);
- if (tags)
- {
- new_line->data->tags_array = string_split (tags, ",", 0, 0,
- &new_line->data->tags_count);
- }
- else
- {
- new_line->data->tags_count = 0;
- new_line->data->tags_array = NULL;
- }
+ gui_line_tags_alloc (new_line->data, tags);
new_line->data->refresh_needed = 0;
new_line->data->prefix = (prefix) ?
strdup (prefix) : ((date != 0) ? strdup ("") : NULL);
@@ -1488,18 +1512,8 @@ gui_line_hdata_line_data_update_cb (void *data,
if (hashtable_has_key (hashtable, "tags_array"))
{
value = hashtable_get (hashtable, "tags_array");
- if (line_data->tags_array)
- string_free_split (line_data->tags_array);
- if (value)
- {
- line_data->tags_array = string_split (value, ",", 0, 0,
- &line_data->tags_count);
- }
- else
- {
- line_data->tags_count = 0;
- line_data->tags_array = NULL;
- }
+ gui_line_tags_free (line_data);
+ gui_line_tags_alloc (line_data, value);
rc++;
}