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>
This commit is contained in:
Sami Kerola 2011-04-02 18:11:08 +02:00 committed by Karel Zak
parent 099bce7f5d
commit 2226064c52
1 changed files with 2 additions and 2 deletions

View File

@ -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);