9
0
Fork 0

lib: add wchar strdup

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Lucas Stach 2014-12-08 14:42:35 +01:00 committed by Sascha Hauer
parent 26793cc2cc
commit 42c8b4589a
2 changed files with 18 additions and 0 deletions

View File

@ -5,6 +5,8 @@
typedef u16 wchar_t;
wchar_t *strdup_wchar(const wchar_t *src);
char *strcpy_wchar_to_char(char *dst, const wchar_t *src);
wchar_t *strcpy_char_to_wchar(wchar_t *dst, const char *src);

View File

@ -31,6 +31,22 @@ size_t wcslen(const wchar_t *s)
return len;
}
wchar_t *strdup_wchar(const wchar_t *src)
{
int len = wcslen(src);
wchar_t *tmp, *dst;
if (!(dst = malloc((len + 1) * sizeof(wchar_t))))
return NULL;
tmp = dst;
while ((*dst++ = *src++))
/* nothing */;
return tmp;
}
char *strcpy_wchar_to_char(char *dst, const wchar_t *src)
{
char *ret = dst;