From 78168765d3d7e49ef96f35eef7b4cb07015e6198 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 25 Jul 2011 08:52:14 +0200 Subject: [PATCH] add isl_*_list_concat Signed-off-by: Sven Verdoolaege --- doc/user.pod | 3 +++ include/isl/list.h | 3 +++ isl_list_templ.c | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index d500627..80c0059 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2270,6 +2270,9 @@ Lists can be created, copied and freed using the following functions. __isl_give isl_set_list *isl_set_list_add( __isl_take isl_set_list *list, __isl_take isl_set *el); + __isl_give isl_set_list *isl_set_list_concat( + __isl_take isl_set_list *list1, + __isl_take isl_set_list *list2); void *isl_set_list_free(__isl_take isl_set_list *list); C creates an empty list with a capacity for diff --git a/include/isl/list.h b/include/isl/list.h index 7275de5..3fa6b11 100644 --- a/include/isl/list.h +++ b/include/isl/list.h @@ -31,6 +31,9 @@ void *isl_##EL##_list_free(__isl_take isl_##EL##_list *list); \ __isl_give isl_##EL##_list *isl_##EL##_list_add( \ __isl_take isl_##EL##_list *list, \ __isl_take struct isl_##EL *el); \ +__isl_give isl_##EL##_list *isl_##EL##_list_concat( \ + __isl_take isl_##EL##_list *list1, \ + __isl_take isl_##EL##_list *list2); \ int isl_##EL##_list_n_##EL(__isl_keep isl_##EL##_list *list); \ __isl_give struct isl_##EL *isl_##EL##_list_get_##EL( \ __isl_keep isl_##EL##_list *list, int index); \ diff --git a/isl_list_templ.c b/isl_list_templ.c index 7eb50af..9aa4351 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -155,6 +155,32 @@ error: return NULL; } +__isl_give LIST(EL) *FN(LIST(EL),concat)(__isl_take LIST(EL) *list1, + __isl_take LIST(EL) *list2) +{ + int i; + isl_ctx *ctx; + LIST(EL) *res; + + if (!list1 || !list2) + goto error; + + ctx = FN(LIST(EL),get_ctx)(list1); + res = FN(LIST(EL),alloc)(ctx, list1->n + list2->n); + for (i = 0; i < list1->n; ++i) + res = FN(LIST(EL),add)(res, FN(EL,copy)(list1->p[i])); + for (i = 0; i < list2->n; ++i) + res = FN(LIST(EL),add)(res, FN(EL,copy)(list2->p[i])); + + FN(LIST(EL),free)(list1); + FN(LIST(EL),free)(list2); + return res; +error: + FN(LIST(EL),free)(list1); + FN(LIST(EL),free)(list2); + return NULL; +} + __isl_give isl_printer *CAT(isl_printer_print_,LIST(BASE))( __isl_take isl_printer *p, __isl_keep LIST(EL) *list) { -- 2.7.4