From: batt Date: Mon, 19 Apr 2010 22:41:40 +0000 (+0000) Subject: heap: Fix heap_freemem() when all the heap is full. X-Git-Tag: 2.5.0~439 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=08c8730ec883c21e45a0c475b5c7032f9fdd93a4;p=bertos.git 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 --- 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;