libdl: first execute all destructors, then munmap library
[uclibc-ng.git] / libc / string / strdup.c
blob049a23f63d17620ab67ea44f66eb9d6a88914608
1 /*
2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 #include "_string.h"
9 #include <stdlib.h>
11 #ifdef WANT_WIDE
12 # define Wstrdup wcsdup
13 # define Wstrlen wcslen
14 #else
15 # define Wstrdup strdup
16 # define Wstrlen strlen
17 #endif
19 Wchar *Wstrdup(register const Wchar *s1)
21 register Wchar *s;
22 register size_t l = (Wstrlen(s1) + 1) * sizeof(Wchar);
24 if ((s = malloc(l)) != NULL) {
25 memcpy(s, s1, l);
28 return s;
31 #ifndef WANT_WIDE
32 libc_hidden_weak(strdup)
33 #endif