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:
parent
099bce7f5d
commit
2226064c52
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue