xref: /csrg-svn/lib/libc/string/strdup.3 (revision 62917)
1*62917Sbostic.\" Copyright (c) 1990, 1991, 1993
2*62917Sbostic.\"	The Regents of the University of California.  All rights reserved.
343483Sbostic.\"
443483Sbostic.\" %sccs.include.redist.man%
543483Sbostic.\"
6*62917Sbostic.\"     @(#)strdup.3	8.1 (Berkeley) 06/09/93
743483Sbostic.\"
848351Scael.Dd
948351Scael.Dt STRDUP 3
1048351Scael.Os
1148351Scael.Sh NAME
1248351Scael.Nm strdup
1348351Scael.Nd save a copy of a string
1448351Scael.Sh SYNOPSIS
1548351Scael.Fd #include <string.h>
1648351Scael.Ft char *
1748351Scael.Fn strdup "const char *str"
1848351Scael.Sh DESCRIPTION
1948351ScaelThe
2048351Scael.Fn strdup
2148351Scaelfunction
2248351Scaelallocates sufficient memory for a copy
2348351Scaelof the string
2448351Scael.Fa str ,
2543483Sbosticdoes the copy, and returns a pointer to it.
2648351ScaelThe pointer may subsequently be used as an
2748351Scaelargument to the function
2848351Scael.Xr free 3 .
2956959Sbostic.Pp
3056959SbosticIf insufficient memory is available, NULL is returned.
3148351Scael.Sh SEE ALSO
3248351Scael.Xr malloc 3
3348351Scael.Xr free 3
3448351Scael.Sh HISTORY
3548351ScaelThe
3648351Scael.Fn strdup
3762916Sbosticfunction first appeared in 4.4BSD.
38