X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_list_templ.c;h=9aa4351b5cf09600b18f12928363f0d0ead5c169;hb=56b7d238929980e62218525b4b3be121af386edf;hp=9504e6ed9378ac9869a55d4bbc723e0138c5bae2;hpb=bbf85ab5afe150c925b01e126c438784b015230a;p=platform%2Fupstream%2Fisl.git diff --git a/isl_list_templ.c b/isl_list_templ.c index 9504e6e..9aa4351 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -54,6 +54,22 @@ __isl_give LIST(EL) *FN(LIST(EL),copy)(__isl_keep LIST(EL) *list) return list; } +__isl_give LIST(EL) *FN(LIST(EL),dup)(__isl_keep LIST(EL) *list) +{ + int i; + LIST(EL) *dup; + + if (!list) + return NULL; + + dup = FN(LIST(EL),alloc)(FN(LIST(EL),get_ctx)(list), list->n); + if (!dup) + return NULL; + for (i = 0; i < list->n; ++i) + dup = FN(LIST(EL),add)(dup, FN(EL,copy)(list->p[i])); + return dup; +} + __isl_give LIST(EL) *FN(LIST(EL),add)(__isl_take LIST(EL) *list, __isl_take struct EL *el) { @@ -69,20 +85,22 @@ error: return NULL; } -void FN(LIST(EL),free)(__isl_take LIST(EL) *list) +void *FN(LIST(EL),free)(__isl_take LIST(EL) *list) { int i; if (!list) - return; + return NULL; if (--list->ref > 0) - return; + return NULL; isl_ctx_deref(list->ctx); for (i = 0; i < list->n; ++i) FN(EL,free)(list->p[i]); free(list); + + return NULL; } int FN(FN(LIST(EL),n),BASE)(__isl_keep LIST(EL) *list) @@ -119,6 +137,50 @@ 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 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) {