From: Denys Vlasenko Date: Tue, 24 Jan 2012 10:31:51 +0000 (+0100) Subject: Allocate -o OUTFILE buffer only if needed X-Git-Tag: v4.7~200 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a677da5e3f25107d4402c1c917d019f2d0bc9f29;p=strace Allocate -o OUTFILE buffer only if needed text data bss dec hex filename 238258 668 28676 267602 41552 strace.before 238274 668 20484 259426 3f562 strace * strace.c (main): Allocate -o OUTFILE buffer only if needed: unused buffer in bss is not entirely free. Signed-off-by: Denys Vlasenko --- diff --git a/strace.c b/strace.c index 64e90e71..0da9afb0 100644 --- a/strace.c +++ b/strace.c @@ -1182,7 +1182,9 @@ main(int argc, char *argv[]) } if (!outfname || outfname[0] == '|' || outfname[0] == '!') { - static char buf[BUFSIZ]; + char *buf = malloc(BUFSIZ); + if (!buf) + die_out_of_memory(); setvbuf(outf, buf, _IOLBF, BUFSIZ); } if (outfname && optind < argc) {