somake/comp/wcsdup.c

17 lines
330 B
C
Raw Normal View History

// 2016, Georg Sauthoff <mail@georg.so>, CDDL and WTFPL
#include "wcsdup.h"
#ifndef HAVE_WCSDUP
#include <stdlib.h>
// this function is part of POSIX.2008
wchar_t * wcsdup(const wchar_t *s)
{
2016-08-26 21:00:14 +00:00
size_t n = wcslen(s) + 1;
wchar_t *r = malloc(n * sizeof(wchar_t));
return r ? wmemcpy(r, s, n) : 0;
}
#endif