nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f8ee991254567ad597a281047e8b63551b6731b5
parent d49ddd1331d5b9c4b7fbfda5e2571cd730d0724c
Author: NRK <nrk@disroot.org>
Date:   Tue,  9 Aug 2022 03:01:30 +0600

xstrdup: use memcpy

the length is already known, so memcpy should be faster than xstrsncpy.

Diffstat:
Msrc/nnn.c | 5+----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -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)