diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2017-05-16 22:22:49 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2017-05-16 22:22:49 +0530 |
commit | b817699b7f13ea78f00810d4be022de47e9e706d (patch) | |
tree | fad81d70531f3006f8f3ccb52fc906d516eb3aae | |
parent | 3243a3082ad807914e8bb0c434e0793cb02a1a5c (diff) | |
download | nnn-b817699b7f13ea78f00810d4be022de47e9e706d.tar.gz |
Home-grown xstrlcpy()
-rw-r--r-- | nnn.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -205,8 +205,9 @@ max_openfds() static void xstrlcpy(char *dest, const char *src, size_t n) { - strncpy(dest, src, n - 1); - dest[n - 1] = '\0'; + while (--n && (*dest++ = *src++)); + if (!n) + *dest = '\0'; } /* |