dupwcs.c 307 B

1234567891011121314151617181920
  1. /*
  2. * Allocate a duplicate of a NUL-terminated wchar_t string.
  3. */
  4. #include <wchar.h>
  5. #include "defs.h"
  6. #include "misc.h"
  7. wchar_t *dupwcs(const wchar_t *s)
  8. {
  9. wchar_t *p = NULL;
  10. if (s) {
  11. int len = wcslen(s);
  12. p = snewn(len + 1, wchar_t);
  13. wcscpy(p, s);
  14. }
  15. return p;
  16. }