diff options
author | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-06-04 19:14:57 +0000 |
---|---|---|
committer | Aaron Campbell <aaron@cvs.openbsd.org> | 1999-06-04 19:14:57 +0000 |
commit | ea3aa758f0613eb4538aa90000b1fefafcdc6976 (patch) | |
tree | 6c58fae8633b1642bfe1f4b5f0ea28f071694465 /lib/libc/string/strdup.3 | |
parent | e288cb3c3b2f3f37b0ec44648cf15b3ce1fa3299 (diff) |
some repairs, add example to strdup(3) page
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 , |