From 97dc0a64bcb6b5152dfa6b1cde54348bc8011a18 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sun, 2 Aug 2009 10:51:34 +0200 Subject: [PATCH] isl_mat: keep track of the actual number of columns in a row We need this number to perform extensions after dropping columns. --- isl_mat.c | 14 ++++++++++---- isl_mat.h | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/isl_mat.c b/isl_mat.c index 5c925ae..c1ba26e 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: diff --git a/isl_mat.h b/isl_mat.h index 3671db1..ed82ec2 100644 --- a/isl_mat.h +++ b/isl_mat.h @@ -26,6 +26,9 @@ struct isl_mat { isl_int **row; + /* actual size of the rows in memory; n_col <= max_col */ + unsigned max_col; + struct isl_blk block; }; -- 2.7.4