From 159a17c8c800f24e82ddd60ed103a76c6f275408 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 15 Mar 2009 13:39:07 +0000 Subject: * libc/include/wchar.h (wcsdup, _wcsdup_r): Declare. * libc/string/Makefile.am: Add wcsdup.c. * libc/string/Makefile.in: Regenerate. * libc/string/strings.tex: Add wcsdup documentation reference. * libc/string/wcsdup.c: New file. --- newlib/libc/string/wcsdup.c | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 newlib/libc/string/wcsdup.c (limited to 'newlib/libc/string/wcsdup.c') diff --git a/newlib/libc/string/wcsdup.c b/newlib/libc/string/wcsdup.c new file mode 100644 index 000000000..8462c0b09 --- /dev/null +++ b/newlib/libc/string/wcsdup.c @@ -0,0 +1,62 @@ +/* +FUNCTION + <>---wide character string duplicate + +INDEX + wcsdup +INDEX + _wcsdup_r + +ANSI_SYNOPSIS + #include + wchar_t *wcsdup(const wchar_t *<[str]>); + + #include + wchar_t *_wcsdup_r(struct _reent *, const wchar_t *<[str]>); + +TRAD_SYNOPSIS + #include + wchar_t *wcsdup(, <[str]>) + struct _reent *; + wchar_t *<[str]>; + +DESCRIPTION + <> allocates a new wide character string using <, + and copies the content of the argument <[str]> into the newly + allocated string, thus making a copy of <[str]>. + +RETURNS + <> returns a pointer to the copy of <[str]> if enough + memory for the copy was available. Otherwise it returns NULL + and errno is set to ENOMEM. + +PORTABILITY +POSIX-1.2008 + +QUICKREF + wcsdup +*/ + +#include +#include +#include + +wchar_t * +_wcsdup_r (struct _reent *p, const wchar_t *str) +{ + size_t len = wcslen (str) + 1; + wchar_t *copy = _malloc_r (p, len * sizeof (wchar_t)); + if (copy) + wmemcpy (copy, str, len); + return copy; +} + +#ifndef _REENT_ONLY + +wchar_t * +wcsdup (const wchar_t *str) +{ + return _wcsdup_r (_REENT, str); +} + +#endif /* !_REENT_ONLY */ -- cgit v1.2.3