From dc2f5b1a42742e40a1e5f9dfc6ecb63997e6cd09 Mon Sep 17 00:00:00 2001 From: kramm Date: Tue, 6 Jan 2009 21:38:00 +0000 Subject: [PATCH] new function list_concat --- lib/q.c | 14 ++++++++++++++ lib/q.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lib/q.c b/lib/q.c index 8c67d06..3b9a62f 100644 --- a/lib/q.c +++ b/lib/q.c @@ -1122,6 +1122,20 @@ int list_length_(void*_list) return 0; return l->info[0].size; } +void list_concat_(void*_l1, void*_l2) +{ + commonlist_t**l1 = (commonlist_t**)_l1; + commonlist_t**l2 = (commonlist_t**)_l2; + + if(!*l1) { + *l1 = *l2; + } else if(*l2) { + (*l1)->info[0].last->next = *l2; + (*l1)->info[0].last = (*l2)->info[0].last; + (*l1)->info[0].size += (*l2)->info[0].size; + } + *l2 = 0; +} void list_append_(void*_list, void*entry) { commonlist_t**list = (commonlist_t**)_list; diff --git a/lib/q.h b/lib/q.h index 173b2d6..6eec83c 100644 --- a/lib/q.h +++ b/lib/q.h @@ -223,8 +223,10 @@ void*list_clone_(void*_list); void list_append_(void*_list, void*entry); void list_prepend_(void*_list, void*entry); void list_free_(void*_list); +void list_concat_(void*l1, void*l2); #define list_new() ((void*)0) #define list_append(list, e) {sizeof((list)->next);list_append_(&(list),(e));} +#define list_concat(l1, l2) {sizeof((l1)->next);sizeof((l2)->next);list_concat_(&(l1),&(l2));} #define list_prepend(list, e) {sizeof((list)->next);list_prepend_(&(list),(e));} #define list_free(list) {sizeof((list)->next);list_free_(&(list));} #define list_clone(list) (sizeof((list)->next),list_clone_(&(list))) -- 1.7.10.4