int isl_tab_extend_cons(struct isl_tab *tab, unsigned n_new)
{
- unsigned off = 2 + tab->M;
+ unsigned off;
if (!tab)
return -1;
+ off = 2 + tab->M;
+
if (tab->max_con < tab->n_con + n_new) {
struct isl_tab_var *con;
prod = isl_mat_alloc(mat1->ctx, mat1->n_row + mat2->n_row,
off + col1 + col2);
+ if (!prod)
+ return NULL;
n = 0;
for (i = 0; i < r1; ++i) {
/* Add an equality that is known to be valid for the given tableau.
*/
-struct isl_tab *isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq)
+int isl_tab_add_valid_eq(struct isl_tab *tab, isl_int *eq)
{
struct isl_tab_var *var;
int r;
if (!tab)
- return NULL;
+ return -1;
r = isl_tab_add_row(tab, eq);
if (r < 0)
- goto error;
+ return -1;
var = &tab->con[r];
r = var->index;
if (row_is_manifestly_zero(tab, r)) {
var->is_zero = 1;
if (isl_tab_mark_redundant(tab, r) < 0)
- goto error;
- return tab;
+ return -1;
+ return 0;
}
if (isl_int_is_neg(tab->mat->row[r][1])) {
}
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;
}
static int add_zero_row(struct isl_tab *tab)
struct isl_tab_var *var;
struct isl_tab_undo *snap;
+ if (!tab)
+ return isl_lp_error;
+
if (tab->empty)
return isl_lp_empty;
if (undo == snap)
break;
if (perform_undo(tab, undo) < 0) {
+ tab->top = undo;
free_undo(tab);
tab->in_undo = 0;
return -1;