diff options
Diffstat (limited to 'src/lib/libc/string/wcsdup.3')
| -rw-r--r-- | src/lib/libc/string/wcsdup.3 | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/lib/libc/string/wcsdup.3 b/src/lib/libc/string/wcsdup.3 new file mode 100644 index 0000000000..588a2571db --- /dev/null +++ b/src/lib/libc/string/wcsdup.3 | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | .\" $OpenBSD: wcsdup.3,v 1.4 2011/07/25 00:38:53 schwarze Exp $ | ||
| 2 | .\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $ | ||
| 3 | .\" | ||
| 4 | .\" Copyright (c) 1990, 1991, 1993 | ||
| 5 | .\" The Regents of the University of California. All rights reserved. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer. | ||
| 12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 14 | .\" documentation and/or other materials provided with the distribution. | ||
| 15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
| 16 | .\" may be used to endorse or promote products derived from this software | ||
| 17 | .\" without specific prior written permission. | ||
| 18 | .\" | ||
| 19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 29 | .\" SUCH DAMAGE. | ||
| 30 | .\" | ||
| 31 | .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 | ||
| 32 | .\" | ||
| 33 | .Dd $Mdocdate: July 25 2011 $ | ||
| 34 | .Dt WCSDUP 3 | ||
| 35 | .Os | ||
| 36 | .Sh NAME | ||
| 37 | .Nm wcsdup | ||
| 38 | .Nd save a copy of a wide string | ||
| 39 | .Sh SYNOPSIS | ||
| 40 | .In wchar.h | ||
| 41 | .Ft wchar_t * | ||
| 42 | .Fn wcsdup "const wchar_t *str" | ||
| 43 | .Sh DESCRIPTION | ||
| 44 | The | ||
| 45 | .Fn wcsdup | ||
| 46 | function | ||
| 47 | allocates sufficient memory for a copy | ||
| 48 | of the wide-character string | ||
| 49 | .Fa str , | ||
| 50 | does the copy, and returns a pointer to it. | ||
| 51 | The pointer may subsequently be used as an | ||
| 52 | argument to the function | ||
| 53 | .Xr free 3 . | ||
| 54 | .Pp | ||
| 55 | If insufficient memory is available, | ||
| 56 | .Dv NULL | ||
| 57 | is returned. | ||
| 58 | .Sh EXAMPLES | ||
| 59 | The following will point | ||
| 60 | .Va p | ||
| 61 | to an allocated area of memory containing the nul-terminated string | ||
| 62 | .Qq foobar : | ||
| 63 | .Bd -literal -offset indent | ||
| 64 | const char *o = "foobar"; | ||
| 65 | wchar_t *p, b[32]; | ||
| 66 | size_t blen; | ||
| 67 | |||
| 68 | blen = sizeof(b) / sizeof(b[0]); | ||
| 69 | if (mbstowcs(b, o, blen) == (size_t)-1) | ||
| 70 | err(1, NULL); | ||
| 71 | b[blen - 1] = 0; | ||
| 72 | if ((p = wcsdup(b)) == NULL) | ||
| 73 | err(1, NULL); | ||
| 74 | .Ed | ||
| 75 | .Sh ERRORS | ||
| 76 | The | ||
| 77 | .Fn wcsdup | ||
| 78 | function may fail and set the external variable | ||
| 79 | .Va errno | ||
| 80 | for any of the errors specified for the library function | ||
| 81 | .Xr malloc 3 . | ||
| 82 | .Sh SEE ALSO | ||
| 83 | .Xr free 3 , | ||
| 84 | .Xr malloc 3 , | ||
| 85 | .Xr strdup 3 | ||
| 86 | .Sh STANDARDS | ||
| 87 | The | ||
| 88 | .Fn wcsdup | ||
| 89 | function conforms to | ||
| 90 | .St -p1003.1-2008 . | ||
| 91 | .Sh HISTORY | ||
| 92 | The | ||
| 93 | .Fn wcsdup | ||
| 94 | function was ported from | ||
| 95 | .Nx | ||
| 96 | and first appeared in | ||
| 97 | .Ox 5.0 . | ||
