diff options
Diffstat (limited to 'src/lib/libc/string/strdup.3')
-rw-r--r-- | src/lib/libc/string/strdup.3 | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 index 60a7462777..05dcb794f0 100644 --- a/src/lib/libc/string/strdup.3 +++ b/src/lib/libc/string/strdup.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: strdup.3,v 1.15 2010/03/24 14:47:46 kettenis Exp $ | 1 | .\" $OpenBSD: strdup.3,v 1.16 2010/05/18 22:24:55 tedu Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 1990, 1991, 1993 | 3 | .\" Copyright (c) 1990, 1991, 1993 |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. |
@@ -29,16 +29,19 @@ | |||
29 | .\" | 29 | .\" |
30 | .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 | 30 | .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 |
31 | .\" | 31 | .\" |
32 | .Dd $Mdocdate: March 24 2010 $ | 32 | .Dd $Mdocdate: May 18 2010 $ |
33 | .Dt STRDUP 3 | 33 | .Dt STRDUP 3 |
34 | .Os | 34 | .Os |
35 | .Sh NAME | 35 | .Sh NAME |
36 | .Nm strdup | 36 | .Nm strdup , |
37 | .Nm strndup | ||
37 | .Nd save a copy of a string | 38 | .Nd save a copy of a string |
38 | .Sh SYNOPSIS | 39 | .Sh SYNOPSIS |
39 | .Fd #include <string.h> | 40 | .Fd #include <string.h> |
40 | .Ft char * | 41 | .Ft char * |
41 | .Fn strdup "const char *s" | 42 | .Fn strdup "const char *s" |
43 | .Ft char * | ||
44 | .Fn strndup "const char *s" "size_t maxlen" | ||
42 | .Sh DESCRIPTION | 45 | .Sh DESCRIPTION |
43 | The | 46 | The |
44 | .Fn strdup | 47 | .Fn strdup |
@@ -48,6 +51,16 @@ does the copy, and returns a pointer to it. | |||
48 | The pointer may subsequently be used as an argument to the function | 51 | The pointer may subsequently be used as an argument to the function |
49 | .Xr free 3 . | 52 | .Xr free 3 . |
50 | .Pp | 53 | .Pp |
54 | The | ||
55 | .Fn strndup | ||
56 | function behaves similarly to | ||
57 | .Nm strdup | ||
58 | but only copies up to | ||
59 | .Fa maxlen | ||
60 | characters from | ||
61 | .Fa s . | ||
62 | The resulting string is always NUL-terminated. | ||
63 | .Pp | ||
51 | If insufficient memory is available, | 64 | If insufficient memory is available, |
52 | .Dv NULL | 65 | .Dv NULL |
53 | is returned. | 66 | is returned. |
@@ -83,3 +96,15 @@ The | |||
83 | .Fn strdup | 96 | .Fn strdup |
84 | function first appeared in | 97 | function first appeared in |
85 | .Bx 4.4 . | 98 | .Bx 4.4 . |
99 | .Pp | ||
100 | The | ||
101 | .Fn strndup | ||
102 | function first appeared in | ||
103 | .Ox 4.8 . | ||
104 | .Sh STANDARDS | ||
105 | The | ||
106 | .Fn strdup | ||
107 | and | ||
108 | .Fn strndup | ||
109 | functions conform to | ||
110 | .St -p1003.1-2008 . | ||