diff options
Diffstat (limited to 'src/lib/libc/string/strdup.3')
-rw-r--r-- | src/lib/libc/string/strdup.3 | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 index 6abbba57cb..73c144d6e4 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.6 1998/08/19 05:51:14 pjanzen Exp $ | 1 | .\" $OpenBSD: strdup.3,v 1.7 1999/06/04 19:14:56 aaron 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. |
@@ -42,20 +42,32 @@ | |||
42 | .Sh SYNOPSIS | 42 | .Sh SYNOPSIS |
43 | .Fd #include <string.h> | 43 | .Fd #include <string.h> |
44 | .Ft char * | 44 | .Ft char * |
45 | .Fn strdup "const char *str" | 45 | .Fn strdup "const char *s" |
46 | .Sh DESCRIPTION | 46 | .Sh DESCRIPTION |
47 | The | 47 | The |
48 | .Fn strdup | 48 | .Fn strdup |
49 | function | 49 | function |
50 | allocates sufficient memory for a copy | 50 | allocates sufficient memory for a copy |
51 | of the string | 51 | of the string |
52 | .Fa str , | 52 | .Fa s , |
53 | does the copy, and returns a pointer to it. | 53 | does the copy, and returns a pointer to it. |
54 | The pointer may subsequently be used as an | 54 | The pointer may subsequently be used as an |
55 | argument to the function | 55 | argument to the function |
56 | .Xr free 3 . | 56 | .Xr free 3 . |
57 | .Pp | 57 | .Pp |
58 | If insufficient memory is available, NULL is returned. | 58 | If insufficient memory is available, |
59 | .Dv NULL | ||
60 | is returned. | ||
61 | .Sh EXAMPLES | ||
62 | The following will point | ||
63 | .Va p | ||
64 | to an allocated area of memory containing the null-terminated string | ||
65 | .Qq foobar : | ||
66 | .Bd -literal -offset indent | ||
67 | char *p; | ||
68 | |||
69 | p = strdup("foobar"); | ||
70 | .Ed | ||
59 | .Sh SEE ALSO | 71 | .Sh SEE ALSO |
60 | .Xr free 3 , | 72 | .Xr free 3 , |
61 | .Xr malloc 3 , | 73 | .Xr malloc 3 , |