summaryrefslogtreecommitdiff
path: root/rtl-alloc-heap.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-05-08 08:47:31 +1000
committerChris Johns <chrisj@rtems.org>2012-05-08 08:47:31 +1000
commitb78c02ab55ae3c0a932901896051617e1a212952 (patch)
treed8ce5cd954bc7d6a830d49f4e6abc210c77fefab /rtl-alloc-heap.c
parent7f7cdc2de97f006def935f3b2788a24dd25248eb (diff)
Add RTL allocator.
Add a custom allocator that can be hooked. The default heap allocator in this code does nothing more than wrap the libc heap allocator. Fix up the RTL initialise to better handle the locking and initialisation of internal structures.
Diffstat (limited to 'rtl-alloc-heap.c')
-rw-r--r--rtl-alloc-heap.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/rtl-alloc-heap.c b/rtl-alloc-heap.c
new file mode 100644
index 0000000..1f3c8dd
--- /dev/null
+++ b/rtl-alloc-heap.c
@@ -0,0 +1,30 @@
+/*
+ * COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+/**
+ * @file
+ *
+ * @ingroup rtems_rtl
+ *
+ * @brief RTEMS Run-Time Linker Allocator for the standard heap.
+ */
+
+#include <stdlib.h>
+
+#include "rtl-alloc-heap.h"
+
+void
+rtems_rtl_alloc_heap (bool allocate,
+ rtems_rtl_alloc_tag_t tag,
+ void** address,
+ size_t size)
+{
+ if (allocate)
+ *address = malloc (size);
+ else
+ free (*address);
+}