|
|
@ -1,4 +1,4 @@ |
|
|
|
.\" $OpenBSD: wcsdup.3,v 1.2 2011/07/05 19:01:31 nicm Exp $ |
|
|
|
.\" $OpenBSD: wcsdup.3,v 1.3 2011/07/08 17:46:45 nicm Exp $ |
|
|
|
.\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $ |
|
|
|
.\" |
|
|
|
.\" Copyright (c) 1990, 1991, 1993 |
|
|
@ -30,7 +30,7 @@ |
|
|
|
.\" |
|
|
|
.\" from: @(#)strdup.3 8.1 (Berkeley) 6/9/93 |
|
|
|
.\" |
|
|
|
.Dd $Mdocdate: July 5 2011 $ |
|
|
|
.Dd $Mdocdate: July 8 2011 $ |
|
|
|
.Dt WCSDUP 3 |
|
|
|
.Os |
|
|
|
.Sh NAME |
|
|
@ -61,9 +61,17 @@ The following will point |
|
|
|
to an allocated area of memory containing the nul-terminated string |
|
|
|
.Qq foobar : |
|
|
|
.Bd -literal -offset indent |
|
|
|
wchar_t *p; |
|
|
|
const char *o = "foobar"; |
|
|
|
wchar_t *p, b[32]; |
|
|
|
size_t blen; |
|
|
|
|
|
|
|
if ((p = wcsdup(L"foobar")) == NULL) { |
|
|
|
blen = sizeof(b) / sizeof(b[0]); |
|
|
|
if (mbstowcs(b, o, blen) == (size_t)-1) { |
|
|
|
fprintf(stderr, "Failed to convert string.\en"); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
b[blen - 1] = 0; |
|
|
|
if ((p = wcsdup(b)) == NULL) { |
|
|
|
fprintf(stderr, "Out of memory.\en"); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|