From 692a4502b0205f083855a102f906e206733b5b93 Mon Sep 17 00:00:00 2001 From: John Beppu Date: Wed, 8 Mar 2000 00:14:35 +0000 Subject: [PATCH] + changed a static array (FileList) into a dynamically allocated one in an attempt to make the .bss section smaller. --- coreutils/tee.c | 11 +++++++++-- tee.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/coreutils/tee.c b/coreutils/tee.c index 2f746f96d..a3a1c8132 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c @@ -23,6 +23,7 @@ */ #include "internal.h" +#include #include static const char tee_usage[] = @@ -38,7 +39,7 @@ static const char tee_usage[] = /* FileList _______________________________________________________________ */ #define FL_MAX 1024 -static FILE *FileList[FL_MAX]; +static FILE **FileList; static int FL_end; typedef void (FL_Function) (FILE * file, char c); @@ -99,6 +100,11 @@ int tee_main(int argc, char **argv) } /* init FILE pointers */ + FileList = calloc(FL_MAX, sizeof(FILE*)); + if (!FileList) { + fprintf(stderr, "tee: %s\n", strerror(errno)); + exit(1); + } FL_end = 0; FileList[0] = stdout; for (; i < argc; i++) { @@ -119,7 +125,8 @@ int tee_main(int argc, char **argv) /* clean up */ FL_apply(tee_fclose, 0); + free(FileList); exit(0); } -/* $Id: tee.c,v 1.6 2000/02/08 19:58:47 erik Exp $ */ +/* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ diff --git a/tee.c b/tee.c index 2f746f96d..a3a1c8132 100644 --- a/tee.c +++ b/tee.c @@ -23,6 +23,7 @@ */ #include "internal.h" +#include #include static const char tee_usage[] = @@ -38,7 +39,7 @@ static const char tee_usage[] = /* FileList _______________________________________________________________ */ #define FL_MAX 1024 -static FILE *FileList[FL_MAX]; +static FILE **FileList; static int FL_end; typedef void (FL_Function) (FILE * file, char c); @@ -99,6 +100,11 @@ int tee_main(int argc, char **argv) } /* init FILE pointers */ + FileList = calloc(FL_MAX, sizeof(FILE*)); + if (!FileList) { + fprintf(stderr, "tee: %s\n", strerror(errno)); + exit(1); + } FL_end = 0; FileList[0] = stdout; for (; i < argc; i++) { @@ -119,7 +125,8 @@ int tee_main(int argc, char **argv) /* clean up */ FL_apply(tee_fclose, 0); + free(FileList); exit(0); } -/* $Id: tee.c,v 1.6 2000/02/08 19:58:47 erik Exp $ */ +/* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ -- 2.25.1