isl_basic_set_opt: avoid invalid access on error path
[platform/upstream/isl.git] / isl_seq.c
index dd80c19..42e6b63 100644 (file)
--- a/isl_seq.c
+++ b/isl_seq.c
@@ -1,7 +1,7 @@
 /*
  * 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
@@ -17,6 +17,13 @@ void isl_seq_clr(isl_int *p, unsigned len)
                isl_int_set_si(p[i], 0);
 }
 
+void isl_seq_set_si(isl_int *p, int v, unsigned len)
+{
+       int i;
+       for (i = 0; i < len; ++i)
+               isl_int_set_si(p[i], v);
+}
+
 void isl_seq_set(isl_int *p, isl_int v, unsigned len)
 {
        int i;
@@ -194,6 +201,17 @@ int isl_seq_last_non_zero(isl_int *p, unsigned len)
        return -1;
 }
 
+void isl_seq_abs_max(isl_int *p, unsigned len, isl_int *max)
+{
+       int i;
+
+       isl_int_set_si(*max, 0);
+
+       for (i = 0; i < len; ++i)
+               if (isl_int_abs_gt(p[i], *max))
+                       isl_int_abs(*max, p[i]);
+}
+
 int isl_seq_abs_min_non_zero(isl_int *p, unsigned len)
 {
        int i, min = isl_seq_first_non_zero(p, len);
@@ -289,3 +307,15 @@ uint32_t isl_seq_get_hash_bits(isl_int *p, unsigned len, unsigned bits)
        hash = isl_seq_get_hash(p, len);
        return isl_hash_bits(hash, bits);
 }
+
+void isl_seq_dump(isl_int *p, unsigned len)
+{
+       int i;
+
+       for (i = 0; i < len; ++i) {
+               if (i)
+                       fprintf(stderr, " ");
+               isl_int_print(stderr, p[i], 0);
+       }
+       fprintf(stderr, "\n");
+}