strdup.c 691 B

12345678910111213141516171819202122232425262728293031323334
  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. #include "_string.h"
  8. #include <stdlib.h>
  9. #ifdef WANT_WIDE
  10. # define __Wstrdup __wcsdup
  11. # define Wstrdup wcsdup
  12. # define Wstrlen __wcslen
  13. # define Wstrcpy __wcscpy
  14. #else
  15. # define __Wstrdup __strdup
  16. # define Wstrdup strdup
  17. # define Wstrlen __strlen
  18. # define Wstrcpy __strcpy
  19. #endif
  20. Wchar attribute_hidden *__Wstrdup(register const Wchar *s1)
  21. {
  22. register Wchar *s;
  23. if ((s = malloc((Wstrlen(s1) + 1) * sizeof(Wchar))) != NULL) {
  24. Wstrcpy(s, s1);
  25. }
  26. return s;
  27. }
  28. strong_alias(__Wstrdup,Wstrdup)