summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strdup.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/string/strdup.3')
-rw-r--r--src/lib/libc/string/strdup.320
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
47The 47The
48.Fn strdup 48.Fn strdup
49function 49function
50allocates sufficient memory for a copy 50allocates sufficient memory for a copy
51of the string 51of the string
52.Fa str , 52.Fa s ,
53does the copy, and returns a pointer to it. 53does the copy, and returns a pointer to it.
54The pointer may subsequently be used as an 54The pointer may subsequently be used as an
55argument to the function 55argument to the function
56.Xr free 3 . 56.Xr free 3 .
57.Pp 57.Pp
58If insufficient memory is available, NULL is returned. 58If insufficient memory is available,
59.Dv NULL
60is returned.
61.Sh EXAMPLES
62The following will point
63.Va p
64to an allocated area of memory containing the null-terminated string
65.Qq foobar :
66.Bd -literal -offset indent
67char *p;
68
69p = 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 ,