X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=archival%2Fgzip.c;h=91b2948917f5658b6ecce5411b5ae3f86711cfd2;hb=768945b762b8850691acd2b63116eed18faa1812;hp=41ed3a2c7c0fabbb6731a66966d969c51c88aaae;hpb=c57ec37959390ff2e43faa5e4dd5281b2923ced3;p=oweals%2Fbusybox.git diff --git a/archival/gzip.c b/archival/gzip.c index 41ed3a2c7..91b294891 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -16,11 +16,7 @@ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */ -/* These defines are very important for BusyBox. Without these, - * huge chunks of ram are pre-allocated making the BusyBox bss - * size Freaking Huge(tm), which is a bad thing.*/ #define SMALL_MEM -#define DYN_ALLOC #include #include @@ -87,17 +83,11 @@ typedef unsigned long ulg; # endif #endif -#ifdef DYN_ALLOC # define DECLARE(type, array, size) static type * array # define ALLOC(type, array, size) { \ - array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ + array = (type*)xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type)); \ } # define FREE(array) {free(array), array=NULL;} -#else -# define DECLARE(type, array, size) static type array[size] -# define ALLOC(type, array, size) -# define FREE(array) -#endif #define tab_suffix window #define tab_prefix prev /* hash link (see deflate.c) */ @@ -334,7 +324,7 @@ static void write_buf(int fd, void *buf, unsigned cnt) unsigned n; while ((n = write(fd, buf, cnt)) != cnt) { - if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write"); + if (n == (unsigned) (-1)) bb_error_msg_and_die(bb_msg_write_error); cnt -= n; buf = (void *) ((char *) buf + n); } @@ -1228,8 +1218,8 @@ int gzip_main(int argc, char **argv) inFileNum = STDIN_FILENO; outFileNum = STDOUT_FILENO; } else { - inFileNum = open(argv[i], O_RDONLY); - if (inFileNum < 0 || fstat(inFileNum, &statBuf) < 0) + inFileNum = bb_xopen3(argv[i], O_RDONLY, 0); + if (fstat(inFileNum, &statBuf) < 0) bb_perror_msg_and_die("%s", argv[i]); time_stamp = statBuf.st_ctime; ifile_size = statBuf.st_size;