isl_list.c: add missing include
[isl.git] / isl_list.c
blob9151cae3e6ce0c2c7f88eeafea5b3fd73aff47c1
1 #include "isl_list.h"
2 #include "isl_set.h"
4 struct isl_basic_set_list *isl_basic_set_list_alloc(struct isl_ctx *ctx, int n)
6 struct isl_basic_set_list *list;
8 isl_assert(ctx, n >= 0, return NULL);
9 list = isl_alloc(ctx, struct isl_basic_set_list,
10 sizeof(struct isl_basic_set_list) +
11 (n - 1) * sizeof(struct isl_basic_set *));
12 if (!list)
13 return NULL;
15 list->ctx = ctx;
16 isl_ctx_ref(ctx);
17 list->ref = 1;
18 list->size = n;
19 list->n = 0;
20 return list;
23 struct isl_basic_set_list *isl_basic_set_list_add(
24 struct isl_basic_set_list *list,
25 struct isl_basic_set *bset)
27 if (!list || !bset)
28 goto error;
29 isl_assert(list->ctx, list->n < list->size, goto error);
30 list->p[list->n] = bset;
31 list->n++;
32 return list;
33 error:
34 isl_basic_set_free(bset);
35 isl_basic_set_list_free(list);
36 return NULL;
39 void isl_basic_set_list_free(struct isl_basic_set_list *list)
41 int i;
43 if (!list)
44 return;
46 if (--list->ref > 0)
47 return;
49 isl_ctx_deref(list->ctx);
50 for (i = 0; i < list->n; ++i)
51 isl_basic_set_free(list->p[i]);
52 free(list);