From 8e30a269a21cd61ca1387e666e458e52c0b153ab Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 19 Dec 2007 16:03:54 +0000 Subject: 2007-12-19 Joel Sherrill * libcsupport/Makefile.am, libcsupport/include/rtems/malloc.h, libcsupport/src/free.c, libcsupport/src/malloc.c, libcsupport/src/malloc_p.h, libcsupport/src/malloc_report_statistics_plugin.c, libmisc/shell/shell.c, libmisc/shell/shell.h, score/src/objectinitializeinformation.c: Add posix_memalign. Split out management of deferred frees to subroutines. * libcsupport/src/malloc_deferred.c, libcsupport/src/posix_memalign.c: New files. --- cpukit/libcsupport/src/malloc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'cpukit/libcsupport/src/malloc.c') diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c index d1b3bb3504..a77444dc2c 100644 --- a/cpukit/libcsupport/src/malloc.c +++ b/cpukit/libcsupport/src/malloc.c @@ -34,30 +34,30 @@ void *malloc( MSBUMP(malloc_calls, 1); + /* + * If some free's have been deferred, then do them now. + */ + malloc_process_deferred_frees(); + + /* + * Validate the parameters + */ if ( !size ) return (void *) 0; - #if defined(RTEMS_HEAP_DEBUG) - _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, FALSE ); - #endif - /* - * Do not attempt to allocate memory if in a critical section or ISR. + * Do not attempt to allocate memory if not in correct system state. */ - - if (_System_state_Is_up(_System_state_Get())) { - if (_Thread_Dispatch_disable_level > 0) - return (void *) 0; - - if (_ISR_Nest_level > 0) - return (void *) 0; - } + if ( _System_state_Is_up(_System_state_Get()) && + !malloc_is_system_state_OK() ) + return NULL; /* - * If some free's have been deferred, then do them now. + * Walk the heap and verify its integrity */ - while ((to_be_freed = Chain_Get(&RTEMS_Malloc_GC_list)) != NULL) - free(to_be_freed); + #if defined(RTEMS_HEAP_DEBUG) + _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, FALSE ); + #endif #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS) /* -- cgit v1.2.3