From bbfb770c73498413055c7af8d3e1b8db36560016 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 31 Aug 2020 02:26:47 +0200 Subject: linked_list: linked_list_take should concat lists --- common/linked_list.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/linked_list.c b/common/linked_list.c index 3d2ee7d..7383de0 100644 --- a/common/linked_list.c +++ b/common/linked_list.c @@ -35,14 +35,12 @@ bool linked_list_empty(struct linked_list *list) { void linked_list_take(struct linked_list *target, struct linked_list *source) { if (linked_list_empty(source)) { - linked_list_init(target); return; } + source->next->prev = target; + source->prev->next = target->next; + target->next->prev = source->prev; target->next = source->next; - target->prev = source->prev; - target->next->prev = target; - target->prev->next = target; - linked_list_init(source); } -- cgit v1.2.3