xref: /csrg-svn/lib/libc/string/strdup.3 (revision 48351)
1*48351Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
243483Sbostic.\" All rights reserved.
343483Sbostic.\"
443483Sbostic.\" %sccs.include.redist.man%
543483Sbostic.\"
6*48351Scael.\"     @(#)strdup.3	5.3 (Berkeley) 04/19/91
743483Sbostic.\"
8*48351Scael.Dd
9*48351Scael.Dt STRDUP 3
10*48351Scael.Os
11*48351Scael.Sh NAME
12*48351Scael.Nm strdup
13*48351Scael.Nd save a copy of a string
14*48351Scael.Sh SYNOPSIS
15*48351Scael.Fd #include <string.h>
16*48351Scael.Ft char *
17*48351Scael.Fn strdup "const char *str"
18*48351Scael.Sh DESCRIPTION
19*48351ScaelThe
20*48351Scael.Fn strdup
21*48351Scaelfunction
22*48351Scaelallocates sufficient memory for a copy
23*48351Scaelof the string
24*48351Scael.Fa str ,
2543483Sbosticdoes the copy, and returns a pointer to it.
26*48351ScaelThe pointer may subsequently be used as an
27*48351Scaelargument to the function
28*48351Scael.Xr free 3 .
29*48351Scael.Sh SEE ALSO
30*48351Scael.Xr calloc 3
31*48351Scael.Xr malloc 3
32*48351Scael.Xr realloc 3
33*48351Scael.Xr free 3
34*48351Scael.Sh HISTORY
35*48351ScaelThe
36*48351Scael.Fn strdup
37*48351Scaelfunction
38*48351Scael.Ud .
39