summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-09 12:11:11 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-12 13:26:22 +0100
commit6efc831f0ff3d975fa9086a46c3a67b6f2b95100 (patch)
tree0abb96a9bac37a9a07470d7645ef74139fd9738a /cpukit/libcsupport
parentscore: Add and use malloc() family attributes (diff)
downloadrtems-6efc831f0ff3d975fa9086a46c3a67b6f2b95100.tar.bz2
Add rtems_malloc() and rtems_calloc()
Close #3583.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/malloc_deferred.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/malloc_deferred.c b/cpukit/libcsupport/src/malloc_deferred.c
index f37b852cba..ccb8dc3b8b 100644
--- a/cpukit/libcsupport/src/malloc_deferred.c
+++ b/cpukit/libcsupport/src/malloc_deferred.c
@@ -23,6 +23,7 @@
#ifdef RTEMS_NEWLIB
#include <stdlib.h>
+#include <string.h>
#include "malloc_p.h"
@@ -136,4 +137,28 @@ void _Malloc_Deferred_free( void *p )
rtems_chain_append_unprotected( &_Malloc_GC_list, node );
rtems_interrupt_lock_release( &_Malloc_GC_lock, &lock_context );
}
+
+void *rtems_malloc( size_t size )
+{
+ if ( size == 0 ) {
+ return NULL;
+ }
+
+ return rtems_heap_allocate_aligned_with_boundary( size, 0, 0 );
+}
+
+void *rtems_calloc( size_t nelem, size_t elsize )
+{
+ size_t length;
+ void *p;
+
+ length = nelem * elsize;
+ p = rtems_malloc( length );
+ RTEMS_OBFUSCATE_VARIABLE( p );
+ if ( RTEMS_PREDICT_FALSE( p == NULL ) ) {
+ return p;
+ }
+
+ return memset( p, 0, length );
+}
#endif