Skip to content

Commit

Permalink
vmh: fix array update for contiguous allocation
Browse files Browse the repository at this point in the history
Array holding sizes of allocations was not updated correctly this
fixes array update issue.

Signed-off-by: Jakub Dabek <[email protected]>
  • Loading branch information
dabekjakub committed Feb 23, 2024
1 parent 3ff62f3 commit 430935f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions zephyr/lib/regions_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ int vmh_free(struct vmh_heap *heap, void *ptr)

size_t mem_block_iter, i, size_to_free, block_size, ptr_bit_array_offset,
ptr_bit_array_position, physical_block_count,
check_offset, check_position, check_size;
check_offset, check_position, check_size, blocks_to_free;
uintptr_t phys_aligned_ptr, phys_aligned_alloc_end, phys_block_ptr;
bool ptr_range_found;

Expand Down Expand Up @@ -581,10 +581,13 @@ int vmh_free(struct vmh_heap *heap, void *ptr)
*/
size_to_free = block_size;
}

blocks_to_free = size_to_free / block_size;
retval = sys_mem_blocks_free_contiguous(
heap->physical_blocks_allocators[mem_block_iter], ptr,
size_to_free / block_size);
blocks_to_free);
if (!retval)
sys_bitarray_clear_region(heap->allocation_sizes[mem_block_iter],
blocks_to_free, ptr_bit_array_position);
} else {
retval = sys_mem_blocks_free(heap->physical_blocks_allocators[mem_block_iter],
1, &ptr);
Expand Down

0 comments on commit 430935f

Please sign in to comment.