Merge pull request #1461 from N-R-K/xstrdup_memcpy

xstrdup: use memcpy
This commit is contained in:
Arun 2022-08-16 19:07:21 +05:30 committed by GitHub
commit 340ba19098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -985,10 +985,7 @@ static char *xstrdup(const char *restrict s)
{
size_t len = xstrlen(s) + 1;
char *ptr = malloc(len);
if (ptr)
xstrsncpy(ptr, s, len);
return ptr;
return ptr ? memcpy(ptr, s, len) : NULL;
}
static bool is_suffix(const char *restrict str, const char *restrict suffix)