minix/lib/other/strdup.c

24 lines
231 B
C
Raw Normal View History

2005-07-11 15:06:27 +02:00
/*
lib/other/strdup.c
*/
#include <stdlib.h>
#include <string.h>
char *strdup(s1)
const char *s1;
{
size_t len;
char *s2;
len= strlen(s1)+1;
s2= malloc(len);
if (s2 == NULL)
return NULL;
strcpy(s2, s1);
return s2;
}