aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/variables.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-09 13:15:10 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-09 13:15:10 +0100
commit7a994c9631c590d6a73c842fa5d2d3567b4771dd (patch)
tree228ade01f99ba217151a0ed20f29c5f3a5028619 /src/mds-kbdc/variables.c
parentmds-kbdc: compile-layout: macro_call: fix bug: do not duplicate the arguments if there are none (diff)
parentreport an error, rather than causing failure the caller but not for the called function (diff)
downloadmds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.gz
mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.bz2
mds-7a994c9631c590d6a73c842fa5d2d3567b4771dd.tar.xz
merge track-errors and resolve conflict
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/mds-kbdc/variables.c')
-rw-r--r--src/mds-kbdc/variables.c11
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;
}