1 1.1 christos /* $NetBSD: wcsdup.c,v 1.1 2006/08/22 20:50:46 christos Exp $ */ 2 1.1 christos 3 1.1 christos #include <sys/cdefs.h> 4 1.1 christos 5 1.1 christos #if defined(LIBC_SCCS) && !defined(lint) 6 1.1 christos __RCSID("$NetBSD: wcsdup.c,v 1.1 2006/08/22 20:50:46 christos Exp $"); 7 1.1 christos #endif /* LIBC_SCCS and not lint */ 8 1.1 christos 9 1.1 christos #include "namespace.h" 10 1.1 christos #include <stdlib.h> 11 1.1 christos #include <assert.h> 12 1.1 christos #include <string.h> 13 1.1 christos #include <wchar.h> 14 1.1 christos 15 1.1 christos __weak_alias(wcsdup,_wcsdup) 16 1.1 christos 17 1.1 christos wchar_t * 18 1.1 christos wcsdup(const wchar_t *str) 19 1.1 christos { 20 1.1 christos wchar_t *copy; 21 1.1 christos size_t len; 22 1.1 christos 23 1.1 christos _DIAGASSERT(str != NULL); 24 1.1 christos 25 1.1 christos len = wcslen(str) + 1; 26 1.1 christos copy = malloc(len * sizeof (wchar_t)); 27 1.1 christos 28 1.1 christos if (!copy) 29 1.1 christos return NULL; 30 1.1 christos 31 1.1 christos return wmemcpy(copy, str, len); 32 1.1 christos } 33