lib: c: re-organise into separate static modules, plus a single shared library
This commit is contained in:
14
lib/libc/malloc/string/strdup.c
Normal file
14
lib/libc/malloc/string/strdup.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strdup(char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
char *out = malloc(len + 1);
|
||||
if (!out) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(out, s, len + 1);
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user