From 08c8730ec883c21e45a0c475b5c7032f9fdd93a4 Mon Sep 17 00:00:00 2001 From: batt Date: Mon, 19 Apr 2010 22:41:40 +0000 Subject: [PATCH] heap: Fix heap_freemem() when all the heap is full. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3469 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/struct/heap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bertos/struct/heap.c b/bertos/struct/heap.c index 33c6de2a..b8d06701 100644 --- a/bertos/struct/heap.c +++ b/bertos/struct/heap.c @@ -127,9 +127,9 @@ void heap_freemem(struct Heap* h, void *mem, size_t size) if (!size) size = sizeof(MemChunk); - /* Special case: first chunk in the free list */ + /* Special cases: first chunk in the free list or memory completely full */ ASSERT((uint8_t*)mem != (uint8_t*)h->FreeList); - if (((uint8_t *)mem) < ((uint8_t *)h->FreeList)) + if (((uint8_t *)mem) < ((uint8_t *)h->FreeList) || !h->FreeList) { /* Insert memory block before the current free list head */ prev = (MemChunk *)mem; -- 2.25.1