From 3dd551186a6f18654214338a83d141c80885ddf6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 25 Jun 2010 18:56:12 +0200 Subject: [PATCH] isl_tab_add_eq: return int instead of isl_tab * --- basis_reduction_tab.c | 6 ++++-- isl_affine_hull.c | 6 +++--- isl_coalesce.c | 3 ++- isl_tab.c | 42 ++++++++++++++++++++---------------------- isl_tab.h | 2 +- isl_tab_pip.c | 6 ++++-- isl_vertices.c | 7 ++----- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/basis_reduction_tab.c b/basis_reduction_tab.c index 4ac27e23..11c43add 100644 --- a/basis_reduction_tab.c +++ b/basis_reduction_tab.c @@ -179,11 +179,13 @@ static int cut_lp_to_hyperplane(struct tab_lp *lp, isl_int *row) return -1; isl_int_neg(lp->row->el[0], lp->tmp); - lp->tab = isl_tab_add_eq(lp->tab, lp->row->el); + if (isl_tab_add_eq(lp->tab, lp->row->el) < 0) + return -1; isl_seq_cpy(lp->row->el + 1 + lp->dim, row, lp->dim); isl_seq_clr(lp->row->el + 1, lp->dim); - lp->tab = isl_tab_add_eq(lp->tab, lp->row->el); + if (isl_tab_add_eq(lp->tab, lp->row->el) < 0) + return -1; lp->con_offset += 2; diff --git a/isl_affine_hull.c b/isl_affine_hull.c index c92b9528..13c818a7 100644 --- a/isl_affine_hull.c +++ b/isl_affine_hull.c @@ -388,8 +388,7 @@ static struct isl_basic_set *extend_affine_hull(struct isl_tab *tab, break; isl_vec_free(sample); - tab = isl_tab_add_eq(tab, hull->eq[j]); - if (!tab) + if (isl_tab_add_eq(tab, hull->eq[j]) < 0) goto error; } if (j == hull->n_eq) @@ -630,7 +629,8 @@ struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab, if (hull->n_eq > tab->n_zero) { for (j = 0; j < hull->n_eq; ++j) { isl_seq_normalize(tab->mat->ctx, hull->eq[j], 1 + tab->n_var); - tab = isl_tab_add_eq(tab, hull->eq[j]); + if (isl_tab_add_eq(tab, hull->eq[j]) < 0) + goto error; } } diff --git a/isl_coalesce.c b/isl_coalesce.c index 8f953df1..84a5a4b0 100644 --- a/isl_coalesce.c +++ b/isl_coalesce.c @@ -722,7 +722,8 @@ static int wrap_in_facets(struct isl_map *map, int i, int j, isl_seq_cpy(bound->el, map->p[i]->ineq[cuts[k]], 1 + total); isl_int_add_ui(bound->el[0], bound->el[0], 1); - tabs[j] = isl_tab_add_eq(tabs[j], bound->el); + if (isl_tab_add_eq(tabs[j], bound->el) < 0) + goto error; if (isl_tab_detect_redundant(tabs[j]) < 0) goto error; diff --git a/isl_tab.c b/isl_tab.c index 4affdaff..5ea612cf 100644 --- a/isl_tab.c +++ b/isl_tab.c @@ -1882,7 +1882,7 @@ static int add_zero_row(struct isl_tab *tab) /* Add equality "eq" and check if it conflicts with the * previously added constraints or if it is obviously redundant. */ -struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) +int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) { struct isl_tab_undo *snap = NULL; struct isl_tab_var *var; @@ -1892,8 +1892,8 @@ struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) isl_int cst; if (!tab) - return NULL; - isl_assert(tab->mat->ctx, !tab->M, goto error); + return -1; + isl_assert(tab->mat->ctx, !tab->M, return -1); if (tab->need_undo) snap = isl_tab_snap(tab); @@ -1908,32 +1908,32 @@ struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) isl_int_clear(cst); } if (r < 0) - goto error; + return -1; var = &tab->con[r]; row = var->index; if (row_is_manifestly_zero(tab, row)) { if (snap) { if (isl_tab_rollback(tab, snap) < 0) - goto error; + return -1; } else drop_row(tab, row); - return tab; + return 0; } if (tab->bmap) { tab->bmap = isl_basic_map_add_ineq(tab->bmap, eq); if (isl_tab_push(tab, isl_tab_undo_bmap_ineq) < 0) - goto error; + return -1; isl_seq_neg(eq, eq, 1 + tab->n_var); tab->bmap = isl_basic_map_add_ineq(tab->bmap, eq); isl_seq_neg(eq, eq, 1 + tab->n_var); if (isl_tab_push(tab, isl_tab_undo_bmap_ineq) < 0) - goto error; + return -1; if (!tab->bmap) - goto error; + return -1; if (add_zero_row(tab) < 0) - goto error; + return -1; } sgn = isl_int_sgn(tab->mat->row[row][1]); @@ -1948,25 +1948,22 @@ struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) if (sgn < 0) { sgn = sign_of_max(tab, var); if (sgn < -1) - goto error; + return -1; if (sgn < 0) { if (isl_tab_mark_empty(tab) < 0) - goto error; - return tab; + return -1; + return 0; } } var->is_nonneg = 1; if (to_col(tab, var) < 0) - goto error; + return -1; var->is_nonneg = 0; if (isl_tab_kill_col(tab, var->index) < 0) - goto error; + return -1; - return tab; -error: - isl_tab_free(tab); - return NULL; + return 0; } /* Construct and return an inequality that expresses an upper bound @@ -2177,9 +2174,10 @@ struct isl_tab *isl_tab_from_recession_cone(__isl_keep isl_basic_set *bset, isl_int_init(cst); for (i = 0; i < bset->n_eq; ++i) { isl_int_swap(bset->eq[i][offset], cst); - if (offset > 0) - tab = isl_tab_add_eq(tab, bset->eq[i] + offset); - else + if (offset > 0) { + if (isl_tab_add_eq(tab, bset->eq[i] + offset) < 0) + goto error; + } else tab = add_eq(tab, bset->eq[i]); isl_int_swap(bset->eq[i][offset], cst); if (!tab) diff --git a/isl_tab.h b/isl_tab.h index cccfb9b0..da7089c5 100644 --- a/isl_tab.h +++ b/isl_tab.h @@ -192,7 +192,7 @@ enum isl_lp_result isl_tab_min(struct isl_tab *tab, struct isl_tab *isl_tab_extend(struct isl_tab *tab, unsigned n_new) WARN_UNUSED; int isl_tab_add_ineq(struct isl_tab *tab, isl_int *ineq) WARN_UNUSED; -struct isl_tab *isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED; +int isl_tab_add_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED; struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq) WARN_UNUSED; int isl_tab_freeze_constraint(struct isl_tab *tab, int con) WARN_UNUSED; diff --git a/isl_tab_pip.c b/isl_tab_pip.c index 809342b2..b616a335 100644 --- a/isl_tab_pip.c +++ b/isl_tab_pip.c @@ -2690,7 +2690,8 @@ static struct isl_tab *add_gbr_eq(struct isl_tab *tab, isl_int *eq) if (isl_tab_extend_cons(tab, 2) < 0) goto error; - tab = isl_tab_add_eq(tab, eq); + if (isl_tab_add_eq(tab, eq) < 0) + goto error; return tab; error: @@ -2708,7 +2709,8 @@ static void context_gbr_add_eq(struct isl_context *context, isl_int *eq, if (cgbr->cone && cgbr->cone->n_col != cgbr->cone->n_dead) { if (isl_tab_extend_cons(cgbr->cone, 2) < 0) goto error; - cgbr->cone = isl_tab_add_eq(cgbr->cone, eq); + if (isl_tab_add_eq(cgbr->cone, eq) < 0) + goto error; } if (check) { diff --git a/isl_vertices.c b/isl_vertices.c index 722fea59..5d2b718e 100644 --- a/isl_vertices.c +++ b/isl_vertices.c @@ -1138,11 +1138,8 @@ static struct isl_tab *tab_for_shifted_cone(__isl_keep isl_basic_set *bset) isl_int_set_si(c->el[0], 0); for (i = 0; i < bset->n_eq; ++i) { isl_seq_cpy(c->el + 1, bset->eq[i], c->size - 1); - tab = isl_tab_add_eq(tab, c->el); - if (!tab) { - isl_vec_free(c); - return tab; - } + if (isl_tab_add_eq(tab, c->el) < 0) + goto error; } isl_int_set_si(c->el[0], -1); -- 2.11.4.GIT