mirror of
https://github.com/sheumann/hush.git
synced 2024-11-18 17:10:36 +00:00
find: code shrink
function old new delta func_exec 306 285 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
c472898eaa
commit
6885e49ba5
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user