diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-07 16:00:00 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-04-07 16:48:02 +0200 |
commit | d61c315575a45ec4e539d9b7511895b310917e77 (patch) | |
tree | 00db95db8e328d87f17bce966ce6eba79506088c /cpukit | |
parent | psxtests/psxkey02: Test for proper error case (diff) | |
download | rtems-d61c315575a45ec4e539d9b7511895b310917e77.tar.bz2 |
score: Fix for empty heap
Diffstat (limited to 'cpukit')
-rw-r--r-- | 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 34ac811951..615d3066cf 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 ); } |