isl_basic_set_opt: avoid invalid access on error path
[platform/upstream/isl.git] / isl_list.c
index db2a608..bb926b7 100644 (file)
@@ -1,62 +1,49 @@
 /*
  * Copyright 2008-2009 Katholieke Universiteit Leuven
  *
- * Use of this software is governed by the GNU LGPLv2.1 license
+ * Use of this software is governed by the MIT license
  *
  * Written by Sven Verdoolaege, K.U.Leuven, Departement
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
  */
 
-#include <isl/list.h>
+#include <isl_list_private.h>
+#include <isl/constraint.h>
 #include <isl/set.h>
+#include <isl/aff.h>
+#include <isl/band.h>
 
-struct isl_basic_set_list *isl_basic_set_list_alloc(struct isl_ctx *ctx, int n)
-{
-       struct isl_basic_set_list *list;
-
-       isl_assert(ctx, n >= 0, return NULL);
-       list = isl_alloc(ctx, struct isl_basic_set_list,
-                        sizeof(struct isl_basic_set_list) +
-                        (n - 1) * sizeof(struct isl_basic_set *));
-       if (!list)
-               return NULL;
-
-       list->ctx = ctx;
-       isl_ctx_ref(ctx);
-       list->ref = 1;
-       list->size = n;
-       list->n = 0;
-       return list;
-}
-
-struct isl_basic_set_list *isl_basic_set_list_add(
-       struct isl_basic_set_list *list,
-       struct isl_basic_set *bset)
-{
-       if (!list || !bset)
-               goto error;
-       isl_assert(list->ctx, list->n < list->size, goto error);
-       list->p[list->n] = bset;
-       list->n++;
-       return list;
-error:
-       isl_basic_set_free(bset);
-       isl_basic_set_list_free(list);
-       return NULL;
-}
-
-void isl_basic_set_list_free(struct isl_basic_set_list *list)
-{
-       int i;
-
-       if (!list)
-               return;
-
-       if (--list->ref > 0)
-               return;
-
-       isl_ctx_deref(list->ctx);
-       for (i = 0; i < list->n; ++i)
-               isl_basic_set_free(list->p[i]);
-       free(list);
-}
+#undef BASE
+#define BASE constraint
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE basic_set
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE set
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE aff
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE pw_aff
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE band
+
+#include <isl_list_templ.c>
+
+#undef BASE
+#define BASE id
+
+#include <isl_list_templ.c>