deflate.c (237691) | deflate.c (254069) |
---|---|
1/* deflate.c -- compress data using the deflation algorithm | 1/* deflate.c -- compress data using the deflation algorithm |
2 * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler | 2 * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler |
3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6/* 7 * ALGORITHM 8 * 9 * The "deflation" process depends on being able to identify portions 10 * of the input text which are identical to earlier input (within a --- 36 unchanged lines hidden (view full) --- 47 * 48 */ 49 50/* @(#) $Id$ */ 51 52#include "deflate.h" 53 54const char deflate_copyright[] = | 3 * For conditions of distribution and use, see copyright notice in zlib.h 4 */ 5 6/* 7 * ALGORITHM 8 * 9 * The "deflation" process depends on being able to identify portions 10 * of the input text which are identical to earlier input (within a --- 36 unchanged lines hidden (view full) --- 47 * 48 */ 49 50/* @(#) $Id$ */ 51 52#include "deflate.h" 53 54const char deflate_copyright[] = |
55 " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; | 55 " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; |
56/* 57 If you use the zlib library in a product, an acknowledgment is welcome 58 in the documentation of your product. If for some reason you cannot 59 include such an acknowledgment, I would appreciate that you keep this 60 copyright string in the executable of your product. 61 */ 62 63/* =========================================================================== --- 236 unchanged lines hidden (view full) --- 300 301 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); 302 s->pending_buf = (uchf *) overlay; 303 s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); 304 305 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || 306 s->pending_buf == Z_NULL) { 307 s->status = FINISH_STATE; | 56/* 57 If you use the zlib library in a product, an acknowledgment is welcome 58 in the documentation of your product. If for some reason you cannot 59 include such an acknowledgment, I would appreciate that you keep this 60 copyright string in the executable of your product. 61 */ 62 63/* =========================================================================== --- 236 unchanged lines hidden (view full) --- 300 301 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); 302 s->pending_buf = (uchf *) overlay; 303 s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); 304 305 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || 306 s->pending_buf == Z_NULL) { 307 s->status = FINISH_STATE; |
308 strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); | 308 strm->msg = ERR_MSG(Z_MEM_ERROR); |
309 deflateEnd (strm); 310 return Z_MEM_ERROR; 311 } 312 s->d_buf = overlay + s->lit_bufsize/sizeof(ush); 313 s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; 314 315 s->level = level; 316 s->strategy = strategy; --- 7 unchanged lines hidden (view full) --- 324 z_streamp strm; 325 const Bytef *dictionary; 326 uInt dictLength; 327{ 328 deflate_state *s; 329 uInt str, n; 330 int wrap; 331 unsigned avail; | 309 deflateEnd (strm); 310 return Z_MEM_ERROR; 311 } 312 s->d_buf = overlay + s->lit_bufsize/sizeof(ush); 313 s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; 314 315 s->level = level; 316 s->strategy = strategy; --- 7 unchanged lines hidden (view full) --- 324 z_streamp strm; 325 const Bytef *dictionary; 326 uInt dictLength; 327{ 328 deflate_state *s; 329 uInt str, n; 330 int wrap; 331 unsigned avail; |
332 unsigned char *next; | 332 z_const unsigned char *next; |
333 334 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) 335 return Z_STREAM_ERROR; 336 s = strm->state; 337 wrap = s->wrap; 338 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) 339 return Z_STREAM_ERROR; 340 --- 13 unchanged lines hidden (view full) --- 354 dictionary += dictLength - s->w_size; /* use the tail */ 355 dictLength = s->w_size; 356 } 357 358 /* insert dictionary into window and hash */ 359 avail = strm->avail_in; 360 next = strm->next_in; 361 strm->avail_in = dictLength; | 333 334 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) 335 return Z_STREAM_ERROR; 336 s = strm->state; 337 wrap = s->wrap; 338 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) 339 return Z_STREAM_ERROR; 340 --- 13 unchanged lines hidden (view full) --- 354 dictionary += dictLength - s->w_size; /* use the tail */ 355 dictLength = s->w_size; 356 } 357 358 /* insert dictionary into window and hash */ 359 avail = strm->avail_in; 360 next = strm->next_in; 361 strm->avail_in = dictLength; |
362 strm->next_in = (Bytef *)dictionary; | 362 strm->next_in = (z_const Bytef *)dictionary; |
363 fill_window(s); 364 while (s->lookahead >= MIN_MATCH) { 365 str = s->strstart; 366 n = s->lookahead - (MIN_MATCH-1); 367 do { 368 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); 369#ifndef FASTEST 370 s->prev[str & s->w_mask] = s->head[s->ins_h]; --- 137 unchanged lines hidden (view full) --- 508 return Z_STREAM_ERROR; 509 } 510 func = configuration_table[s->level].func; 511 512 if ((strategy != s->strategy || func != configuration_table[level].func) && 513 strm->total_in != 0) { 514 /* Flush the last buffer: */ 515 err = deflate(strm, Z_BLOCK); | 363 fill_window(s); 364 while (s->lookahead >= MIN_MATCH) { 365 str = s->strstart; 366 n = s->lookahead - (MIN_MATCH-1); 367 do { 368 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); 369#ifndef FASTEST 370 s->prev[str & s->w_mask] = s->head[s->ins_h]; --- 137 unchanged lines hidden (view full) --- 508 return Z_STREAM_ERROR; 509 } 510 func = configuration_table[s->level].func; 511 512 if ((strategy != s->strategy || func != configuration_table[level].func) && 513 strm->total_in != 0) { 514 /* Flush the last buffer: */ 515 err = deflate(strm, Z_BLOCK); |
516 if (err == Z_BUF_ERROR && s->pending == 0) 517 err = Z_OK; |
|
516 } 517 if (s->level != level) { 518 s->level = level; 519 s->max_lazy_match = configuration_table[level].max_lazy; 520 s->good_match = configuration_table[level].good_length; 521 s->nice_match = configuration_table[level].nice_length; 522 s->max_chain_length = configuration_table[level].max_chain; 523 } --- 1442 unchanged lines hidden --- | 518 } 519 if (s->level != level) { 520 s->level = level; 521 s->max_lazy_match = configuration_table[level].max_lazy; 522 s->good_match = configuration_table[level].good_length; 523 s->nice_match = configuration_table[level].nice_length; 524 s->max_chain_length = configuration_table[level].max_chain; 525 } --- 1442 unchanged lines hidden --- |