diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-02-25 09:02:43 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-02-25 11:35:54 +0100 |
commit | 9d1f39434585e8d3f8897d95a2bfe1ddccb79aec (patch) | |
tree | 2d3a0868f410cff137871f5ce493df4f27a22b1a /cpukit/libcsupport/src/free.c | |
parent | malloc: Use dedicated lock for deferred frees (diff) | |
download | rtems-9d1f39434585e8d3f8897d95a2bfe1ddccb79aec.tar.bz2 |
malloc: Add _Malloc_System_state()
Replace malloc_is_system_state_OK() with _Malloc_System_state() to allow
early allocations, e.g. in bsp_start(). Here the _Thread_Executing is
NULL, thus an _API_Mutex_Lock() would lead to a NULL pointer access.
Move malloc() support code to general case
rtems_heap_allocate_aligned_with_boundary(). Use
rtems_heap_allocate_aligned_with_boundary() to avoid duplicated code.
Diffstat (limited to 'cpukit/libcsupport/src/free.c')
-rw-r--r-- | cpukit/libcsupport/src/free.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/cpukit/libcsupport/src/free.c b/cpukit/libcsupport/src/free.c index 63eb7b8037..f3d4cb824b 100644 --- a/cpukit/libcsupport/src/free.c +++ b/cpukit/libcsupport/src/free.c @@ -22,10 +22,6 @@ #include "malloc_p.h" #include <stdlib.h> -#include <rtems/score/sysstate.h> - -#include "malloc_p.h" - void free( void *ptr ) @@ -36,8 +32,8 @@ void free( /* * Do not attempt to free memory if in a critical section or ISR. */ - if ( !malloc_is_system_state_OK() ) { - malloc_deferred_free(ptr); + if ( _Malloc_System_state() != MALLOC_SYSTEM_STATE_NORMAL ) { + _Malloc_Deferred_free(ptr); return; } |