diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-12-12 15:17:33 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-12-12 15:17:33 +0000 |
commit | 141b31107a64a23ef2e369cc7cc2ed91c1e78cc3 (patch) | |
tree | 78337f049e79a9886d7257668864b8aeeb7d9351 /cpukit/score/src/wkstringduplicate.c | |
parent | Regenerate. (diff) | |
download | rtems-141b31107a64a23ef2e369cc7cc2ed91c1e78cc3.tar.bz2 |
2011-12-12 Sebastian Huber <sebastian.huber@embedded-brains.de>
* score/src/wkstringduplicate.c: New file.
* score/Makefile.am: Reflect change above.
* score/include/rtems/score/wkspace.h: Declare
_Workspace_String_duplicate().
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/src/wkstringduplicate.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cpukit/score/src/wkstringduplicate.c b/cpukit/score/src/wkstringduplicate.c new file mode 100644 index 0000000000..55c347a7ca --- /dev/null +++ b/cpukit/score/src/wkstringduplicate.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include <rtems/score/wkspace.h> + +#include <string.h> + +char *_Workspace_String_duplicate( + const char *string, + size_t maxlen +) +{ + size_t n = strnlen(string, maxlen); + char *dup = _Workspace_Allocate(n + 1); + + if (dup != NULL) { + dup [n] = '\0'; + memcpy(dup, string, n); + } + + return dup; +} |