mirror of
https://github.com/drasko/codezero.git
synced 2026-04-16 08:49:05 +02:00
Initial commit
This commit is contained in:
15
libs/c/src/strdup.c
Normal file
15
libs/c/src/strdup.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#define _USE_XOPEN
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char *
|
||||
strdup(const char *s)
|
||||
{
|
||||
int len = strlen(s);
|
||||
char *d;
|
||||
d = malloc(len);
|
||||
if (d == NULL)
|
||||
return NULL;
|
||||
strcpy(d, s);
|
||||
return d;
|
||||
}
|
||||
Reference in New Issue
Block a user