summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/strdup.3
diff options
context:
space:
mode:
authoraaron <aaron@openbsd.org>1999-06-04 19:14:55 +0000
committeraaron <aaron@openbsd.org>1999-06-04 19:14:55 +0000
commit828c488475bdafe8acf9260723b3b46d4a8cbc9d (patch)
tree2dfd7638a87c304a1a3721cc2e44492a07491dee /lib/libc/string/strdup.3
parentadd examples (diff)
downloadwireguard-openbsd-828c488475bdafe8acf9260723b3b46d4a8cbc9d.tar.xz
wireguard-openbsd-828c488475bdafe8acf9260723b3b46d4a8cbc9d.zip
some repairs, add example to strdup(3) page
Diffstat (limited to 'lib/libc/string/strdup.3')
-rw-r--r--lib/libc/string/strdup.320
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 ,