-/* ===========================================================================
- * Write the output gunzip_window gunzip_window[0..gunzip_outbuf_count-1] and update crc and gunzip_bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_gunzip_window(void)
-{
- int n;
-
- for (n = 0; n < gunzip_outbuf_count; n++) {
- gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
- }
-
- if (output_buffer_len == 0) { // Our buffer is empty -> straight memcpy
- memcpy(output_buffer, gunzip_window, gunzip_outbuf_count);
- output_buffer_len = gunzip_outbuf_count;
- } else { // Bit more complicated, append to end of output_buffer, realloc as necessary
- int newlen = output_buffer_len + gunzip_outbuf_count;
- if (newlen > output_buffer_size) {
- output_buffer = xrealloc(output_buffer, newlen); // Could free later, but as we now have the memory...
- //printf("Using %d byte output buffer\n", newlen);
- output_buffer_size = newlen;
- }
- memcpy(output_buffer + output_buffer_len, gunzip_window, gunzip_outbuf_count);
- output_buffer_len += gunzip_outbuf_count;
- }
-
- gunzip_bytes_out += gunzip_outbuf_count;
- gunzip_outbuf_count = 0;
-}
-