diff options
Diffstat (limited to 'lib/libc/string/strdup.3')
-rw-r--r-- | lib/libc/string/strdup.3 | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3 index 6abbba57cb7..73c144d6e4c 100644 --- a/lib/libc/string/strdup.3 +++ b/lib/libc/string/strdup.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strdup.3,v 1.6 1998/08/19 05:51:14 pjanzen Exp $ +.\" $OpenBSD: strdup.3,v 1.7 1999/06/04 19:14:56 aaron Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -42,20 +42,32 @@ .Sh SYNOPSIS .Fd #include <string.h> .Ft char * -.Fn strdup "const char *str" +.Fn strdup "const char *s" .Sh DESCRIPTION The .Fn strdup function allocates sufficient memory for a copy of the string -.Fa str , +.Fa s , does the copy, and returns a pointer to it. The pointer may subsequently be used as an argument to the function .Xr free 3 . .Pp -If insufficient memory is available, NULL is returned. +If insufficient memory is available, +.Dv NULL +is returned. +.Sh EXAMPLES +The following will point +.Va p +to an allocated area of memory containing the null-terminated string +.Qq foobar : +.Bd -literal -offset indent +char *p; + +p = strdup("foobar"); +.Ed .Sh SEE ALSO .Xr free 3 , .Xr malloc 3 , |