home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixtools
/
util
/
c
/
strdup
< prev
next >
Wrap
Text File
|
1992-07-21
|
355b
|
17 lines
/* > C.Strdup - save a string on the heap; return pointer to it */
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include "utils.h"
char *strdup (const char *str)
{
char *p = malloc(strlen(str)+1);
if ( p == NULL )
fatal(1,"Not enough memory to save string\n");
return (strcpy(p,str));
}