diff options
author | Chris Johns <chrisj@rtems.org> | 2012-05-08 08:47:31 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-05-08 08:47:31 +1000 |
commit | b78c02ab55ae3c0a932901896051617e1a212952 (patch) | |
tree | d8ce5cd954bc7d6a830d49f4e6abc210c77fefab /rtl-string.c | |
parent | 7f7cdc2de97f006def935f3b2788a24dd25248eb (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-string.c')
-rw-r--r-- | rtl-string.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/rtl-string.c b/rtl-string.c new file mode 100644 index 0000000..cba7616 --- /dev/null +++ b/rtl-string.c @@ -0,0 +1,32 @@ +/* + * 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 String managment. + */ + +#include <string.h> + +#include "rtl-allocator.h" +#include "rtl-string.h" + +char* +rtems_rtl_strdup (const char *s1) +{ + size_t len = strlen (s1); + char* s2 = rtems_rtl_alloc_new (RTEMS_RTL_ALLOC_STRING, len + 1); + if (s2) + { + memcpy (s2, s1, len); + s2[len] = '\0'; + } + return s2; +} |