add isl_*_list_concat
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 25 Jul 2011 06:52:14 +0000 (08:52 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Jul 2011 14:41:23 +0000 (16:41 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/list.h
isl_list_templ.c

index d500627..80c0059 100644 (file)
@@ -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<isl_set_list_alloc> creates an empty list with a capacity for
index 7275de5..3fa6b11 100644 (file)
@@ -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);                   \
index 7eb50af..9aa4351 100644 (file)
@@ -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)
 {