lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Manuel Novoa III |
| 3 | * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> |
| 4 | * |
| 5 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 6 | */ |
| 7 | |
| 8 | #include "_string.h" |
| 9 | #include <stdlib.h> |
| 10 | |
| 11 | #ifdef WANT_WIDE |
| 12 | # define Wstrdup wcsdup |
| 13 | # define Wstrlen wcslen |
| 14 | #else |
| 15 | # define Wstrdup strdup |
| 16 | # define Wstrlen strlen |
| 17 | #endif |
| 18 | |
| 19 | Wchar *Wstrdup(register const Wchar *s1) |
| 20 | { |
| 21 | register Wchar *s; |
| 22 | register size_t l = (Wstrlen(s1) + 1) * sizeof(Wchar); |
| 23 | |
| 24 | if ((s = malloc(l)) != NULL) { |
| 25 | memcpy(s, s1, l); |
| 26 | } |
| 27 | |
| 28 | return s; |
| 29 | } |
| 30 | |
| 31 | #ifndef WANT_WIDE |
| 32 | libc_hidden_weak(strdup) |
| 33 | #endif |