isl_polynomial.c: use flex array member to avoid array out of bounds warning
[platform/upstream/isl.git] / isl_map_subtract.c
index bde4c44..0510657 100644 (file)
@@ -7,10 +7,10 @@
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
  */
 
+#include <isl_map_private.h>
 #include <isl/seq.h>
 #include <isl/set.h>
 #include <isl/map.h>
-#include "isl_map_private.h"
 #include "isl_tab.h"
 #include <isl_point_private.h>
 
@@ -249,7 +249,7 @@ struct isl_diff_collector {
  * a negative value is treated as an error, but the calling
  * function can interpret the results based on the state of dc.
  *
- * Assumes that both bmap and map have known divs.
+ * Assumes that map has known divs.
  *
  * The difference is computed by a backtracking algorithm.
  * Each level corresponds to a basic map in "map".
@@ -560,7 +560,7 @@ static int basic_map_diff_is_empty(__isl_keep isl_basic_map *bmap,
        int r;
        struct isl_is_empty_diff_collector edc;
 
-       r = isl_basic_map_fast_is_empty(bmap);
+       r = isl_basic_map_plain_is_empty(bmap);
        if (r)
                return r;
 
@@ -596,7 +596,7 @@ static int map_diff_is_empty(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
 
 /* Return 1 if "bmap" contains a single element.
  */
-int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap)
+int isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
 {
        if (!bmap)
                return -1;
@@ -609,14 +609,14 @@ int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap)
 
 /* Return 1 if "map" contains a single element.
  */
-int isl_map_is_singleton(__isl_keep isl_map *map)
+int isl_map_plain_is_singleton(__isl_keep isl_map *map)
 {
        if (!map)
                return -1;
        if (map->n != 1)
                return 0;
 
-       return isl_basic_map_is_singleton(map->p[0]);
+       return isl_basic_map_plain_is_singleton(map->p[0]);
 }
 
 /* Given a singleton basic map, extract the single element
@@ -625,7 +625,7 @@ int isl_map_is_singleton(__isl_keep isl_map *map)
 static __isl_give isl_point *singleton_extract_point(
        __isl_keep isl_basic_map *bmap)
 {
-       int i, j;
+       int j;
        unsigned dim;
        struct isl_vec *point;
        isl_int m;
@@ -643,7 +643,6 @@ static __isl_give isl_point *singleton_extract_point(
 
        isl_int_set_si(point->el[0], 1);
        for (j = 0; j < bmap->n_eq; ++j) {
-               int s;
                int i = dim - 1 - j;
                isl_assert(bmap->ctx,
                    isl_seq_first_non_zero(bmap->eq[j] + 1, i) == -1,
@@ -675,6 +674,7 @@ error:
 
 /* Return 1 is the singleton map "map1" is a subset of "map2",
  * i.e., if the single element of "map1" is also an element of "map2".
+ * Assumes "map2" has known divs.
  */
 static int map_is_singleton_subset(__isl_keep isl_map *map1,
        __isl_keep isl_map *map2)
@@ -705,7 +705,6 @@ static int map_is_singleton_subset(__isl_keep isl_map *map1,
 int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2)
 {
        int is_subset = 0;
-       struct isl_map *diff;
 
        if (!map1 || !map2)
                return -1;
@@ -716,19 +715,16 @@ int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2)
        if (isl_map_is_empty(map2))
                return 0;
 
-       if (isl_map_fast_is_universe(map2))
+       if (isl_map_plain_is_universe(map2))
                return 1;
 
-       map1 = isl_map_compute_divs(isl_map_copy(map1));
        map2 = isl_map_compute_divs(isl_map_copy(map2));
-       if (isl_map_is_singleton(map1)) {
+       if (isl_map_plain_is_singleton(map1)) {
                is_subset = map_is_singleton_subset(map1, map2);
-               isl_map_free(map1);
                isl_map_free(map2);
                return is_subset;
        }
        is_subset = map_diff_is_empty(map1, map2);
-       isl_map_free(map1);
        isl_map_free(map2);
 
        return is_subset;