From fb240915dac74d3360936b44e66f459f9b878b57 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 25 Jul 2011 08:47:27 +0200 Subject: [PATCH] add isl_*_list_from_* Signed-off-by: Sven Verdoolaege --- doc/user.pod | 5 ++++- include/isl/list.h | 2 ++ isl_list_templ.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/user.pod b/doc/user.pod index f5cfabf..d500627 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -2261,6 +2261,8 @@ Here we take lists of Cs as an example. Lists can be created, copied and freed using the following functions. #include + __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 creates an empty list with a capacity for -C elements. +C elements. C creates a list with a single +element. Lists can be inspected using the following functions. diff --git a/include/isl/list.h b/include/isl/list.h index 765d016..7275de5 100644 --- a/include/isl/list.h +++ b/include/isl/list.h @@ -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); \ diff --git a/isl_list_templ.c b/isl_list_templ.c index 00f993d..7eb50af 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -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) { -- 2.7.4