home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
c
/
strdup
< prev
next >
Wrap
Text File
|
1994-03-08
|
639b
|
41 lines
#ifdef __STDC__
static char sccs_id[] = "@(#) strdup.c 1.0 " __DATE__ " HJR";
#else
static char sccs_id[] = "@(#) strdup.c 1.0 8/11/91 HJR";
#endif
/* strdup.c (c) Copyright 1990 H.Rogers */
#ifndef __STDC__
#include "sys/types.h"
#endif
#include <string.h>
#ifdef ARCH
#include "sys/unix.h"
#else
#include <stdlib.h>
#endif
#ifdef __STDC__
char *
strdup (register const char *s1)
#else
char *
strdup (s)
register const char *s1;
#endif
{
#ifdef ARCH
return (__permstr (s1));
#else
register int i = strlen (s1) + 1;
register char *s2;
if (!(s2 = malloc (i)))
return (0);
memcpy (s2, s1, i);
return (s2);
#endif
}