diff options
| author | beppu <beppu@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-03-08 00:14:35 +0000 |
|---|---|---|
| committer | beppu <beppu@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-03-08 00:14:35 +0000 |
| commit | b539892e40d359fb3ac8725737361cfc2faeb082 (patch) | |
| tree | 5d90a36636f2c32495999c499808bb80ee0d58d2 | |
| parent | 39b1e70bfab085a5fbc825731cb094e492c359b3 (diff) | |
| download | busybox-w32-b539892e40d359fb3ac8725737361cfc2faeb082.tar.gz busybox-w32-b539892e40d359fb3ac8725737361cfc2faeb082.tar.bz2 busybox-w32-b539892e40d359fb3ac8725737361cfc2faeb082.zip | |
+ changed a static array (FileList) into a dynamically allocated one
in an attempt to make the .bss section smaller.
git-svn-id: svn://busybox.net/trunk/busybox@398 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | coreutils/tee.c | 11 | ||||
| -rw-r--r-- | 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 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include "internal.h" | 25 | #include "internal.h" |
| 26 | #include <errno.h> | ||
| 26 | #include <stdio.h> | 27 | #include <stdio.h> |
| 27 | 28 | ||
| 28 | static const char tee_usage[] = | 29 | static const char tee_usage[] = |
| @@ -38,7 +39,7 @@ static const char tee_usage[] = | |||
| 38 | /* FileList _______________________________________________________________ */ | 39 | /* FileList _______________________________________________________________ */ |
| 39 | 40 | ||
| 40 | #define FL_MAX 1024 | 41 | #define FL_MAX 1024 |
| 41 | static FILE *FileList[FL_MAX]; | 42 | static FILE **FileList; |
| 42 | static int FL_end; | 43 | static int FL_end; |
| 43 | 44 | ||
| 44 | typedef void (FL_Function) (FILE * file, char c); | 45 | typedef void (FL_Function) (FILE * file, char c); |
| @@ -99,6 +100,11 @@ int tee_main(int argc, char **argv) | |||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | /* init FILE pointers */ | 102 | /* init FILE pointers */ |
| 103 | FileList = calloc(FL_MAX, sizeof(FILE*)); | ||
| 104 | if (!FileList) { | ||
| 105 | fprintf(stderr, "tee: %s\n", strerror(errno)); | ||
| 106 | exit(1); | ||
| 107 | } | ||
| 102 | FL_end = 0; | 108 | FL_end = 0; |
| 103 | FileList[0] = stdout; | 109 | FileList[0] = stdout; |
| 104 | for (; i < argc; i++) { | 110 | for (; i < argc; i++) { |
| @@ -119,7 +125,8 @@ int tee_main(int argc, char **argv) | |||
| 119 | 125 | ||
| 120 | /* clean up */ | 126 | /* clean up */ |
| 121 | FL_apply(tee_fclose, 0); | 127 | FL_apply(tee_fclose, 0); |
| 128 | free(FileList); | ||
| 122 | exit(0); | 129 | exit(0); |
| 123 | } | 130 | } |
| 124 | 131 | ||
| 125 | /* $Id: tee.c,v 1.6 2000/02/08 19:58:47 erik Exp $ */ | 132 | /* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ |
| @@ -23,6 +23,7 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include "internal.h" | 25 | #include "internal.h" |
| 26 | #include <errno.h> | ||
| 26 | #include <stdio.h> | 27 | #include <stdio.h> |
| 27 | 28 | ||
| 28 | static const char tee_usage[] = | 29 | static const char tee_usage[] = |
| @@ -38,7 +39,7 @@ static const char tee_usage[] = | |||
| 38 | /* FileList _______________________________________________________________ */ | 39 | /* FileList _______________________________________________________________ */ |
| 39 | 40 | ||
| 40 | #define FL_MAX 1024 | 41 | #define FL_MAX 1024 |
| 41 | static FILE *FileList[FL_MAX]; | 42 | static FILE **FileList; |
| 42 | static int FL_end; | 43 | static int FL_end; |
| 43 | 44 | ||
| 44 | typedef void (FL_Function) (FILE * file, char c); | 45 | typedef void (FL_Function) (FILE * file, char c); |
| @@ -99,6 +100,11 @@ int tee_main(int argc, char **argv) | |||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | /* init FILE pointers */ | 102 | /* init FILE pointers */ |
| 103 | FileList = calloc(FL_MAX, sizeof(FILE*)); | ||
| 104 | if (!FileList) { | ||
| 105 | fprintf(stderr, "tee: %s\n", strerror(errno)); | ||
| 106 | exit(1); | ||
| 107 | } | ||
| 102 | FL_end = 0; | 108 | FL_end = 0; |
| 103 | FileList[0] = stdout; | 109 | FileList[0] = stdout; |
| 104 | for (; i < argc; i++) { | 110 | for (; i < argc; i++) { |
| @@ -119,7 +125,8 @@ int tee_main(int argc, char **argv) | |||
| 119 | 125 | ||
| 120 | /* clean up */ | 126 | /* clean up */ |
| 121 | FL_apply(tee_fclose, 0); | 127 | FL_apply(tee_fclose, 0); |
| 128 | free(FileList); | ||
| 122 | exit(0); | 129 | exit(0); |
| 123 | } | 130 | } |
| 124 | 131 | ||
| 125 | /* $Id: tee.c,v 1.6 2000/02/08 19:58:47 erik Exp $ */ | 132 | /* $Id: tee.c,v 1.7 2000/03/08 00:14:35 beppu Exp $ */ |
