[rtems commit] score: Fix for empty heap
Sebastian Huber
sebh at rtems.org
Mon Apr 7 14:42:13 UTC 2014
Module: rtems
Branch: master
Commit: d61c315575a45ec4e539d9b7511895b310917e77
Changeset: http://git.rtems.org/rtems/commit/?id=d61c315575a45ec4e539d9b7511895b310917e77
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Apr 7 16:00:00 2014 +0200
score: Fix for empty heap
---
cpukit/score/src/heapgreedy.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/cpukit/score/src/heapgreedy.c b/cpukit/score/src/heapgreedy.c
index 34ac811..615d306 100644
--- a/cpukit/score/src/heapgreedy.c
+++ b/cpukit/score/src/heapgreedy.c
@@ -83,7 +83,12 @@ Heap_Block *_Heap_Greedy_allocate_all_except_largest(
Heap_Information info;
_Heap_Get_free_information( heap, &info );
- *allocatable_size = info.largest - HEAP_BLOCK_HEADER_SIZE + HEAP_ALLOC_BONUS;
+
+ if ( info.largest > 0 ) {
+ *allocatable_size = info.largest - HEAP_BLOCK_HEADER_SIZE + HEAP_ALLOC_BONUS;
+ } else {
+ *allocatable_size = 0;
+ }
return _Heap_Greedy_allocate( heap, allocatable_size, 1 );
}
More information about the vc
mailing list