[rtems commit] libcsupport: Have greedy allocations use consume extended memory

Chris Johns chrisj at rtems.org
Mon Feb 8 06:47:39 UTC 2021


Module:    rtems
Branch:    master
Commit:    7ca3b283bac78e69f09f6e0e992abf088e7dd16c
Changeset: http://git.rtems.org/rtems/commit/?id=7ca3b283bac78e69f09f6e0e992abf088e7dd16c

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Feb  8 17:27:34 2021 +1100

libcsupport: Have greedy allocations use consume extended memory

- Call the heap extend handler until all memory has been
  requested.

Closes #3982

---

 cpukit/libcsupport/src/rtems_heap_greedy.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/cpukit/libcsupport/src/rtems_heap_greedy.c b/cpukit/libcsupport/src/rtems_heap_greedy.c
index 4dda398..c02e48d 100644
--- a/cpukit/libcsupport/src/rtems_heap_greedy.c
+++ b/cpukit/libcsupport/src/rtems_heap_greedy.c
@@ -30,8 +30,21 @@ void *rtems_heap_greedy_allocate(
   size_t block_count
 )
 {
+  Heap_Control *heap = RTEMS_Malloc_Heap;
+  size_t size = 128 * 1024 * 1024;
   void *opaque;
 
+  while ( size > 0 ) {
+    opaque = (*rtems_malloc_extend_handler)( heap, size );
+    if ( opaque == NULL ) {
+      size >>= 1;
+    } else {
+      if ( rtems_malloc_dirty_helper != NULL ) {
+	(*rtems_malloc_dirty_helper)( opaque, size );
+      }
+    }
+  }
+
   _RTEMS_Lock_allocator();
   opaque = _Heap_Greedy_allocate( RTEMS_Malloc_Heap, block_sizes, block_count );
   _RTEMS_Unlock_allocator();



More information about the vc mailing list