1 /* $MirOS: src/lib/libc/string/wcsdup.c,v 1.2 2006/11/01 20:01:21 tg Exp $ */
2 
3 /*-
4  * Copyright (c) 2006
5  *	Thorsten Glaser <tg@mirbsd.de>
6  *
7  * Licensee is hereby permitted to deal in this work without restric-
8  * tion, including unlimited rights to use, publicly perform, modify,
9  * merge, distribute, sell, give away or sublicence, provided all co-
10  * pyright notices above, these terms and the disclaimer are retained
11  * in all redistributions or reproduced in accompanying documentation
12  * or other materials provided with binary redistributions.
13  *
14  * Advertising materials mentioning features or use of this work must
15  * display the following acknowledgement:
16  *	This product includes material provided by Thorsten Glaser.
17  *
18  * Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind,
19  * express, or implied, to the maximum extent permitted by applicable
20  * law, without malicious intent or gross negligence; in no event may
21  * licensor, an author or contributor be held liable for any indirect
22  * or other damage, or direct damage except proven a consequence of a
23  * direct error of said person and intended use of this work, loss or
24  * other issues arising in any way out of its use, even if advised of
25  * the possibility of such damage or existence of a defect.
26  */
27 
28 #include <wchar.h>
29 
30 __RCSID("$MirOS: src/lib/libc/string/wcsdup.c,v 1.2 2006/11/01 20:01:21 tg Exp $");
31 
32 wchar_t *
wcsdup(const wchar_t * s)33 wcsdup(const wchar_t *s)
34 {
35 	size_t n;
36 	wchar_t *rv;
37 
38 	n = wcslen(s) + 1;
39 	if ((rv = calloc(n, sizeof (wchar_t))) == NULL)
40 		return (NULL);
41 	memcpy(rv, s, n * sizeof (wchar_t));
42 	return (rv);
43 }
44