Moving the malloc out of loop will make leak to disappear, and the command might run few jiffie quicker when there are 1+N arguments. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- text-utils/rev.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/text-utils/rev.c b/text-utils/rev.c index 31004a0..76a3620 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -107,6 +107,8 @@ int main(int argc, char *argv[]) argc -= optind; argv += optind; + buf = xmalloc(bufsiz * sizeof(wchar_t)); + do { if (*argv) { if ((fp = fopen(*argv, "r")) == NULL) { @@ -118,8 +120,6 @@ int main(int argc, char *argv[]) filename = *argv++; } - buf = xmalloc(bufsiz * sizeof(wchar_t)); - while (fgetws(buf, bufsiz, fp)) { len = wcslen(buf); -- 1.7.4.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html