uniLoader/lib/string/strdup_r.c
Ivaylo Ivanov a1be36ae02 EXPERIMENTAL: Partially implement NewLib
Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
2023-07-19 19:37:17 +03:00

17 lines
281 B
C

#include <reent.h>
#include <stdlib.h>
#include <string.h>
char *
_strdup_r (struct _reent *reent_ptr,
const char *str)
{
size_t len = strlen (str) + 1;
char *copy = _malloc_r (reent_ptr, len);
if (copy)
{
memcpy (copy, str, len);
}
return copy;
}