xref: /original-bsd/lib/libc/string/strdup.3 (revision 044d1bee)
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)strdup.3	5.4 (Berkeley) 12/02/92
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
38.Ud .
39