diff options
Diffstat (limited to 'src/mds-kbdc/include-stack.c')
-rw-r--r-- | src/mds-kbdc/include-stack.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mds-kbdc/include-stack.c b/src/mds-kbdc/include-stack.c index bec1425..d8c4547 100644 --- a/src/mds-kbdc/include-stack.c +++ b/src/mds-kbdc/include-stack.c @@ -190,9 +190,7 @@ mds_kbdc_include_stack_t* mds_kbdc_include_stack_save(void) return latest_save; } - latest_save = malloc(sizeof(mds_kbdc_include_stack_t)); - if (latest_save == NULL) - return NULL; + fail_if (xmalloc(latest_save, 1, mds_kbdc_include_stack_t)); latest_save->stack = NULL; latest_save->ptr = includes_ptr; @@ -207,8 +205,8 @@ mds_kbdc_include_stack_t* mds_kbdc_include_stack_save(void) return latest_save; fail: saved_errno = errno; - free(latest_save->stack); - latest_save = NULL; + if (latest_save) + free(latest_save->stack), latest_save = NULL; errno = saved_errno; return NULL; } @@ -229,8 +227,7 @@ int mds_kbdc_include_stack_restore(mds_kbdc_include_stack_t* restrict stack) if (stack->ptr > includes_size) { new = realloc(includes, stack->ptr * sizeof(const mds_kbdc_tree_include_t*)); - if (new == NULL) - return -1; + fail_if (new == NULL); includes = new; includes_size = stack->ptr; } @@ -238,6 +235,8 @@ int mds_kbdc_include_stack_restore(mds_kbdc_include_stack_t* restrict stack) memcpy(includes, stack->stack, stack->ptr * sizeof(const mds_kbdc_tree_include_t*)); includes_ptr = stack->ptr; return 0; + fail: + return -1; } |