aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-27 08:25:13 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-04-27 08:25:13 +0530
commitf1a9446b99b903bae8c115447eadd25691205054 (patch)
tree6de2dab206e1eb05be3d63e860185317b020db6d
parent187750556c9b8770cb335978674383c4bfbcb5b5 (diff)
downloadnnn-f1a9446b99b903bae8c115447eadd25691205054.tar.gz
Use mem* function
-rw-r--r--src/nnn.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 97a18ff..79f4f07 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1038,6 +1038,7 @@ static char *abspath(const char *path, const char *cwd)
return NULL;
size_t dst_size = 0, src_size = xstrlen(path), cwd_size = xstrlen(cwd);
+ size_t len = src_size;
const char *src;
char *dst;
/*
@@ -1058,7 +1059,7 @@ static char *abspath(const char *path, const char *cwd)
src = path;
dst = resolved_path + dst_size;
for (const char *next = NULL; next != path + src_size;) {
- next = strchr(src, '/');
+ next = memchr(src, '/', len);
if (!next)
next = path + src_size;
@@ -1076,6 +1077,7 @@ static char *abspath(const char *path, const char *cwd)
}
src = next + 1;
+ len = src_size - (src - path);
}
if (*resolved_path == '\0') {