1
Description: clear gzip buffers between files
2
When compressing multiple files on the commandline, empty the buffers in
3
between each file to guard against small permutations in the resulting
5
Author: Cyril Brulebois <kibi@debian.org>
6
Bug-Debian: http://bugs.debian.org/647522
7
Bug-Ubuntu: https://bugs.launchpad.net/bugs/871083
10
===================================================================
14
SET_BINARY_MODE(fileno(stdout));
16
while (optind < argc) {
18
+ /* Make sure buffers are reset to 0 to ensure reproducibility when handling several files */
19
+ ZEROIFY(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
20
+ ZEROIFY(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
21
+ ZEROIFY(ush, d_buf, DIST_BUFSIZE);
22
+ ZEROIFY(uch, window, 2L*WSIZE);
24
+ ZEROIFY(ush, tab_prefix, 1L<<BITS);
26
+ ZEROIFY(ush, tab_prefix0, 1L<<(BITS-1));
27
+ ZEROIFY(ush, tab_prefix1, 1L<<(BITS-1));
30
treat_file(argv[optind++]);
32
} else { /* Standard input */
34
===================================================================
38
array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
39
if (!array) xalloc_die (); \
41
+# define ZEROIFY(type, array, size) memset(array, 0, (size_t)(((size)+1L)/2)*2*sizeof(type))
42
# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
44
# define EXTERN(type, array) extern type array[]
45
# define DECLARE(type, array, size) type array[size]
46
# define ALLOC(type, array, size)
47
+# define ZEROIFY(type, array, size) { for (int i=0; i<size; i++) { array[i] = 0; } }