From 43e0677c6de891c184da4ec66a03005d0824d5d0 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 2 Apr 2021 09:55:15 +0900 Subject: Fill the ring-buffer with the fallback value Fill with the pointer to the root position, instead of zero and comparing later. Also suppress a false warning by Visual C++. ``` file.c(4759): warning C4090: 'function': different 'const' qualifiers ``` --- file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index e8e4b1d541..6e6dfbca17 100644 --- a/file.c +++ b/file.c @@ -4756,7 +4756,7 @@ rb_file_dirname_n(VALUE fname, int n) break; default: seps = ALLOCV_N(const char *, sepsv, n); - MEMZERO(seps, const char *, n); + for (i = 0; i < n; ++i) seps[i] = root; i = 0; for (p = root; p < end; ) { if (isdirsep(*p)) { @@ -4772,7 +4772,6 @@ rb_file_dirname_n(VALUE fname, int n) } p = seps[i]; ALLOCV_END(sepsv); - if (!p) p = root; break; } } -- cgit v1.2.3