xref: /original-bsd/lib/libc/string/strdup.3 (revision 3705696b)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)strdup.3	8.1 (Berkeley) 06/09/93
7.\"
8.Dd
9.Dt STRDUP 3
10.Os
11.Sh NAME
12.Nm strdup
13.Nd save a copy of a string
14.Sh SYNOPSIS
15.Fd #include <string.h>
16.Ft char *
17.Fn strdup "const char *str"
18.Sh DESCRIPTION
19The
20.Fn strdup
21function
22allocates sufficient memory for a copy
23of the string
24.Fa str ,
25does the copy, and returns a pointer to it.
26The pointer may subsequently be used as an
27argument to the function
28.Xr free 3 .
29.Pp
30If insufficient memory is available, NULL is returned.
31.Sh SEE ALSO
32.Xr malloc 3
33.Xr free 3
34.Sh HISTORY
35The
36.Fn strdup
37function first appeared in 4.4BSD.
38