Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <user/trace.h>
#include <config.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Expand Down Expand Up @@ -447,6 +448,7 @@ static void free_block(void *ptr)
int i;
int block;
int used_blocks;
bool heap_is_full;

heap = get_heap_from_ptr(ptr);
if (!heap) {
Expand Down Expand Up @@ -499,6 +501,8 @@ static void free_block(void *ptr)
if (block_map->base + block_map->block_size * block != (uint32_t)ptr)
panic(SOF_IPC_PANIC_MEM);

heap_is_full = !block_map->free_count;

/* free block header and continuous blocks */
used_blocks = block + hdr->size;

Expand All @@ -513,7 +517,7 @@ static void free_block(void *ptr)
}

/* set first free block */
if (block < block_map->first_free)
if (block < block_map->first_free || heap_is_full)
block_map->first_free = block;

writeback_block_map(block_map);
Expand Down