From 7e59c771569e6162f2ef96b1d88c85f05cc0e552 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Mon, 15 Jul 2019 10:52:13 +0100 Subject: Fixing a memory allocation regression In a previous commit, adding HASH node support, this code was added that would let both ARRAY and HASH nodes allocate an array. The syntax was however wrong, never allocating memory and thus failing with an INVALID_STATE when freeing. Additionally, this begs the question how a cleanup of INVALID_STATE could be handled (i.e. with a `goto fail` in the `bowl_free` function) --- bowl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bowl.c b/bowl.c index 248ac37..9d12c69 100644 --- a/bowl.c +++ b/bowl.c @@ -31,7 +31,8 @@ err_t bowl_malloc(struct bowl **ptr, bowl_t type) switch((*ptr)->type) { case LEAF: return OK; // No further allocation needed - case ARRAY | HASH: return array_malloc(*ptr, ARRAY_START_SIZE); + case ARRAY: + case HASH: return array_malloc(*ptr, ARRAY_START_SIZE); default: return INVALID_STATE; } -- cgit v1.2.3