Files
libretiny/cores/common/base/posix/strdup.c
2023-03-04 11:09:27 +01:00

14 lines
296 B
C

/* Copyright (c) Kuba Szczodrzyński 2022-05-16. */
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
__attribute__((weak)) char *strdup(const char *s) {
size_t len = strlen(s) + 1;
void *newp = malloc(len);
if (newp == NULL)
return NULL;
return (char *)memcpy(newp, s, len);
}