diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-02-03 22:13:40 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-02-03 22:20:36 (GMT) |
commit | 9b35b89fce2499d5352f5323baec53abbf9a4af2 (patch) | |
tree | 49dde922a235f7d11cc8db63c8e0ac1d26f530e7 /src/common | |
parent | 10aa517f3a26dd9e4f96f78e62ba1c87e91c7243 (diff) |
Fixed various memory leaks.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/array.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/array.c b/src/common/array.c index 8264101..3f721be 100644 --- a/src/common/array.c +++ b/src/common/array.c @@ -285,7 +285,7 @@ void copy_flat_array_items(flat_array_t **src, flat_array_t **dest, size_t size, { extended = EXTENDED_ARRAY(*src); - new_ext = (ext_flat_array_t *)malloc(sizeof(ext_flat_array_t)); + new_ext = malloc(sizeof(ext_flat_array_t)); new_ext->items = malloc(extended->count * size); new_ext->count = extended->count; @@ -387,7 +387,7 @@ void add_item_to_flat_array(flat_array_t **array, const void *item, size_t size) { if (FLAT_ARRAY_HAS_NO_INDEX(*array)) { - extended = (ext_flat_array_t *)malloc(sizeof(ext_flat_array_t)); + extended = malloc(sizeof(ext_flat_array_t)); extended->items = malloc(2 * size); extended->count = 2; @@ -456,7 +456,7 @@ void insert_item_into_flat_array(flat_array_t **array, void *item, size_t size, { if (FLAT_ARRAY_HAS_NO_INDEX(*array)) { - extended = (ext_flat_array_t *)malloc(sizeof(ext_flat_array_t)); + extended = malloc(sizeof(ext_flat_array_t)); extended->items = malloc(size); extended->count = 1; @@ -581,6 +581,7 @@ void rem_item_from_flat_array(flat_array_t **array, size_t index, size_t size) else memcpy(new, ((char *)extended->items) + size, size); + free(extended->items); free(extended); relock_flat_array(array, new); |