Minor refactor in strn_edup()

This commit is contained in:
Andrew Bettison 2013-11-28 17:45:32 +10:30
parent 1d14f43050
commit 16995f1041

6
mem.c
View File

@ -51,10 +51,8 @@ void *_emalloc_zero(struct __sourceloc __whence, size_t bytes)
char *_strn_edup(struct __sourceloc __whence, const char *str, size_t len)
{
char *new = _emalloc(__whence, len + 1);
if (new) {
strncpy(new, str, len);
new[len] = '\0';
}
if (new)
strncpy(new, str, len)[len] = '\0';
return new;
}