Merge pull request #301 from tlauda/topic/alloc_free_block

alloc: fix free_block
This commit is contained in:
Liam Girdwood 2018-09-03 14:36:42 +01:00 committed by GitHub
commit c28a210732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -324,11 +324,12 @@ static void free_block(void *ptr)
return;
/* find block that ptr belongs to */
for (i = 0; i < heap->blocks - 1; i++) {
block_map = cache_to_uncache(&heap->map[i + 1]);
for (i = 0; i < heap->blocks; i++) {
block_map = cache_to_uncache(&heap->map[i]);
/* is ptr in this block */
if ((uint32_t)ptr < block_map->base)
if ((uint32_t)ptr < (block_map->base +
(block_map->block_size * block_map->count)))
goto found;
}
@ -337,9 +338,6 @@ static void free_block(void *ptr)
return;
found:
/* the block i is it */
block_map = cache_to_uncache(&heap->map[i]);
/* calculate block header */
block = ((uint32_t)ptr - block_map->base) / block_map->block_size;
hdr = cache_to_uncache(&block_map->block[block]);