From 75ee44db20dbfa982dfa72412e3e171b45326b2e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 20 Apr 2024 21:29:08 +0300 Subject: [PATCH] Use listbox_add_item_take() in obvious cases. Signed-off-by: Andrew Borodin --- lib/widget/dialog-switch.c | 5 ++--- src/editor/etags.c | 3 +-- src/filemanager/boxes.c | 3 +-- src/filemanager/hotlist.c | 17 +++++------------ 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c index 74aedff0c..8666522dd 100644 --- a/lib/widget/dialog-switch.c +++ b/lib/widget/dialog-switch.c @@ -252,9 +252,8 @@ dialog_switch_list (void) else title = g_strdup (""); - listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h, FALSE); - - g_free (title); + listbox_add_item_take (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h, + FALSE); } selected = listbox_run_with_data (listbox, mc_current); diff --git a/src/editor/etags.c b/src/editor/etags.c index 40ea023b2..cfefd1fc2 100644 --- a/src/editor/etags.c +++ b/src/editor/etags.c @@ -303,9 +303,8 @@ editcmd_dialog_select_definition_add (gpointer data, gpointer user_data) label_def = g_strdup_printf ("%s -> %s:%ld", def_hash->short_define, def_hash->filename, def_hash->line); - listbox_add_item (def_list, LISTBOX_APPEND_AT_END, 0, label_def, def_hash, FALSE); + listbox_add_item_take (def_list, LISTBOX_APPEND_AT_END, 0, label_def, def_hash, FALSE); def_width = str_term_width1 (label_def); - g_free (label_def); def_max_width = MAX (def_max_width, def_width); } diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index 6291ec5f0..8d11e5d1a 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -474,8 +474,7 @@ jobs_fill_listbox (WListbox * list) char *s; s = g_strconcat (state_str[tl->state], " ", tl->info, (char *) NULL); - listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE); - g_free (s); + listbox_add_item_take (list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl, FALSE); } } diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index 68406e4b9..312db4624 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -271,20 +271,16 @@ static void fill_listbox (WListbox * list) { struct hotlist *current; - GString *buff; - - buff = g_string_new (""); for (current = current_group->head; current != NULL; current = current->next) switch (current->type) { case HL_TYPE_GROUP: { - /* buff clean up */ - g_string_truncate (buff, 0); - g_string_append (buff, "->"); - g_string_append (buff, current->label); - listbox_add_item (list, LISTBOX_APPEND_AT_END, 0, buff->str, current, FALSE); + char *lbl; + + lbl = g_strconcat ("->", current->label, (char *) NULL); + listbox_add_item_take (list, LISTBOX_APPEND_AT_END, 0, lbl, current, FALSE); } break; case HL_TYPE_DOTDOT: @@ -294,8 +290,6 @@ fill_listbox (WListbox * list) default: break; } - - g_string_free (buff, TRUE); } /* --------------------------------------------------------------------------------------------- */ @@ -988,8 +982,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, listbox_append char *lbl; lbl = g_strconcat ("->", new->label, (char *) NULL); - listbox_add_item (l_hotlist, pos, 0, lbl, new, FALSE); - g_free (lbl); + listbox_add_item_take (l_hotlist, pos, 0, lbl, new, FALSE); } else listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE);