Skip to content

Commit 520ef18

Browse files
dabekjakubmwasko
authored andcommitted
vmh: fix allocation size value calculation
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 <jakub.dabek@intel.com>
1 parent 4189f09 commit 520ef18

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

zephyr/lib/regions_mm.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,20 +552,14 @@ int vmh_free(struct vmh_heap *heap, void *ptr)
552552
return -EINVAL;
553553

554554
if (bit_value) {
555-
/* We know we have more than one block was allocated so
556-
* we need to find the size
557-
*/
558-
size_t bits_to_check =
559-
heap->physical_blocks_allocators
560-
[mem_block_iter]->info.num_blocks - ptr_bit_array_position;
561-
562555
/* Neeeeeeeds optimization - thinking how to do it properly
563556
* each set bit in order after another means one allocated block.
564557
* When we get to 0 in such range we know that is last allocated block.
565558
* Testing bundles looks promising - need to investigate.
566559
*/
567560
for (i = ptr_bit_array_position;
568-
i < bits_to_check;
561+
i < heap->physical_blocks_allocators
562+
[mem_block_iter]->info.num_blocks;
569563
i++) {
570564

571565
sys_bitarray_test_bit(heap->allocation_sizes[mem_block_iter], i,

0 commit comments

Comments
 (0)