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

index f5cfabf..d500627 100644 (file)
@@ -2261,6 +2261,8 @@ Here we take lists of C<isl_set>s as an example.
 Lists can be created, copied and freed using the following functions.
 
        #include <isl/list.h>
+       __isl_give isl_set_list *isl_set_list_from_set(
+               __isl_take struct isl_set *el);
        __isl_give isl_set_list *isl_set_list_alloc(
                isl_ctx *ctx, int n);
        __isl_give isl_set_list *isl_set_list_copy(
@@ -2271,7 +2273,8 @@ Lists can be created, copied and freed using the following functions.
        void *isl_set_list_free(__isl_take isl_set_list *list);
 
 C<isl_set_list_alloc> creates an empty list with a capacity for
-C<n> elements.
+C<n> elements.  C<isl_set_list_from_set> creates a list with a single
+element.
 
 Lists can be inspected using the following functions.
 
index 765d016..7275de5 100644 (file)
@@ -22,6 +22,8 @@ struct isl_##EL;                                                      \
 struct isl_##EL##_list;                                                        \
 typedef struct isl_##EL##_list isl_##EL##_list;                                \
 isl_ctx *isl_##EL##_list_get_ctx(__isl_keep isl_##EL##_list *list);    \
+__isl_give isl_##EL##_list *isl_##EL##_list_from_##EL(                 \
+       __isl_take struct isl_##EL *el);                                \
 __isl_give isl_##EL##_list *isl_##EL##_list_alloc(isl_ctx *ctx, int n);        \
 __isl_give isl_##EL##_list *isl_##EL##_list_copy(                      \
        __isl_keep isl_##EL##_list *list);                              \
index 00f993d..7eb50af 100644 (file)
@@ -137,6 +137,24 @@ int FN(LIST(EL),foreach)(__isl_keep LIST(EL) *list,
        return 0;
 }
 
+__isl_give LIST(EL) *FN(FN(LIST(EL),from),BASE)(__isl_take EL *el)
+{
+       isl_ctx *ctx;
+       LIST(EL) *list;
+
+       if (!el)
+               return NULL;
+       ctx = FN(EL,get_ctx)(el);
+       list = FN(LIST(EL),alloc)(ctx, 1);
+       if (!list)
+               goto error;
+       list = FN(LIST(EL),add)(list, el);
+       return list;
+error:
+       FN(EL,free)(el);
+       return NULL;
+}
+
 __isl_give isl_printer *CAT(isl_printer_print_,LIST(BASE))(
        __isl_take isl_printer *p, __isl_keep LIST(EL) *list)
 {