From 2064b68718ea5f15de76d661ae1f307d67a0cf26 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 8 Dec 2014 22:39:07 +0100 Subject: with a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/variables.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/mds-kbdc/variables.c') diff --git a/src/mds-kbdc/variables.c b/src/mds-kbdc/variables.c index 55bae76..7431767 100644 --- a/src/mds-kbdc/variables.c +++ b/src/mds-kbdc/variables.c @@ -17,6 +17,8 @@ */ #include "variables.h" +#include + #include #include @@ -149,9 +151,8 @@ int variables_let(size_t variable, mds_kbdc_tree_t* restrict value) /* Grow the table if necessary to fit the variable. */ if (variable >= variable_count) { - new = realloc(variables, (variable + 1) * sizeof(variable_t*)); - if (new == NULL) - return -1; + new = variables; + fail_if (xrealloc(new, variable + 1, variable_t*)); variables = new; memset(variables + variable_count, 0, (variable + 1 - variable_count) * sizeof(variable_t*)); variable_count = variable + 1; @@ -169,13 +170,15 @@ int variables_let(size_t variable, mds_kbdc_tree_t* restrict value) previous = variables[variable]; variables[variable] = malloc(sizeof(variable_t)); if (variables[variable] == NULL) - return variables[variable] = previous, -1; + fail_if (variables[variable] = previous, 1); variables[variable]->value = value; variables[variable]->previous = previous; variables[variable]->scope = current_scope; } return 0; + fail: + return -1; } -- cgit v1.2.3-70-g09d2