diff options
Diffstat (limited to 'source/kit/dynamic_array.h')
-rw-r--r-- | source/kit/dynamic_array.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/kit/dynamic_array.h b/source/kit/dynamic_array.h index df7b933..e868917 100644 --- a/source/kit/dynamic_array.h +++ b/source/kit/dynamic_array.h @@ -3,6 +3,8 @@ #include "allocator.h" +#include <string.h> + #ifdef __cplusplus extern "C" { #endif @@ -46,11 +48,14 @@ void kit_da_resize_exact(kit_da_void_t *array, i64 element_size, /* Destroy dynamic array. */ -#define KIT_DA_DESTROY(array_) \ - do { \ - if ((array_).values != NULL) \ - kit_alloc_dispatch((array_).alloc, KIT_DEALLOCATE, 0, 0, \ - (array_).values); \ +#define KIT_DA_DESTROY(array_) \ + do { \ + if ((array_).values != NULL) \ + kit_alloc_dispatch((array_).alloc, KIT_DEALLOCATE, 0, \ + (array_).capacity * \ + sizeof((array_).values[0]), \ + (array_).values); \ + memset(&(array_), 0, sizeof(array_)); \ } while (0) /* Resize dynamic array. |