Fix bug in aligned_realloc, fixes issue when a type is not resolved before the cast. #897

This commit is contained in:
Christoffer Lerno
2023-07-28 22:21:23 +02:00
parent 283a95dea2
commit 108b2244d8
3 changed files with 4 additions and 2 deletions

View File

@@ -77,7 +77,7 @@ macro void*! @aligned_realloc(#calloc_fn, #free_fn, void* old_pointer, usz bytes
AlignedBlock* desc = (AlignedBlock*)old_pointer - 1;
void* data_start = desc.start;
void* new_data = @aligned_calloc(#calloc_fn, bytes, alignment, offset)!;
mem::copy(new_data, old_pointer, desc.len > bytes ? desc.len : bytes, mem::DEFAULT_MEM_ALIGNMENT, mem::DEFAULT_MEM_ALIGNMENT);
mem::copy(new_data, old_pointer, desc.len < bytes ? desc.len : bytes, mem::DEFAULT_MEM_ALIGNMENT, mem::DEFAULT_MEM_ALIGNMENT);
$if $checks(#free_fn(data_start)!):
#free_fn(data_start)!;
$else