diff options
author | Katharina Fey <kookie@spacekookie.de> | 2019-07-15 10:52:13 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2019-07-15 10:52:13 +0100 |
commit | 7e59c771569e6162f2ef96b1d88c85f05cc0e552 (patch) | |
tree | a8c9922d9f93d85a3ac336daa333874f71d5fca6 | |
parent | 0a97a1613bf42dc4ecaffbed1426d3495f5f9160 (diff) |
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)
-rw-r--r-- | bowl.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; } |