summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/heap.h16
-rw-r--r--cpukit/score/src/heapgreedy.c13
2 files changed, 28 insertions, 1 deletions
diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h
index 2937490896..bea9f3ec25 100644
--- a/cpukit/score/include/rtems/score/heap.h
+++ b/cpukit/score/include/rtems/score/heap.h
@@ -595,7 +595,7 @@ void _Heap_Iterate(
/**
* @brief Greedy allocate that empties the heap.
*
- * Afterward the heap has at most @a block_count allocateable blocks of sizes
+ * Afterwards the heap has at most @a block_count allocatable blocks of sizes
* specified by @a block_sizes. The @a block_sizes must point to an array with
* @a block_count members. All other blocks are used.
*
@@ -608,6 +608,20 @@ Heap_Block *_Heap_Greedy_allocate(
);
/**
+ * @brief Greedy allocate all blocks except the largest free block.
+ *
+ * Afterwards the heap has at most one allocatable block. This block is the
+ * largest free block if it exists. The allocatable size of this block is
+ * stored in @a allocatable_size. All other blocks are used.
+ *
+ * @see _Heap_Greedy_free().
+ */
+Heap_Block *_Heap_Greedy_allocate_all_except_largest(
+ Heap_Control *heap,
+ uintptr_t *allocatable_size
+);
+
+/**
* @brief Frees blocks of a greedy allocation.
*
* The @a blocks must be the return value of _Heap_Greedy_allocate().
diff --git a/cpukit/score/src/heapgreedy.c b/cpukit/score/src/heapgreedy.c
index 23eb4cdd3a..b5c61a4e64 100644
--- a/cpukit/score/src/heapgreedy.c
+++ b/cpukit/score/src/heapgreedy.c
@@ -75,6 +75,19 @@ Heap_Block *_Heap_Greedy_allocate(
return blocks;
}
+Heap_Block *_Heap_Greedy_allocate_all_except_largest(
+ Heap_Control *heap,
+ uintptr_t *allocatable_size
+)
+{
+ Heap_Information info;
+
+ _Heap_Get_free_information( heap, &info );
+ *allocatable_size = info.largest - HEAP_BLOCK_HEADER_SIZE + HEAP_ALLOC_BONUS;
+
+ return _Heap_Greedy_allocate( heap, allocatable_size, 1 );
+}
+
void _Heap_Greedy_free(
Heap_Control *heap,
Heap_Block *blocks