diff options
author | Jim Meyering <jim@meyering.net> | 2003-11-12 09:23:03 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-11-12 09:23:03 +0000 |
commit | 9bdd30ba17f6a2490c670e121395a70abcca7233 (patch) | |
tree | 407adf2cc0f9de19cc31f57d8e30794f0228f449 | |
parent | b15ebcd4a7910d49180f0733b26c161edd6e175e (diff) | |
download | coreutils-9bdd30ba17f6a2490c670e121395a70abcca7233.tar.xz |
(extract_dirs_from_files): Avoid useless copy operations.
This avoids a warning valgrind about memcpy with overlapping
source and destination.
-rw-r--r-- | src/ls.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -2582,8 +2582,14 @@ extract_dirs_from_files (const char *dirname, int ignore_dot_and_dot_dot) entries. */ for (i = 0, j = 0; i < files_index; i++) - if (files[i].filetype != arg_directory) - files[j++] = files[i]; + { + if (files[i].filetype != arg_directory) + { + if (j < i) + files[j] = files[i]; + ++j; + } + } files_index = j; } |