]> granicus.if.org Git - strace/commitdiff
Allocate -o OUTFILE buffer only if needed
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 24 Jan 2012 10:31:51 +0000 (11:31 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 24 Jan 2012 10:50:04 +0000 (11:50 +0100)
   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 <vda.linux@googlemail.com>
strace.c

index 64e90e71b62197afb5244cdb3f43099d9c50d2c7..0da9afb09d71f793908f7d9524a9315203649e26 100644 (file)
--- 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) {