From e57b5033559e51d8931daea5fb9fbeb027d8261f Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Thu, 18 May 2023 16:44:11 +0100 Subject: [PATCH] Fix memory errors --- containers/aligned_vector.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/containers/aligned_vector.c b/containers/aligned_vector.c index 15729ae..f75459a 100644 --- a/containers/aligned_vector.c +++ b/containers/aligned_vector.c @@ -23,6 +23,7 @@ void aligned_vector_init(AlignedVector* vector, uint32_t element_size) { hdr->size = 0; hdr->capacity = ALIGNED_VECTOR_CHUNK_SIZE; hdr->element_size = element_size; + vector->data = NULL; /* Reserve some initial capacity. This will do the allocation but not set up the header */ void* ptr = aligned_vector_reserve(vector, ALIGNED_VECTOR_CHUNK_SIZE); @@ -37,7 +38,7 @@ void aligned_vector_shrink_to_fit(AlignedVector* vector) { free(vector->data); /* Reallocate the header */ - vector->data = memalign(0x20, sizeof(AlignedVectorHeader)); + vector->data = NULL; hdr->size = hdr->capacity = 0; hdr->element_size = element_size; } else {