diff options
Diffstat (limited to 'cpukit/libcsupport/src/rtems_heap_greedy.c')
-rw-r--r-- | cpukit/libcsupport/src/rtems_heap_greedy.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/cpukit/libcsupport/src/rtems_heap_greedy.c b/cpukit/libcsupport/src/rtems_heap_greedy.c index c02e48d962..94c28d7f16 100644 --- a/cpukit/libcsupport/src/rtems_heap_greedy.c +++ b/cpukit/libcsupport/src/rtems_heap_greedy.c @@ -25,25 +25,17 @@ #include "malloc_p.h" +#define SBRK_ALLOC_SIZE (128 * 1024UL * 1024UL) + void *rtems_heap_greedy_allocate( const uintptr_t *block_sizes, 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_heap_sbrk_greedy_allocate( heap, SBRK_ALLOC_SIZE ); _RTEMS_Lock_allocator(); opaque = _Heap_Greedy_allocate( RTEMS_Malloc_Heap, block_sizes, block_count ); @@ -56,11 +48,14 @@ void *rtems_heap_greedy_allocate_all_except_largest( uintptr_t *allocatable_size ) { + Heap_Control *heap = RTEMS_Malloc_Heap; void *opaque; + rtems_heap_sbrk_greedy_allocate( heap, SBRK_ALLOC_SIZE ); + _RTEMS_Lock_allocator(); opaque = _Heap_Greedy_allocate_all_except_largest( - RTEMS_Malloc_Heap, + heap, allocatable_size ); _RTEMS_Unlock_allocator(); |