diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-12-08 22:39:07 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-12-08 22:39:07 +0100 |
commit | 2064b68718ea5f15de76d661ae1f307d67a0cf26 (patch) | |
tree | 3b8f93932cb4a13ab6001f165de7714ec7e86848 /src/mds-kbdc/variables.c | |
parent | update the texinfo manual for the new use of fail_if (diff) | |
download | mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.gz mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.bz2 mds-2064b68718ea5f15de76d661ae1f307d67a0cf26.tar.xz |
with a few exceptions and some remaining files, never return directly on failure, always goto fail by invoking fail_if
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/mds-kbdc/variables.c | 11 |
1 files changed, 7 insertions, 4 deletions
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 <libmdsserver/macros.h> + #include <stdlib.h> #include <string.h> @@ -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; } |