projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace current verbose GPL stuff in libbb/*.c with one-line GPL boilerplate.
[oweals/busybox.git]
/
archival
/
gzip.c
diff --git
a/archival/gzip.c
b/archival/gzip.c
index 41ed3a2c7c0fabbb6731a66966d969c51c88aaae..486f78f887db1e6ae2cb8eaf1f7614ec6d237b93 100644
(file)
--- 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.
*/
* 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 SMALL_MEM
-#define DYN_ALLOC
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
@@
-87,17
+83,11
@@
typedef unsigned long ulg;
# endif
#endif
# endif
#endif
-#ifdef DYN_ALLOC
# define DECLARE(type, array, size) static type * array
# define ALLOC(type, array, size) { \
# define DECLARE(type, array, size) static type * array
# define ALLOC(type, array, size) { \
- array = (type*)x
calloc((size_t)(((size)+1L)/2),
2*sizeof(type)); \
+ array = (type*)x
zalloc((size_t)(((size)+1L)/2) *
2*sizeof(type)); \
}
# define FREE(array) {free(array), array=NULL;}
}
# 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) */
#define tab_suffix window
#define tab_prefix prev /* hash link (see deflate.c) */
@@
-154,15
+144,6
@@
typedef int file_t; /* Do not use stdio */
#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\
flush_outbuf();}
#define put_byte(c) {outbuf[outcnt++]=(uch)(c); if (outcnt==OUTBUFSIZ)\
flush_outbuf();}
-
-/* Output a 32 bit value to the bit stream, lsb first */
-#if 0
-#define put_long(n) { \
- put_short((n) & 0xffff); \
- put_short(((ulg)(n)) >> 16); \
-}
-#endif
-
#define seekable() 0 /* force sequential output */
#define translate_eol 0 /* no option -a yet */
#define seekable() 0 /* force sequential output */
#define translate_eol 0 /* no option -a yet */
@@
-334,7
+315,7
@@
static void write_buf(int fd, void *buf, unsigned cnt)
unsigned n;
while ((n = write(fd, buf, cnt)) != 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);
}
cnt -= n;
buf = (void *) ((char *) buf + n);
}
@@
-494,7
+475,7
@@
static void send_bits(int value, int length)
*/
static unsigned bi_reverse(unsigned code, int len)
{
*/
static unsigned bi_reverse(unsigned code, int len)
{
-
register
unsigned res = 0;
+ unsigned res = 0;
do {
res |= code & 1;
do {
res |= code & 1;
@@
-792,7
+773,7
@@
static void check_match(IPos start, IPos match, int length);
*/
static void lm_init(ush * flags)
{
*/
static void lm_init(ush * flags)
{
-
register
unsigned j;
+ unsigned j;
/* Initialize the hash table. */
memset(head, 0, HASH_SIZE * sizeof(*head));
/* Initialize the hash table. */
memset(head, 0, HASH_SIZE * sizeof(*head));
@@
-842,9
+823,9
@@
static void lm_init(ush * flags)
static int longest_match(IPos cur_match)
{
unsigned chain_length = max_chain_length; /* max hash chain length */
static int longest_match(IPos cur_match)
{
unsigned chain_length = max_chain_length; /* max hash chain length */
-
register uch *scan = window + strstart;
/* current string */
-
register uch *match;
/* matched string */
-
register int len;
/* length of current match */
+
uch *scan = window + strstart;
/* current string */
+
uch *match;
/* matched string */
+
int len;
/* length of current match */
int best_len = prev_length; /* best match length so far */
IPos limit =
strstart > (IPos) MAX_DIST ? strstart - (IPos) MAX_DIST : NIL;
int best_len = prev_length; /* best match length so far */
IPos limit =
strstart > (IPos) MAX_DIST ? strstart - (IPos) MAX_DIST : NIL;
@@
-858,9
+839,9
@@
static int longest_match(IPos cur_match)
#if HASH_BITS < 8 || MAX_MATCH != 258
# error Code too clever
#endif
#if HASH_BITS < 8 || MAX_MATCH != 258
# error Code too clever
#endif
-
register
uch *strend = window + strstart + MAX_MATCH;
-
register
uch scan_end1 = scan[best_len - 1];
-
register
uch scan_end = scan[best_len];
+ uch *strend = window + strstart + MAX_MATCH;
+ uch scan_end1 = scan[best_len - 1];
+ uch scan_end = scan[best_len];
/* Do not waste too much time if we already have a good match: */
if (prev_length >= good_match) {
/* Do not waste too much time if we already have a good match: */
if (prev_length >= good_match) {
@@
-947,7
+928,7
@@
static void check_match(IPos start, IPos match, int length)
*/
static void fill_window(void)
{
*/
static void fill_window(void)
{
-
register
unsigned n, m;
+ unsigned n, m;
unsigned more =
(unsigned) (window_size - (ulg) lookahead - (ulg) strstart);
/* Amount of free space at the end of the window. */
unsigned more =
(unsigned) (window_size - (ulg) lookahead - (ulg) strstart);
/* Amount of free space at the end of the window. */
@@
-1015,7
+996,7
@@
static ulg deflate(void)
IPos prev_match; /* previous match */
int flush; /* set if current block must be flushed */
int match_available = 0; /* set if previous match exists */
IPos prev_match; /* previous match */
int flush; /* set if current block must be flushed */
int match_available = 0; /* set if previous match exists */
-
register unsigned match_length = MIN_MATCH - 1;
/* length of best match */
+
unsigned match_length = MIN_MATCH - 1;
/* length of best match */
/* Process the input block. */
while (lookahead != 0) {
/* Process the input block. */
while (lookahead != 0) {
@@
-1228,8
+1209,8
@@
int gzip_main(int argc, char **argv)
inFileNum = STDIN_FILENO;
outFileNum = STDOUT_FILENO;
} else {
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;
bb_perror_msg_and_die("%s", argv[i]);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;