diff options
author | Sami Kerola | 2011-04-02 18:11:08 +0200 |
---|---|---|
committer | Karel Zak | 2011-04-06 10:45:02 +0200 |
commit | 2226064c52af6ae5d5c8871056aede10a7d14b97 (patch) | |
tree | 40b65f1022660ed1f9c3c211ccc4ea5db2ac23bb /text-utils | |
parent | rev: use xrealloc from xalloc.h (diff) | |
download | kernel-qcow2-util-linux-2226064c52af6ae5d5c8871056aede10a7d14b97.tar.gz kernel-qcow2-util-linux-2226064c52af6ae5d5c8871056aede10a7d14b97.tar.xz kernel-qcow2-util-linux-2226064c52af6ae5d5c8871056aede10a7d14b97.zip |
rev: memory leak fix
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@iki.fi>
Diffstat (limited to 'text-utils')
-rw-r--r-- | 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 31004a070..76a362030 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); |