mirror of
https://github.com/vivier/EMILE.git
synced 2025-02-25 08:28:59 +00:00
add strdup()
This commit is contained in:
parent
d8bc6db8f5
commit
7a9f9c00e7
@ -12,7 +12,7 @@ LIBRARY = libunix.a
|
||||
SOURCES = divsi3.S modsi3.S mulsi3.S udivsi3.S umodsi3.S free.c malloc.c \
|
||||
memcpy.c memset.c printf.c putchar.c puts.c read.c sprintf.c \
|
||||
strcpy.c strlen.c strncpy.c vsprintf.c write.c strcmp.c \
|
||||
strncmp.c strtol.c
|
||||
strncmp.c strtol.c strdup.c
|
||||
|
||||
HEADERS =
|
||||
|
||||
|
20
libunix/strdup.c
Normal file
20
libunix/strdup.c
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004,2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strdup (__const char *__restrict __src)
|
||||
{
|
||||
char *__dest;
|
||||
|
||||
__dest = (char*)malloc(strlen(__src) + 1);
|
||||
if (__dest == NULL)
|
||||
return NULL;
|
||||
strcpy(__dest, __src);
|
||||
|
||||
return __dest;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user