summaryrefslogtreecommitdiff
path: root/isl_mat.c
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2009-08-02 10:51:34 +0200
committerSven Verdoolaege <skimo@kotnet.org>2009-08-07 11:20:34 +0200
commit97dc0a64bcb6b5152dfa6b1cde54348bc8011a18 (patch)
treefb0d158a3bd602d3ee9d5d5f683aaee00f7aa437 /isl_mat.c
parentd91a2fefa628c00f34416d18fbc1aa2271d5929a (diff)
downloadisl-97dc0a64bcb6b5152dfa6b1cde54348bc8011a18.tar.gz
isl-97dc0a64bcb6b5152dfa6b1cde54348bc8011a18.tar.bz2
isl-97dc0a64bcb6b5152dfa6b1cde54348bc8011a18.zip
isl_mat: keep track of the actual number of columns in a row
We need this number to perform extensions after dropping columns.
Diffstat (limited to 'isl_mat.c')
-rw-r--r--isl_mat.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/isl_mat.c b/isl_mat.c
index 5c925aeb..c1ba26e4 100644
--- a/isl_mat.c
+++ b/isl_mat.c
@@ -29,6 +29,7 @@ struct isl_mat *isl_mat_alloc(struct isl_ctx *ctx,
mat->ref = 1;
mat->n_row = n_row;
mat->n_col = n_col;
+ mat->max_col = n_col;
mat->flags = 0;
return mat;
@@ -47,10 +48,13 @@ struct isl_mat *isl_mat_extend(struct isl_mat *mat,
if (!mat)
return NULL;
- if (mat->n_col >= n_col && mat->n_row >= n_row)
+ if (mat->max_col >= n_col && mat->n_row >= n_row) {
+ if (mat->n_col < n_col)
+ mat->n_col = n_col;
return mat;
+ }
- if (mat->n_col < n_col) {
+ if (mat->max_col < n_col) {
struct isl_mat *new_mat;
new_mat = isl_mat_alloc(mat->ctx, n_row, n_col);
@@ -68,7 +72,7 @@ struct isl_mat *isl_mat_extend(struct isl_mat *mat,
assert(mat->ref == 1);
old = mat->block.data;
- mat->block = isl_blk_extend(mat->ctx, mat->block, n_row * mat->n_col);
+ mat->block = isl_blk_extend(mat->ctx, mat->block, n_row * mat->max_col);
if (isl_blk_is_error(mat->block))
goto error;
mat->row = isl_realloc_array(mat->ctx, mat->row, isl_int *, n_row);
@@ -78,8 +82,10 @@ struct isl_mat *isl_mat_extend(struct isl_mat *mat,
for (i = 0; i < mat->n_row; ++i)
mat->row[i] = mat->block.data + (mat->row[i] - old);
for (i = mat->n_row; i < n_row; ++i)
- mat->row[i] = mat->block.data + i * mat->n_col;
+ mat->row[i] = mat->block.data + i * mat->max_col;
mat->n_row = n_row;
+ if (mat->n_col < n_col)
+ mat->n_col = n_col;
return mat;
error: