2 * Copyright 2008-2009 Katholieke Universiteit Leuven
3 * Copyright 2011 INRIA Saclay
5 * Use of this software is governed by the GNU LGPLv2.1 license
7 * Written by Sven Verdoolaege, K.U.Leuven, Departement
8 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
9 * and INRIA Saclay - Ile-de-France, Parc Club Orsay Universite,
10 * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France
13 #define xCAT(A,B) A ## B
14 #define CAT(A,B) xCAT(A,B)
16 #define EL CAT(isl_,BASE)
17 #define xFN(TYPE,NAME) TYPE ## _ ## NAME
18 #define FN(TYPE,NAME) xFN(TYPE,NAME)
19 #define xLIST(EL) EL ## _list
20 #define LIST(EL) xLIST(EL)
22 __isl_give
LIST(EL
) *FN(LIST(EL
),alloc
)(isl_ctx
*ctx
, int n
)
27 isl_die(ctx
, isl_error_invalid
,
28 "cannot create list of negative length",
30 list
= isl_alloc(ctx
, LIST(EL
),
31 sizeof(LIST(EL
)) + (n
- 1) * sizeof(struct EL
*));
43 __isl_give
LIST(EL
) *FN(LIST(EL
),copy
)(__isl_keep
LIST(EL
) *list
)
52 __isl_give
LIST(EL
) *FN(LIST(EL
),add
)(__isl_take
LIST(EL
) *list
,
53 __isl_take
struct EL
*el
)
57 isl_assert(list
->ctx
, list
->n
< list
->size
, goto error
);
58 list
->p
[list
->n
] = el
;
63 FN(LIST(EL
),free
)(list
);
67 void FN(LIST(EL
),free
)(__isl_take
LIST(EL
) *list
)
77 isl_ctx_deref(list
->ctx
);
78 for (i
= 0; i
< list
->n
; ++i
)
79 FN(EL
,free
)(list
->p
[i
]);