summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/string/wcsdup.316
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/libc/string/wcsdup.3 b/src/lib/libc/string/wcsdup.3
index 4d29ac218f..6588f14988 100644
--- a/src/lib/libc/string/wcsdup.3
+++ b/src/lib/libc/string/wcsdup.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: wcsdup.3,v 1.2 2011/07/05 19:01:31 nicm Exp $ 1.\" $OpenBSD: wcsdup.3,v 1.3 2011/07/08 17:46:45 nicm Exp $
2.\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $ 2.\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $
3.\" 3.\"
4.\" Copyright (c) 1990, 1991, 1993 4.\" Copyright (c) 1990, 1991, 1993
@@ -30,7 +30,7 @@
30.\" 30.\"
31.\" from: @(#)strdup.3 8.1 (Berkeley) 6/9/93 31.\" from: @(#)strdup.3 8.1 (Berkeley) 6/9/93
32.\" 32.\"
33.Dd $Mdocdate: July 5 2011 $ 33.Dd $Mdocdate: July 8 2011 $
34.Dt WCSDUP 3 34.Dt WCSDUP 3
35.Os 35.Os
36.Sh NAME 36.Sh NAME
@@ -61,9 +61,17 @@ The following will point
61to an allocated area of memory containing the nul-terminated string 61to an allocated area of memory containing the nul-terminated string
62.Qq foobar : 62.Qq foobar :
63.Bd -literal -offset indent 63.Bd -literal -offset indent
64wchar_t *p; 64const char *o = "foobar";
65wchar_t *p, b[32];
66size_t blen;
65 67
66if ((p = wcsdup(L"foobar")) == NULL) { 68blen = sizeof(b) / sizeof(b[0]);
69if (mbstowcs(b, o, blen) == (size_t)-1) {
70 fprintf(stderr, "Failed to convert string.\en");
71 exit(1);
72}
73b[blen - 1] = 0;
74if ((p = wcsdup(b)) == NULL) {
67 fprintf(stderr, "Out of memory.\en"); 75 fprintf(stderr, "Out of memory.\en");
68 exit(1); 76 exit(1);
69} 77}