Skip to content

Commit

Permalink
vmh: fix allocation size value calculation
Browse files Browse the repository at this point in the history
Allocation sizes were calculated with faulty logic. Bits to check
size calculation is not needed since array position was calculated
and loop should go from this position to array end.

Signed-off-by: Jakub Dabek <[email protected]>
  • Loading branch information
dabekjakub committed Feb 23, 2024
1 parent 430935f commit ea65d21
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions zephyr/lib/regions_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,20 +552,14 @@ int vmh_free(struct vmh_heap *heap, void *ptr)
return -EINVAL;

if (bit_value) {
/* We know we have more than one block was allocated so
* we need to find the size
*/
size_t bits_to_check =
heap->physical_blocks_allocators
[mem_block_iter]->info.num_blocks - ptr_bit_array_position;

/* Neeeeeeeds optimization - thinking how to do it properly
* each set bit in order after another means one allocated block.
* When we get to 0 in such range we know that is last allocated block.
* Testing bundles looks promising - need to investigate.
*/
for (i = ptr_bit_array_position;
i < bits_to_check;
i < heap->physical_blocks_allocators
[mem_block_iter]->info.num_blocks;
i++) {

sys_bitarray_test_bit(heap->allocation_sizes[mem_block_iter], i,
Expand Down

0 comments on commit ea65d21

Please sign in to comment.