← Commit list

6885e49ba

Denys Vlasenko
Denys Vlasenko
2014-02-26
SUCCESS Duration: 273s

Subject

find: code shrink

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

findutils/find.c+3 -5
@@ -420,12 +420,10 @@ static char* subst(const char *src, unsigned count, const char* filename)
size_t flen = strlen(filename);
/* we replace each '{}' with filename: growth by strlen-2 */
buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1);
- while ((end = strstr(src, "{}"))) {
- memcpy(dst, src, end - src);
- dst += end - src;
+ while ((end = strstr(src, "{}")) != NULL) {
+ dst = mempcpy(dst, src, end - src);
+ dst = mempcpy(dst, filename, flen);
src = end + 2;
- memcpy(dst, filename, flen);
- dst += flen;
}
strcpy(dst, src);
return buf;