From: Sven Verdoolaege Date: Sun, 2 Aug 2009 08:51:34 +0000 (+0200) Subject: isl_mat: keep track of the actual number of columns in a row X-Git-Tag: isl-0.01~109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97dc0a64bcb6b5152dfa6b1cde54348bc8011a18;hp=d91a2fefa628c00f34416d18fbc1aa2271d5929a;p=platform%2Fupstream%2Fisl.git isl_mat: keep track of the actual number of columns in a row We need this number to perform extensions after dropping columns. --- 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; };