add isl_aff_mod_val
[platform/upstream/isl.git] / isl_space.c
index eaad1a6..499dd1a 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <isl_space_private.h>
 #include <isl_id_private.h>
 #include <isl_reordering.h>
@@ -292,6 +293,8 @@ __isl_take isl_space *isl_space_dup(__isl_keep isl_space *dim)
        if (!dim)
                return NULL;
        dup = isl_space_alloc(dim->ctx, dim->nparam, dim->n_in, dim->n_out);
+       if (!dup)
+               return NULL;
        if (dim->tuple_id[0] &&
            !(dup->tuple_id[0] = isl_id_copy(dim->tuple_id[0])))
                goto error;
@@ -781,6 +784,8 @@ __isl_give isl_space *isl_space_extend(__isl_take isl_space *dim,
        isl_assert(dim->ctx, dim->n_out <= n_out, goto error);
 
        dim = isl_space_cow(dim);
+       if (!dim)
+               goto error;
 
        if (dim->ids) {
                ids = isl_calloc_array(dim->ctx, isl_id *,
@@ -1545,9 +1550,9 @@ static uint32_t isl_hash_dim(uint32_t hash, __isl_keep isl_space *dim)
        if (!dim)
                return hash;
 
-       hash = isl_hash_builtin(hash, dim->nparam);
-       hash = isl_hash_builtin(hash, dim->n_in);
-       hash = isl_hash_builtin(hash, dim->n_out);
+       isl_hash_byte(hash, dim->nparam % 256);
+       isl_hash_byte(hash, dim->n_in % 256);
+       isl_hash_byte(hash, dim->n_out % 256);
 
        for (i = 0; i < dim->nparam; ++i) {
                id = get_id(dim, isl_dim_param, i);