summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/wcsdup.c
diff options
context:
space:
mode:
authornicm <>2011-07-04 04:37:34 +0000
committernicm <>2011-07-04 04:37:34 +0000
commitc2fefb45cad7a8dea2cb9072d7e84499e81fd8dc (patch)
treeecc5f99f764f612c819ad4917edf266071c15ace /src/lib/libc/string/wcsdup.c
parent614c377cb5cfeef667190bff1ff7652ddcc07c51 (diff)
downloadopenbsd-c2fefb45cad7a8dea2cb9072d7e84499e81fd8dc.tar.gz
openbsd-c2fefb45cad7a8dea2cb9072d7e84499e81fd8dc.tar.bz2
openbsd-c2fefb45cad7a8dea2cb9072d7e84499e81fd8dc.zip
Add wcsdup(), from NetBSD.
ok deraadt matthew
Diffstat (limited to 'src/lib/libc/string/wcsdup.c')
-rw-r--r--src/lib/libc/string/wcsdup.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/libc/string/wcsdup.c b/src/lib/libc/string/wcsdup.c
new file mode 100644
index 0000000000..57a328a8c2
--- /dev/null
+++ b/src/lib/libc/string/wcsdup.c
@@ -0,0 +1,31 @@
1/* $OpenBSD: wcsdup.c,v 1.1 2011/07/04 04:37:34 nicm Exp $ */
2/* $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $ */
3
4/*
5 * Copyright (C) 2006 Aleksey Cheusov
6 *
7 * This material is provided "as is", with absolutely no warranty expressed
8 * or implied. Any use is at your own risk.
9 *
10 * Permission to use or copy this software for any purpose is hereby granted
11 * without fee. Permission to modify the code and to distribute modified
12 * code is also granted without any restrictions.
13 */
14
15#include <stdlib.h>
16#include <wchar.h>
17
18wchar_t *
19wcsdup(const wchar_t *str)
20{
21 wchar_t *copy;
22 size_t len;
23
24 len = wcslen(str) + 1;
25 copy = malloc(len * sizeof (wchar_t));
26
27 if (!copy)
28 return (NULL);
29
30 return (wmemcpy(copy, str, len));
31}