| 1 | .\" Copyright (c) 1990 The Regents of the University of California. |
| 2 | .\" All rights reserved. |
| 3 | .\" |
| 4 | .\" %sccs.include.redist.man% |
| 5 | .\" |
| 6 | .\" @(#)strdup.3 5.1 (Berkeley) %G% |
| 7 | .\" |
| 8 | .TH STRDUP 3 "" |
| 9 | .UC 7 |
| 10 | .SH NAME |
| 11 | strdup \- save a copy of a string |
| 12 | .SH SYNOPSIS |
| 13 | .nf |
| 14 | .ft B |
| 15 | #include <string.h> |
| 16 | |
| 17 | char * |
| 18 | strdup(const char *str); |
| 19 | .ft R |
| 20 | .fi |
| 21 | .SH DESCRIPTION |
| 22 | .I Strdup |
| 23 | allocates sufficient memory for a copy of the string |
| 24 | .IR str , |
| 25 | does the copy, and returns a pointer to it. |
| 26 | The pointer may subsequently be used as an argument to the function |
| 27 | .IR free (3). |
| 28 | .PP |
| 29 | .I Strdup |
| 30 | returns NULL if unable to allocate the necessary memory. |
| 31 | .SH SEE ALSO |
| 32 | malloc(3) |