148351Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California. 243483Sbostic.\" All rights reserved. 343483Sbostic.\" 443483Sbostic.\" %sccs.include.redist.man% 543483Sbostic.\" 6*56959Sbostic.\" @(#)strdup.3 5.4 (Berkeley) 12/02/92 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 . 29*56959Sbostic.Pp 30*56959SbosticIf 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 3748351Scaelfunction 3848351Scael.Ud . 39