14 lines
296 B
C
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);
|
|
}
|