From d254189b38bb5b0b77a18a401c05c415ce0733c9 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 23 Jul 2002 21:38:00 +0000 Subject: 2002-07-23 Jeff Johnston * libc/include/string.h: Add mempcpy, strndup, and _strndup_r prototypes. * libc/stdlib/Makefile.am: Remove strdup.c and strdup_r.c. * libc/stdlib/Makefile.in: Regenerated. * libc/stdlib/strdup.c: Removed. * libc/stdlib/strdup_r.c: Removed. * libc/string/Makefile.am: Add strdup.c, strdup_r.c, memccpy.c, mempcpy.c, strndup.c, and strndup_r.c. * libc/string/Makefile.in: Regenerated. * libc/string/memccpy.c: New file. * libc/string/mempcpy.c: Ditto. * libc/string/strndup.c: Ditto. * libc/string/strndup_r.c: Ditto. * libc/string/strdup.c: New file moved from stdlib. * libc/string/strdup_r.c: Ditto. * libc/string/strings.tex: Add memccpy and mempcpy documentation. --- newlib/libc/string/strdup_r.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 newlib/libc/string/strdup_r.c (limited to 'newlib/libc/string/strdup_r.c') diff --git a/newlib/libc/string/strdup_r.c b/newlib/libc/string/strdup_r.c new file mode 100644 index 000000000..ef77a58eb --- /dev/null +++ b/newlib/libc/string/strdup_r.c @@ -0,0 +1,17 @@ +#include +#include +#include + +char * +_DEFUN (_strdup_r, (reent_ptr, str), + struct _reent *reent_ptr _AND + _CONST char *str) +{ + size_t len = strlen (str) + 1; + char *copy = _malloc_r (reent_ptr, len); + if (copy) + { + memcpy (copy, str, len); + } + return copy; +} -- cgit v1.2.3