history.c: use g_list_delete_link()

This commit is contained in:
wdlkmpx 2021-01-22 16:27:41 +08:00
parent 073e95a57a
commit 077ac01700
1 changed files with 5 additions and 5 deletions

View File

@ -294,10 +294,11 @@ void history_append (HistoryFile * history, const char * text)
for (i = history->list; i; i = i->next)
{
char * ientry = (char *) (i->data);
if (strcmp (text, ientry) == 0) {
if (strcmp (text, ientry) == 0)
{
// entry already exists.. remove
free (i->data);
templist = g_list_remove (i, i->data);
templist = g_list_delete_link (history->list, i);
if (!templist->prev) { // no previous entry.. new start
history->list = templist;
}
@ -344,9 +345,8 @@ void history_append (HistoryFile * history, const char * text)
if (history->current == history->list) {
history->current = history->list->next;
}
gpointer data = history->list->data;
free (data);
history->list = g_list_remove (history->list, data);
free (history->list->data);
history->list = g_list_delete_link (history->list, history->list);
}
}