Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
deflate.cc File Reference
#include "deflate.h"

Go to the source code of this file.

Data Structures

struct  config_s
 
struct  static_tree_desc_s
 

Macros

#define NIL   0
 
#define TOO_FAR   4096
 
#define EQUAL   0
 
#define RANK(f)   (((f) << 1) - ((f) > 4 ? 9 : 0))
 
#define UPDATE_HASH(s, h, c)   (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
 
#define INSERT_STRING(s, str, match_head)
 
#define CLEAR_HASH(s)
 
#define check_match(s, start, match, length)
 
#define FLUSH_BLOCK_ONLY(s, last)
 
#define FLUSH_BLOCK(s, last)
 

Typedefs

typedef block_state compress_func OF ((deflate_state *s, int flush))
 
typedef struct config_s config
 

Enumerations

enum  block_state { need_more, block_done, finish_started, finish_done }
 

Functions

local void fill_window OF ((deflate_state *s))
 
local block_state deflate_stored OF ((deflate_state *s, int flush))
 
local void putShortMSB OF ((deflate_state *s, uInt b))
 
local void flush_pending OF ((z_streamp strm))
 
local int read_buf OF ((z_streamp strm, Bytef *buf, unsigned size))
 
local uInt longest_match OF ((deflate_state *s, IPos cur_match))
 
int ZEXPORT deflateInit_ (z_streamp strm, int level, const char *version, int stream_size)
 
int ZEXPORT deflateInit2_ (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)
 
int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
 
int ZEXPORT deflateResetKeep (z_streamp strm)
 
int ZEXPORT deflateReset (z_streamp strm)
 
int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
 
int ZEXPORT deflatePending (z_streamp strm, unsigned *pending, int *bits)
 
int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
 
int ZEXPORT deflateParams (z_streamp strm, int level, int strategy)
 
int ZEXPORT deflateTune (z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
 
uLong ZEXPORT deflateBound (z_streamp strm, uLong sourceLen)
 
local void putShortMSB (deflate_state *s, uInt b)
 
local void flush_pending (z_streamp strm)
 
int ZEXPORT deflate (z_streamp strm, int flush)
 
int ZEXPORT deflateEnd (z_streamp strm)
 
int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
 
local int read_buf (z_streamp strm, Bytef *buf, unsigned size)
 
local void lm_init (deflate_state *s)
 
local uInt longest_match (deflate_state *s, IPos cur_match)
 
local void fill_window (deflate_state *s)
 
local block_state deflate_stored (deflate_state *s, int flush)
 
local block_state deflate_fast (deflate_state *s, int flush)
 
local block_state deflate_slow (deflate_state *s, int flush)
 
local block_state deflate_rle (deflate_state *s, int flush)
 
local block_state deflate_huff (deflate_state *s, int flush)
 

Variables

const char deflate_copyright []
 
local const config configuration_table [10]
 

Macro Definition Documentation

#define check_match (   s,
  start,
  match,
  length 
)

Definition at line 1321 of file deflate.cc.

Referenced by deflate_fast(), deflate_rle(), and deflate_slow().

#define CLEAR_HASH (   s)
Value:
s->head[s->hash_size-1] = NIL; \
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
const XML_Char * s
#define NIL
Definition: deflate.cc:104
void ZLIB_INTERNAL zmemzero(Bytef *dest, uInt len)
Definition: zutil.cc:168

Definition at line 196 of file deflate.cc.

Referenced by deflate(), deflateSetDictionary(), and lm_init().

#define EQUAL   0

Definition at line 151 of file deflate.cc.

#define FLUSH_BLOCK (   s,
  last 
)
Value:
{ \
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
const XML_Char * s
#define FLUSH_BLOCK_ONLY(s, last)
Definition: deflate.cc:1481

Definition at line 1493 of file deflate.cc.

Referenced by deflate_fast(), deflate_huff(), deflate_rle(), deflate_slow(), and deflate_stored().

#define FLUSH_BLOCK_ONLY (   s,
  last 
)
Value:
{ \
_tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
(last)); \
s->block_start = s->strstart; \
Tracev((stderr,"[FLUSH]")); \
}
local void flush_pending(z_streamp strm)
Definition: deflate.cc:603
const XML_Char * s
#define Tracev(x)
Definition: zutil.h:231
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.cc:877
unsigned long ulg
Definition: zutil.h:45
#define Z_NULL
Definition: zlib.h:208

Definition at line 1481 of file deflate.cc.

Referenced by deflate_slow().

#define INSERT_STRING (   s,
  str,
  match_head 
)
Value:
(UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
s->head[s->ins_h] = (Pos)(str))
#define MIN_MATCH
Definition: zutil.h:75
#define UPDATE_HASH(s, h, c)
Definition: deflate.cc:167
const XML_Char * s
ush Pos
Definition: deflate.h:89

Definition at line 186 of file deflate.cc.

Referenced by deflate_fast(), and deflate_slow().

#define NIL   0

Definition at line 104 of file deflate.cc.

Referenced by deflate_fast(), deflate_slow(), fill_window(), and longest_match().

#define RANK (   f)    (((f) << 1) - ((f) > 4 ? 9 : 0))

Definition at line 159 of file deflate.cc.

Referenced by deflate().

#define TOO_FAR   4096

Definition at line 108 of file deflate.cc.

Referenced by deflate_slow().

#define UPDATE_HASH (   s,
  h,
 
)    (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)

Definition at line 167 of file deflate.cc.

Referenced by deflate_fast(), deflateSetDictionary(), and fill_window().

Typedef Documentation

typedef struct config_s config
typedef block_state compress_func OF((deflate_state *s, int flush))

Definition at line 73 of file deflate.cc.

Enumeration Type Documentation

Enumerator
need_more 
block_done 
finish_started 
finish_done 

Definition at line 66 of file deflate.cc.

66  {
67  need_more, /* block not completed, need more input or more output */
68  block_done, /* block flush performed */
69  finish_started, /* finish started, need only more output at next deflate */
70  finish_done /* finish done, accept no more input or output */
71 } block_state;
block_state
Definition: deflate.cc:66

Function Documentation

int ZEXPORT deflate ( z_streamp  strm,
int  flush 
)

Definition at line 625 of file deflate.cc.

References _tr_align(), _tr_stored_block(), adler32(), Assert, block_done, internal_state::block_start, BUSY_STATE, CLEAR_HASH, COMMENT_STATE, crc32(), deflate_huff(), deflate_rle(), ERR_RETURN, EXTRA_STATE, finish_done, finish_started, FINISH_STATE, flush_pending(), internal_state::gzhead, internal_state::gzindex, HCRC_STATE, INIT_STATE, internal_state::insert, internal_state::last_flush, internal_state::level, internal_state::lookahead, NAME_STATE, need_more, OS_CODE, internal_state::pending, internal_state::pending_buf, internal_state::pending_buf_size, PRESET_DICT, put_byte, putShortMSB(), RANK, internal_state::status, internal_state::strategy, internal_state::strm, internal_state::strstart, internal_state::w_bits, internal_state::wrap, Z_BLOCK, Z_BUF_ERROR, Z_DEFLATED, Z_FINISH, Z_FULL_FLUSH, Z_HUFFMAN_ONLY, Z_NO_FLUSH, Z_NULL, Z_OK, Z_PARTIAL_FLUSH, Z_RLE, Z_STREAM_END, and Z_STREAM_ERROR.

Referenced by compress2(), deflateParams(), cheprep::DeflateOutputStreamBuffer::finish(), gz_comp(), and cheprep::DeflateOutputStreamBuffer::overflow().

626 {
627  int old_flush; /* value of flush param for previous deflate call */
628  deflate_state *s;
629 
630  if (strm == Z_NULL || strm->state == Z_NULL ||
631  flush > Z_BLOCK || flush < 0) {
632  return Z_STREAM_ERROR;
633  }
634  s = strm->state;
635 
636  if (strm->next_out == Z_NULL ||
637  (strm->next_in == Z_NULL && strm->avail_in != 0) ||
638  (s->status == FINISH_STATE && flush != Z_FINISH)) {
639  ERR_RETURN(strm, Z_STREAM_ERROR);
640  }
641  if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
642 
643  s->strm = strm; /* just in case */
644  old_flush = s->last_flush;
645  s->last_flush = flush;
646 
647  /* Write the header */
648  if (s->status == INIT_STATE) {
649 #ifdef GZIP
650  if (s->wrap == 2) {
651  strm->adler = crc32(0L, Z_NULL, 0);
652  put_byte(s, 31);
653  put_byte(s, 139);
654  put_byte(s, 8);
655  if (s->gzhead == Z_NULL) {
656  put_byte(s, 0);
657  put_byte(s, 0);
658  put_byte(s, 0);
659  put_byte(s, 0);
660  put_byte(s, 0);
661  put_byte(s, s->level == 9 ? 2 :
662  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
663  4 : 0));
664  put_byte(s, OS_CODE);
665  s->status = BUSY_STATE;
666  }
667  else {
668  put_byte(s, (s->gzhead->text ? 1 : 0) +
669  (s->gzhead->hcrc ? 2 : 0) +
670  (s->gzhead->extra == Z_NULL ? 0 : 4) +
671  (s->gzhead->name == Z_NULL ? 0 : 8) +
672  (s->gzhead->comment == Z_NULL ? 0 : 16)
673  );
674  put_byte(s, (Byte)(s->gzhead->time & 0xff));
675  put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
676  put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
677  put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
678  put_byte(s, s->level == 9 ? 2 :
679  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
680  4 : 0));
681  put_byte(s, s->gzhead->os & 0xff);
682  if (s->gzhead->extra != Z_NULL) {
683  put_byte(s, s->gzhead->extra_len & 0xff);
684  put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
685  }
686  if (s->gzhead->hcrc)
687  strm->adler = crc32(strm->adler, s->pending_buf,
688  s->pending);
689  s->gzindex = 0;
690  s->status = EXTRA_STATE;
691  }
692  }
693  else
694 #endif
695  {
696  uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
697  uInt level_flags;
698 
699  if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
700  level_flags = 0;
701  else if (s->level < 6)
702  level_flags = 1;
703  else if (s->level == 6)
704  level_flags = 2;
705  else
706  level_flags = 3;
707  header |= (level_flags << 6);
708  if (s->strstart != 0) header |= PRESET_DICT;
709  header += 31 - (header % 31);
710 
711  s->status = BUSY_STATE;
712  putShortMSB(s, header);
713 
714  /* Save the adler32 of the preset dictionary: */
715  if (s->strstart != 0) {
716  putShortMSB(s, (uInt)(strm->adler >> 16));
717  putShortMSB(s, (uInt)(strm->adler & 0xffff));
718  }
719  strm->adler = adler32(0L, Z_NULL, 0);
720  }
721  }
722 #ifdef GZIP
723  if (s->status == EXTRA_STATE) {
724  if (s->gzhead->extra != Z_NULL) {
725  uInt beg = s->pending; /* start of bytes to update crc */
726 
727  while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
728  if (s->pending == s->pending_buf_size) {
729  if (s->gzhead->hcrc && s->pending > beg)
730  strm->adler = crc32(strm->adler, s->pending_buf + beg,
731  s->pending - beg);
732  flush_pending(strm);
733  beg = s->pending;
734  if (s->pending == s->pending_buf_size)
735  break;
736  }
737  put_byte(s, s->gzhead->extra[s->gzindex]);
738  s->gzindex++;
739  }
740  if (s->gzhead->hcrc && s->pending > beg)
741  strm->adler = crc32(strm->adler, s->pending_buf + beg,
742  s->pending - beg);
743  if (s->gzindex == s->gzhead->extra_len) {
744  s->gzindex = 0;
745  s->status = NAME_STATE;
746  }
747  }
748  else
749  s->status = NAME_STATE;
750  }
751  if (s->status == NAME_STATE) {
752  if (s->gzhead->name != Z_NULL) {
753  uInt beg = s->pending; /* start of bytes to update crc */
754  int val;
755 
756  do {
757  if (s->pending == s->pending_buf_size) {
758  if (s->gzhead->hcrc && s->pending > beg)
759  strm->adler = crc32(strm->adler, s->pending_buf + beg,
760  s->pending - beg);
761  flush_pending(strm);
762  beg = s->pending;
763  if (s->pending == s->pending_buf_size) {
764  val = 1;
765  break;
766  }
767  }
768  val = s->gzhead->name[s->gzindex++];
769  put_byte(s, val);
770  } while (val != 0);
771  if (s->gzhead->hcrc && s->pending > beg)
772  strm->adler = crc32(strm->adler, s->pending_buf + beg,
773  s->pending - beg);
774  if (val == 0) {
775  s->gzindex = 0;
776  s->status = COMMENT_STATE;
777  }
778  }
779  else
780  s->status = COMMENT_STATE;
781  }
782  if (s->status == COMMENT_STATE) {
783  if (s->gzhead->comment != Z_NULL) {
784  uInt beg = s->pending; /* start of bytes to update crc */
785  int val;
786 
787  do {
788  if (s->pending == s->pending_buf_size) {
789  if (s->gzhead->hcrc && s->pending > beg)
790  strm->adler = crc32(strm->adler, s->pending_buf + beg,
791  s->pending - beg);
792  flush_pending(strm);
793  beg = s->pending;
794  if (s->pending == s->pending_buf_size) {
795  val = 1;
796  break;
797  }
798  }
799  val = s->gzhead->comment[s->gzindex++];
800  put_byte(s, val);
801  } while (val != 0);
802  if (s->gzhead->hcrc && s->pending > beg)
803  strm->adler = crc32(strm->adler, s->pending_buf + beg,
804  s->pending - beg);
805  if (val == 0)
806  s->status = HCRC_STATE;
807  }
808  else
809  s->status = HCRC_STATE;
810  }
811  if (s->status == HCRC_STATE) {
812  if (s->gzhead->hcrc) {
813  if (s->pending + 2 > s->pending_buf_size)
814  flush_pending(strm);
815  if (s->pending + 2 <= s->pending_buf_size) {
816  put_byte(s, (Byte)(strm->adler & 0xff));
817  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
818  strm->adler = crc32(0L, Z_NULL, 0);
819  s->status = BUSY_STATE;
820  }
821  }
822  else
823  s->status = BUSY_STATE;
824  }
825 #endif
826 
827  /* Flush as much pending output as possible */
828  if (s->pending != 0) {
829  flush_pending(strm);
830  if (strm->avail_out == 0) {
831  /* Since avail_out is 0, deflate will be called again with
832  * more output space, but possibly with both pending and
833  * avail_in equal to zero. There won't be anything to do,
834  * but this is not an error situation so make sure we
835  * return OK instead of BUF_ERROR at next call of deflate:
836  */
837  s->last_flush = -1;
838  return Z_OK;
839  }
840 
841  /* Make sure there is something to do and avoid duplicate consecutive
842  * flushes. For repeated and useless calls with Z_FINISH, we keep
843  * returning Z_STREAM_END instead of Z_BUF_ERROR.
844  */
845  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
846  flush != Z_FINISH) {
847  ERR_RETURN(strm, Z_BUF_ERROR);
848  }
849 
850  /* User must not provide more input after the first FINISH: */
851  if (s->status == FINISH_STATE && strm->avail_in != 0) {
852  ERR_RETURN(strm, Z_BUF_ERROR);
853  }
854 
855  /* Start a new block or continue the current one.
856  */
857  if (strm->avail_in != 0 || s->lookahead != 0 ||
858  (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
859  block_state bstate;
860 
861  bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
862  (s->strategy == Z_RLE ? deflate_rle(s, flush) :
863  (*(configuration_table[s->level].func))(s, flush));
864 
865  if (bstate == finish_started || bstate == finish_done) {
866  s->status = FINISH_STATE;
867  }
868  if (bstate == need_more || bstate == finish_started) {
869  if (strm->avail_out == 0) {
870  s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
871  }
872  return Z_OK;
873  /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
874  * of deflate should use the same flush parameter to make sure
875  * that the flush is complete. So we don't have to output an
876  * empty block here, this will be done at next call. This also
877  * ensures that for a very small output buffer, we emit at most
878  * one empty block.
879  */
880  }
881  if (bstate == block_done) {
882  if (flush == Z_PARTIAL_FLUSH) {
883  _tr_align(s);
884  } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
885  _tr_stored_block(s, (char*)0, 0L, 0);
886  /* For a full flush, this empty block will be recognized
887  * as a special marker by inflate_sync().
888  */
889  if (flush == Z_FULL_FLUSH) {
890  CLEAR_HASH(s); /* forget history */
891  if (s->lookahead == 0) {
892  s->strstart = 0;
893  s->block_start = 0L;
894  s->insert = 0;
895  }
896  }
897  }
898  flush_pending(strm);
899  if (strm->avail_out == 0) {
900  s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
901  return Z_OK;
902  }
903  }
904  }
905  Assert(strm->avail_out > 0, "bug2");
906 
907  if (flush != Z_FINISH) return Z_OK;
908  if (s->wrap <= 0) return Z_STREAM_END;
909 
910  /* Write the trailer */
911 #ifdef GZIP
912  if (s->wrap == 2) {
913  put_byte(s, (Byte)(strm->adler & 0xff));
914  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
915  put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
916  put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
917  put_byte(s, (Byte)(strm->total_in & 0xff));
918  put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
919  put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
920  put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
921  }
922  else
923 #endif
924  {
925  putShortMSB(s, (uInt)(strm->adler >> 16));
926  putShortMSB(s, (uInt)(strm->adler & 0xffff));
927  }
928  flush_pending(strm);
929  /* If avail_out is zero, the application will call deflate again
930  * to flush the rest.
931  */
932  if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
933  return s->pending != 0 ? Z_OK : Z_STREAM_END;
934 }
#define INIT_STATE
Definition: deflate.h:54
#define Z_BLOCK
Definition: zlib.h:169
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.cc:202
local void putShortMSB(deflate_state *s, uInt b)
Definition: deflate.cc:591
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.cc:841
local block_state deflate_huff(deflate_state *s, int flush)
Definition: deflate.cc:1869
#define HCRC_STATE
Definition: deflate.h:58
local void flush_pending(z_streamp strm)
Definition: deflate.cc:603
#define Z_NO_FLUSH
Definition: zlib.h:164
#define PRESET_DICT
Definition: zutil.h:79
const XML_Char * s
#define Z_PARTIAL_FLUSH
Definition: zlib.h:165
#define Assert(cond, msg)
Definition: zutil.h:229
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.cc:65
void ZLIB_INTERNAL _tr_align(deflate_state *s)
Definition: trees.cc:863
block_state
Definition: deflate.cc:66
#define Z_STREAM_ERROR
Definition: zlib.h:177
gz_headerp gzhead
Definition: deflate.h:105
uInt lookahead
Definition: deflate.h:161
#define BUSY_STATE
Definition: deflate.h:59
#define Z_FINISH
Definition: zlib.h:168
z_streamp strm
Definition: deflate.h:98
#define Z_DEFLATED
Definition: zlib.h:205
#define Z_STREAM_END
Definition: zlib.h:174
#define put_byte(s, c)
Definition: deflate.h:278
#define COMMENT_STATE
Definition: deflate.h:57
Bytef * pending_buf
Definition: deflate.h:100
#define NAME_STATE
Definition: deflate.h:56
long block_start
Definition: deflate.h:151
local const config configuration_table[10]
Definition: deflate.cc:131
uInt gzindex
Definition: deflate.h:106
#define FINISH_STATE
Definition: deflate.h:60
#define Z_HUFFMAN_ONLY
Definition: zlib.h:193
#define CLEAR_HASH(s)
Definition: deflate.cc:196
#define Z_BUF_ERROR
Definition: zlib.h:180
uInt pending
Definition: deflate.h:103
uInt strstart
Definition: deflate.h:159
#define ERR_RETURN(strm, err)
Definition: zutil.h:52
ulg pending_buf_size
Definition: deflate.h:101
#define Z_OK
Definition: zlib.h:173
#define EXTRA_STATE
Definition: deflate.h:55
#define Z_NULL
Definition: zlib.h:208
local block_state deflate_rle(deflate_state *s, int flush)
Definition: deflate.cc:1798
#define Z_FULL_FLUSH
Definition: zlib.h:167
int last_flush
Definition: deflate.h:108
#define RANK(f)
Definition: deflate.cc:159
#define OS_CODE
Definition: zutil.h:179
#define Z_RLE
Definition: zlib.h:194
local block_state deflate_fast ( deflate_state s,
int  flush 
)

Definition at line 1569 of file deflate.cc.

References _tr_tally_dist, _tr_tally_lit, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, internal_state::ins_h, internal_state::insert, INSERT_STRING, internal_state::last_lit, longest_match(), internal_state::lookahead, internal_state::match_length, internal_state::match_start, MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, need_more, NIL, internal_state::strstart, times, Tracevv, UPDATE_HASH, internal_state::window, Z_FINISH, and Z_NO_FLUSH.

1570 {
1571  IPos hash_head; /* head of the hash chain */
1572  int bflush; /* set if current block must be flushed */
1573 
1574  for (;;) {
1575  /* Make sure that we always have enough lookahead, except
1576  * at the end of the input file. We need MAX_MATCH bytes
1577  * for the next match, plus MIN_MATCH bytes to insert the
1578  * string following the next match.
1579  */
1580  if (s->lookahead < MIN_LOOKAHEAD) {
1581  fill_window(s);
1582  if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1583  return need_more;
1584  }
1585  if (s->lookahead == 0) break; /* flush the current block */
1586  }
1587 
1588  /* Insert the string window[strstart .. strstart+2] in the
1589  * dictionary, and set hash_head to the head of the hash chain:
1590  */
1591  hash_head = NIL;
1592  if (s->lookahead >= MIN_MATCH) {
1593  INSERT_STRING(s, s->strstart, hash_head);
1594  }
1595 
1596  /* Find the longest match, discarding those <= prev_length.
1597  * At this point we have always match_length < MIN_MATCH
1598  */
1599  if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1600  /* To simplify the code, we prevent matches with the string
1601  * of window index 0 (in particular we have to avoid a match
1602  * of the string with itself at the start of the input file).
1603  */
1604  s->match_length = longest_match (s, hash_head);
1605  /* longest_match() sets match_start */
1606  }
1607  if (s->match_length >= MIN_MATCH) {
1609 
1610  _tr_tally_dist(s, s->strstart - s->match_start,
1611  s->match_length - MIN_MATCH, bflush);
1612 
1613  s->lookahead -= s->match_length;
1614 
1615  /* Insert new strings in the hash table only if the match length
1616  * is not too large. This saves time but degrades compression.
1617  */
1618 #ifndef FASTEST
1619  if (s->match_length <= s->max_insert_length &&
1620  s->lookahead >= MIN_MATCH) {
1621  s->match_length--; /* string at strstart already in table */
1622  do {
1623  s->strstart++;
1624  INSERT_STRING(s, s->strstart, hash_head);
1625  /* strstart never exceeds WSIZE-MAX_MATCH, so there are
1626  * always MIN_MATCH bytes ahead.
1627  */
1628  } while (--s->match_length != 0);
1629  s->strstart++;
1630  } else
1631 #endif
1632  {
1633  s->strstart += s->match_length;
1634  s->match_length = 0;
1635  s->ins_h = s->window[s->strstart];
1636  UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
1637 #if MIN_MATCH != 3
1638  Call UPDATE_HASH() MIN_MATCH-3 more times
1639 #endif
1640  /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
1641  * matter since it will be recomputed at next deflate call.
1642  */
1643  }
1644  } else {
1645  /* No match, output a literal byte */
1646  Tracevv((stderr,"%c", s->window[s->strstart]));
1647  _tr_tally_lit (s, s->window[s->strstart], bflush);
1648  s->lookahead--;
1649  s->strstart++;
1650  }
1651  if (bflush) FLUSH_BLOCK(s, 0);
1652  }
1653  s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1654  if (flush == Z_FINISH) {
1655  FLUSH_BLOCK(s, 1);
1656  return finish_done;
1657  }
1658  if (s->last_lit)
1659  FLUSH_BLOCK(s, 0);
1660  return block_done;
1661 }
Bytef * window
Definition: deflate.h:116
#define Z_NO_FLUSH
Definition: zlib.h:164
#define MIN_MATCH
Definition: zutil.h:75
#define UPDATE_HASH(s, h, c)
Definition: deflate.cc:167
uInt match_length
Definition: deflate.h:156
#define NIL
Definition: deflate.cc:104
Definition: G4Pair.hh:150
uInt match_start
Definition: deflate.h:160
uInt lookahead
Definition: deflate.h:161
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:323
#define MAX_DIST(s)
Definition: deflate.h:286
#define check_match(s, start, match, length)
Definition: deflate.cc:1321
#define MIN_LOOKAHEAD
Definition: deflate.h:281
#define Z_FINISH
Definition: zlib.h:168
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
#define INSERT_STRING(s, str, match_head)
Definition: deflate.cc:186
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:330
#define FLUSH_BLOCK(s, last)
Definition: deflate.cc:1493
local uInt longest_match(deflate_state *s, IPos cur_match)
Definition: deflate.cc:1099
#define times
uInt last_lit
Definition: deflate.h:239
uInt strstart
Definition: deflate.h:159
#define Tracevv(x)
Definition: zutil.h:232
unsigned IPos
Definition: deflate.h:91
local block_state deflate_huff ( deflate_state s,
int  flush 
)

Definition at line 1869 of file deflate.cc.

References _tr_tally_lit, block_done, fill_window(), finish_done, FLUSH_BLOCK, internal_state::insert, internal_state::last_lit, internal_state::lookahead, internal_state::match_length, need_more, internal_state::strstart, Tracevv, internal_state::window, Z_FINISH, and Z_NO_FLUSH.

Referenced by deflate().

1870 {
1871  int bflush; /* set if current block must be flushed */
1872 
1873  for (;;) {
1874  /* Make sure that we have a literal to write. */
1875  if (s->lookahead == 0) {
1876  fill_window(s);
1877  if (s->lookahead == 0) {
1878  if (flush == Z_NO_FLUSH)
1879  return need_more;
1880  break; /* flush the current block */
1881  }
1882  }
1883 
1884  /* Output a literal byte */
1885  s->match_length = 0;
1886  Tracevv((stderr,"%c", s->window[s->strstart]));
1887  _tr_tally_lit (s, s->window[s->strstart], bflush);
1888  s->lookahead--;
1889  s->strstart++;
1890  if (bflush) FLUSH_BLOCK(s, 0);
1891  }
1892  s->insert = 0;
1893  if (flush == Z_FINISH) {
1894  FLUSH_BLOCK(s, 1);
1895  return finish_done;
1896  }
1897  if (s->last_lit)
1898  FLUSH_BLOCK(s, 0);
1899  return block_done;
1900 }
Bytef * window
Definition: deflate.h:116
#define Z_NO_FLUSH
Definition: zlib.h:164
uInt match_length
Definition: deflate.h:156
uInt lookahead
Definition: deflate.h:161
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:323
#define Z_FINISH
Definition: zlib.h:168
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
#define FLUSH_BLOCK(s, last)
Definition: deflate.cc:1493
uInt last_lit
Definition: deflate.h:239
uInt strstart
Definition: deflate.h:159
#define Tracevv(x)
Definition: zutil.h:232
local block_state deflate_rle ( deflate_state s,
int  flush 
)

Definition at line 1798 of file deflate.cc.

References _tr_tally_dist, _tr_tally_lit, Assert, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, internal_state::insert, int(), internal_state::last_lit, internal_state::lookahead, internal_state::match_length, MAX_MATCH, MIN_MATCH, need_more, internal_state::prev, internal_state::strstart, Tracevv, internal_state::window, internal_state::window_size, Z_FINISH, and Z_NO_FLUSH.

Referenced by deflate().

1799 {
1800  int bflush; /* set if current block must be flushed */
1801  uInt prev; /* byte at distance one to match */
1802  Bytef *scan, *strend; /* scan goes up to strend for length of run */
1803 
1804  for (;;) {
1805  /* Make sure that we always have enough lookahead, except
1806  * at the end of the input file. We need MAX_MATCH bytes
1807  * for the longest run, plus one for the unrolled loop.
1808  */
1809  if (s->lookahead <= MAX_MATCH) {
1810  fill_window(s);
1811  if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
1812  return need_more;
1813  }
1814  if (s->lookahead == 0) break; /* flush the current block */
1815  }
1816 
1817  /* See how many times the previous byte repeats */
1818  s->match_length = 0;
1819  if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
1820  scan = s->window + s->strstart - 1;
1821  prev = *scan;
1822  if (prev == *++scan && prev == *++scan && prev == *++scan) {
1823  strend = s->window + s->strstart + MAX_MATCH;
1824  do {
1825  } while (prev == *++scan && prev == *++scan &&
1826  prev == *++scan && prev == *++scan &&
1827  prev == *++scan && prev == *++scan &&
1828  prev == *++scan && prev == *++scan &&
1829  scan < strend);
1830  s->match_length = MAX_MATCH - (int)(strend - scan);
1831  if (s->match_length > s->lookahead)
1832  s->match_length = s->lookahead;
1833  }
1834  Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
1835  }
1836 
1837  /* Emit match if have run of MIN_MATCH or longer, else emit literal */
1838  if (s->match_length >= MIN_MATCH) {
1839  check_match(s, s->strstart, s->strstart - 1, s->match_length);
1840 
1841  _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
1842 
1843  s->lookahead -= s->match_length;
1844  s->strstart += s->match_length;
1845  s->match_length = 0;
1846  } else {
1847  /* No match, output a literal byte */
1848  Tracevv((stderr,"%c", s->window[s->strstart]));
1849  _tr_tally_lit (s, s->window[s->strstart], bflush);
1850  s->lookahead--;
1851  s->strstart++;
1852  }
1853  if (bflush) FLUSH_BLOCK(s, 0);
1854  }
1855  s->insert = 0;
1856  if (flush == Z_FINISH) {
1857  FLUSH_BLOCK(s, 1);
1858  return finish_done;
1859  }
1860  if (s->last_lit)
1861  FLUSH_BLOCK(s, 0);
1862  return block_done;
1863 }
Bytef * window
Definition: deflate.h:116
#define Z_NO_FLUSH
Definition: zlib.h:164
#define MIN_MATCH
Definition: zutil.h:75
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
uInt match_length
Definition: deflate.h:156
#define Assert(cond, msg)
Definition: zutil.h:229
uInt lookahead
Definition: deflate.h:161
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:323
#define check_match(s, start, match, length)
Definition: deflate.cc:1321
ulg window_size
Definition: deflate.h:126
#define Z_FINISH
Definition: zlib.h:168
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
#define MAX_MATCH
Definition: zutil.h:76
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:330
#define FLUSH_BLOCK(s, last)
Definition: deflate.cc:1493
uInt last_lit
Definition: deflate.h:239
uInt strstart
Definition: deflate.h:159
#define Tracevv(x)
Definition: zutil.h:232
local block_state deflate_slow ( deflate_state s,
int  flush 
)

Definition at line 1669 of file deflate.cc.

References _tr_tally_dist, _tr_tally_lit, Assert, block_done, check_match, fill_window(), finish_done, FLUSH_BLOCK, FLUSH_BLOCK_ONLY, internal_state::insert, INSERT_STRING, internal_state::last_lit, longest_match(), internal_state::lookahead, internal_state::match_available, internal_state::match_length, internal_state::match_start, MAX_DIST, internal_state::max_lazy_match, MIN_LOOKAHEAD, MIN_MATCH, need_more, NIL, internal_state::prev_length, internal_state::prev_match, internal_state::strategy, internal_state::strm, internal_state::strstart, TOO_FAR, Tracevv, internal_state::window, Z_FILTERED, Z_FINISH, and Z_NO_FLUSH.

1670 {
1671  IPos hash_head; /* head of hash chain */
1672  int bflush; /* set if current block must be flushed */
1673 
1674  /* Process the input block. */
1675  for (;;) {
1676  /* Make sure that we always have enough lookahead, except
1677  * at the end of the input file. We need MAX_MATCH bytes
1678  * for the next match, plus MIN_MATCH bytes to insert the
1679  * string following the next match.
1680  */
1681  if (s->lookahead < MIN_LOOKAHEAD) {
1682  fill_window(s);
1683  if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1684  return need_more;
1685  }
1686  if (s->lookahead == 0) break; /* flush the current block */
1687  }
1688 
1689  /* Insert the string window[strstart .. strstart+2] in the
1690  * dictionary, and set hash_head to the head of the hash chain:
1691  */
1692  hash_head = NIL;
1693  if (s->lookahead >= MIN_MATCH) {
1694  INSERT_STRING(s, s->strstart, hash_head);
1695  }
1696 
1697  /* Find the longest match, discarding those <= prev_length.
1698  */
1700  s->match_length = MIN_MATCH-1;
1701 
1702  if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
1703  s->strstart - hash_head <= MAX_DIST(s)) {
1704  /* To simplify the code, we prevent matches with the string
1705  * of window index 0 (in particular we have to avoid a match
1706  * of the string with itself at the start of the input file).
1707  */
1708  s->match_length = longest_match (s, hash_head);
1709  /* longest_match() sets match_start */
1710 
1711  if (s->match_length <= 5 && (s->strategy == Z_FILTERED
1712 #if TOO_FAR <= 32767
1713  || (s->match_length == MIN_MATCH &&
1714  s->strstart - s->match_start > TOO_FAR)
1715 #endif
1716  )) {
1717 
1718  /* If prev_match is also MIN_MATCH, match_start is garbage
1719  * but we will ignore the current match anyway.
1720  */
1721  s->match_length = MIN_MATCH-1;
1722  }
1723  }
1724  /* If there was a match at the previous step and the current
1725  * match is not better, output the previous match:
1726  */
1727  if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
1728  uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
1729  /* Do not insert strings in hash table beyond this. */
1730 
1731  check_match(s, s->strstart-1, s->prev_match, s->prev_length);
1732 
1733  _tr_tally_dist(s, s->strstart -1 - s->prev_match,
1734  s->prev_length - MIN_MATCH, bflush);
1735 
1736  /* Insert in hash table all strings up to the end of the match.
1737  * strstart-1 and strstart are already inserted. If there is not
1738  * enough lookahead, the last two strings are not inserted in
1739  * the hash table.
1740  */
1741  s->lookahead -= s->prev_length-1;
1742  s->prev_length -= 2;
1743  do {
1744  if (++s->strstart <= max_insert) {
1745  INSERT_STRING(s, s->strstart, hash_head);
1746  }
1747  } while (--s->prev_length != 0);
1748  s->match_available = 0;
1749  s->match_length = MIN_MATCH-1;
1750  s->strstart++;
1751 
1752  if (bflush) FLUSH_BLOCK(s, 0);
1753 
1754  } else if (s->match_available) {
1755  /* If there was no match at the previous position, output a
1756  * single literal. If there was a match but the current match
1757  * is longer, truncate the previous match to a single literal.
1758  */
1759  Tracevv((stderr,"%c", s->window[s->strstart-1]));
1760  _tr_tally_lit(s, s->window[s->strstart-1], bflush);
1761  if (bflush) {
1762  FLUSH_BLOCK_ONLY(s, 0);
1763  }
1764  s->strstart++;
1765  s->lookahead--;
1766  if (s->strm->avail_out == 0) return need_more;
1767  } else {
1768  /* There is no previous match to compare with, wait for
1769  * the next step to decide.
1770  */
1771  s->match_available = 1;
1772  s->strstart++;
1773  s->lookahead--;
1774  }
1775  }
1776  Assert (flush != Z_NO_FLUSH, "no flush?");
1777  if (s->match_available) {
1778  Tracevv((stderr,"%c", s->window[s->strstart-1]));
1779  _tr_tally_lit(s, s->window[s->strstart-1], bflush);
1780  s->match_available = 0;
1781  }
1782  s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1783  if (flush == Z_FINISH) {
1784  FLUSH_BLOCK(s, 1);
1785  return finish_done;
1786  }
1787  if (s->last_lit)
1788  FLUSH_BLOCK(s, 0);
1789  return block_done;
1790 }
Bytef * window
Definition: deflate.h:116
#define Z_NO_FLUSH
Definition: zlib.h:164
#define MIN_MATCH
Definition: zutil.h:75
uInt max_lazy_match
Definition: deflate.h:174
uInt match_length
Definition: deflate.h:156
#define NIL
Definition: deflate.cc:104
#define Assert(cond, msg)
Definition: zutil.h:229
uInt prev_length
Definition: deflate.h:163
#define FLUSH_BLOCK_ONLY(s, last)
Definition: deflate.cc:1481
#define Z_FILTERED
Definition: zlib.h:192
uInt match_start
Definition: deflate.h:160
uInt lookahead
Definition: deflate.h:161
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:323
#define MAX_DIST(s)
Definition: deflate.h:286
#define check_match(s, start, match, length)
Definition: deflate.cc:1321
#define MIN_LOOKAHEAD
Definition: deflate.h:281
#define Z_FINISH
Definition: zlib.h:168
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
z_streamp strm
Definition: deflate.h:98
#define TOO_FAR
Definition: deflate.cc:108
#define INSERT_STRING(s, str, match_head)
Definition: deflate.cc:186
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:330
#define FLUSH_BLOCK(s, last)
Definition: deflate.cc:1493
int match_available
Definition: deflate.h:158
local uInt longest_match(deflate_state *s, IPos cur_match)
Definition: deflate.cc:1099
uInt last_lit
Definition: deflate.h:239
uInt strstart
Definition: deflate.h:159
IPos prev_match
Definition: deflate.h:157
#define Tracevv(x)
Definition: zutil.h:232
unsigned IPos
Definition: deflate.h:91
local block_state deflate_stored ( deflate_state s,
int  flush 
)

Definition at line 1507 of file deflate.cc.

References Assert, block_done, internal_state::block_start, fill_window(), finish_done, FLUSH_BLOCK, internal_state::insert, internal_state::lookahead, MAX_DIST, need_more, internal_state::pending_buf_size, internal_state::strstart, internal_state::w_size, Z_FINISH, and Z_NO_FLUSH.

1508 {
1509  /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
1510  * to pending_buf_size, and each stored block has a 5 byte header:
1511  */
1512  ulg max_block_size = 0xffff;
1513  ulg max_start;
1514 
1515  if (max_block_size > s->pending_buf_size - 5) {
1516  max_block_size = s->pending_buf_size - 5;
1517  }
1518 
1519  /* Copy as much as possible from input to output: */
1520  for (;;) {
1521  /* Fill the window as much as possible: */
1522  if (s->lookahead <= 1) {
1523 
1524  Assert(s->strstart < s->w_size+MAX_DIST(s) ||
1525  s->block_start >= (long)s->w_size, "slide too late");
1526 
1527  fill_window(s);
1528  if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
1529 
1530  if (s->lookahead == 0) break; /* flush the current block */
1531  }
1532  Assert(s->block_start >= 0L, "block gone");
1533 
1534  s->strstart += s->lookahead;
1535  s->lookahead = 0;
1536 
1537  /* Emit a stored block if pending_buf will be full: */
1538  max_start = s->block_start + max_block_size;
1539  if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
1540  /* strstart == 0 is possible when wraparound on 16-bit machine */
1541  s->lookahead = (uInt)(s->strstart - max_start);
1542  s->strstart = (uInt)max_start;
1543  FLUSH_BLOCK(s, 0);
1544  }
1545  /* Flush if we may have to slide, otherwise block_start may become
1546  * negative and the data will be gone:
1547  */
1548  if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
1549  FLUSH_BLOCK(s, 0);
1550  }
1551  }
1552  s->insert = 0;
1553  if (flush == Z_FINISH) {
1554  FLUSH_BLOCK(s, 1);
1555  return finish_done;
1556  }
1557  if ((long)s->strstart > s->block_start)
1558  FLUSH_BLOCK(s, 0);
1559  return block_done;
1560 }
#define Z_NO_FLUSH
Definition: zlib.h:164
#define Assert(cond, msg)
Definition: zutil.h:229
uInt lookahead
Definition: deflate.h:161
#define MAX_DIST(s)
Definition: deflate.h:286
#define Z_FINISH
Definition: zlib.h:168
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
#define FLUSH_BLOCK(s, last)
Definition: deflate.cc:1493
long block_start
Definition: deflate.h:151
unsigned long ulg
Definition: zutil.h:45
uInt strstart
Definition: deflate.h:159
ulg pending_buf_size
Definition: deflate.h:101
uLong ZEXPORT deflateBound ( z_streamp  strm,
uLong  sourceLen 
)

Definition at line 531 of file deflate.cc.

References internal_state::gzhead, internal_state::hash_bits, internal_state::strstart, internal_state::w_bits, internal_state::wrap, and Z_NULL.

532 {
533  deflate_state *s;
534  uLong complen, wraplen;
535  Bytef *str;
536 
537  /* conservative upper bound for compressed data */
538  complen = sourceLen +
539  ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
540 
541  /* if can't get parameters, return conservative bound plus zlib wrapper */
542  if (strm == Z_NULL || strm->state == Z_NULL)
543  return complen + 6;
544 
545  /* compute wrapper length */
546  s = strm->state;
547  switch (s->wrap) {
548  case 0: /* raw deflate */
549  wraplen = 0;
550  break;
551  case 1: /* zlib wrapper */
552  wraplen = 6 + (s->strstart ? 4 : 0);
553  break;
554  case 2: /* gzip wrapper */
555  wraplen = 18;
556  if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
557  if (s->gzhead->extra != Z_NULL)
558  wraplen += 2 + s->gzhead->extra_len;
559  str = s->gzhead->name;
560  if (str != Z_NULL)
561  do {
562  wraplen++;
563  } while (*str++);
564  str = s->gzhead->comment;
565  if (str != Z_NULL)
566  do {
567  wraplen++;
568  } while (*str++);
569  if (s->gzhead->hcrc)
570  wraplen += 2;
571  }
572  break;
573  default: /* for compiler happiness */
574  wraplen = 6;
575  }
576 
577  /* if not default parameters, return conservative bound */
578  if (s->w_bits != 15 || s->hash_bits != 8 + 7)
579  return complen + wraplen;
580 
581  /* default settings: return tight bound for that case */
582  return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
583  (sourceLen >> 25) + 13 - 6 + wraplen;
584 }
const XML_Char * s
#define Z_NULL
Definition: zlib.h:208
int ZEXPORT deflateCopy ( z_streamp  dest,
z_streamp  source 
)

Definition at line 971 of file deflate.cc.

References deflateEnd(), Z_MEM_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, ZALLOC, and zmemcpy().

972 {
973 #ifdef MAXSEG_64K
974  return Z_STREAM_ERROR;
975 #else
976  deflate_state *ds;
977  deflate_state *ss;
978  ushf *overlay;
979 
980 
981  if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
982  return Z_STREAM_ERROR;
983  }
984 
985  ss = source->state;
986 
987  zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
988 
989  ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
990  if (ds == Z_NULL) return Z_MEM_ERROR;
991  dest->state = (struct internal_state FAR *) ds;
992  zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
993  ds->strm = dest;
994 
995  ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
996  ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
997  ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
998  overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
999  ds->pending_buf = (uchf *) overlay;
1000 
1001  if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
1002  ds->pending_buf == Z_NULL) {
1003  deflateEnd (dest);
1004  return Z_MEM_ERROR;
1005  }
1006  /* following zmemcpy do not work for 16-bit MSDOS */
1007  zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
1008  zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
1009  zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
1010  zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
1011 
1012  ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
1013  ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
1014  ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
1015 
1016  ds->l_desc.dyn_tree = ds->dyn_ltree;
1017  ds->d_desc.dyn_tree = ds->dyn_dtree;
1018  ds->bl_desc.dyn_tree = ds->bl_tree;
1019 
1020  return Z_OK;
1021 #endif /* MAXSEG_64K */
1022 }
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.cc:937
ush FAR ushf
Definition: zutil.h:44
ush Pos
Definition: deflate.h:89
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.cc:150
#define Z_STREAM_ERROR
Definition: zlib.h:177
#define ZALLOC(strm, items, size)
Definition: zutil.h:243
unsigned short ush
Definition: zutil.h:43
Pos FAR Posf
Definition: deflate.h:90
#define Z_MEM_ERROR
Definition: zlib.h:179
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
uch FAR uchf
Definition: zutil.h:42
int ZEXPORT deflateEnd ( z_streamp  strm)

Definition at line 937 of file deflate.cc.

References BUSY_STATE, COMMENT_STATE, EXTRA_STATE, FINISH_STATE, HCRC_STATE, INIT_STATE, NAME_STATE, status, TRY_FREE, Z_DATA_ERROR, Z_NULL, Z_OK, Z_STREAM_ERROR, and ZFREE.

Referenced by compress2(), deflateCopy(), deflateInit2_(), cheprep::DeflateOutputStreamBuffer::finish(), and gzclose_w().

938 {
939  int status;
940 
941  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
942 
943  status = strm->state->status;
944  if (status != INIT_STATE &&
945  status != EXTRA_STATE &&
946  status != NAME_STATE &&
947  status != COMMENT_STATE &&
948  status != HCRC_STATE &&
949  status != BUSY_STATE &&
950  status != FINISH_STATE) {
951  return Z_STREAM_ERROR;
952  }
953 
954  /* Deallocate in reverse order of allocations: */
955  TRY_FREE(strm, strm->state->pending_buf);
956  TRY_FREE(strm, strm->state->head);
957  TRY_FREE(strm, strm->state->prev);
958  TRY_FREE(strm, strm->state->window);
959 
960  ZFREE(strm, strm->state);
961  strm->state = Z_NULL;
962 
963  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
964 }
#define INIT_STATE
Definition: deflate.h:54
#define HCRC_STATE
Definition: deflate.h:58
#define Z_STREAM_ERROR
Definition: zlib.h:177
#define BUSY_STATE
Definition: deflate.h:59
z_streamp strm
Definition: deflate.h:98
#define Z_DATA_ERROR
Definition: zlib.h:178
#define ZFREE(strm, addr)
Definition: zutil.h:245
#define COMMENT_STATE
Definition: deflate.h:57
int status
Definition: tracer.cxx:24
#define NAME_STATE
Definition: deflate.h:56
#define TRY_FREE(s, p)
Definition: zutil.h:246
#define FINISH_STATE
Definition: deflate.h:60
#define Z_OK
Definition: zlib.h:173
#define EXTRA_STATE
Definition: deflate.h:55
#define Z_NULL
Definition: zlib.h:208
int ZEXPORT deflateInit2_ ( z_streamp  strm,
int  level,
int  method,
int  windowBits,
int  memLevel,
int  strategy,
const char *  version,
int  stream_size 
)

Definition at line 209 of file deflate.cc.

References internal_state::d_buf, deflateEnd(), deflateReset(), ERR_MSG, FINISH_STATE, internal_state::gzhead, internal_state::hash_bits, internal_state::hash_mask, internal_state::hash_shift, internal_state::hash_size, internal_state::head, internal_state::high_water, internal_state::l_buf, internal_state::level, internal_state::lit_bufsize, internal_state::method, MIN_MATCH, internal_state::pending_buf, internal_state::pending_buf_size, internal_state::prev, internal_state::status, internal_state::strategy, internal_state::strm, internal_state::w_bits, internal_state::w_mask, internal_state::w_size, internal_state::window, internal_state::wrap, G4INCL::String::wrap(), Z_DEFAULT_COMPRESSION, Z_DEFLATED, Z_FIXED, Z_MEM_ERROR, Z_NULL, Z_STREAM_ERROR, Z_VERSION_ERROR, ZALLOC, zcalloc(), zcfree(), and ZLIB_VERSION.

Referenced by deflateInit_().

211 {
212  deflate_state *s;
213  int wrap = 1;
214  static const char my_version[] = ZLIB_VERSION;
215 
216  ushf *overlay;
217  /* We overlay pending_buf and d_buf+l_buf. This works since the average
218  * output size for (length,distance) codes is <= 24 bits.
219  */
220 
221  if (version == Z_NULL || version[0] != my_version[0] ||
222  stream_size != sizeof(z_stream)) {
223  return Z_VERSION_ERROR;
224  }
225  if (strm == Z_NULL) return Z_STREAM_ERROR;
226 
227  strm->msg = Z_NULL;
228  if (strm->zalloc == (alloc_func)0) {
229 #ifdef Z_SOLO
230  return Z_STREAM_ERROR;
231 #else
232  strm->zalloc = zcalloc;
233  strm->opaque = (voidpf)0;
234 #endif
235  }
236  if (strm->zfree == (free_func)0)
237 #ifdef Z_SOLO
238  return Z_STREAM_ERROR;
239 #else
240  strm->zfree = zcfree;
241 #endif
242 
243 #ifdef FASTEST
244  if (level != 0) level = 1;
245 #else
246  if (level == Z_DEFAULT_COMPRESSION) level = 6;
247 #endif
248 
249  if (windowBits < 0) { /* suppress zlib wrapper */
250  wrap = 0;
251  windowBits = -windowBits;
252  }
253 #ifdef GZIP
254  else if (windowBits > 15) {
255  wrap = 2; /* write gzip wrapper instead */
256  windowBits -= 16;
257  }
258 #endif
259  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
260  windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
261  strategy < 0 || strategy > Z_FIXED) {
262  return Z_STREAM_ERROR;
263  }
264  if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
265  s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
266  if (s == Z_NULL) return Z_MEM_ERROR;
267  strm->state = (struct internal_state FAR *)s;
268  s->strm = strm;
269 
270  s->wrap = wrap;
271  s->gzhead = Z_NULL;
272  s->w_bits = windowBits;
273  s->w_size = 1 << s->w_bits;
274  s->w_mask = s->w_size - 1;
275 
276  s->hash_bits = memLevel + 7;
277  s->hash_size = 1 << s->hash_bits;
278  s->hash_mask = s->hash_size - 1;
279  s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
280 
281  s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
282  s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
283  s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
284 
285  s->high_water = 0; /* nothing written to s->window yet */
286 
287  s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
288 
289  overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
290  s->pending_buf = (uchf *) overlay;
291  s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
292 
293  if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
294  s->pending_buf == Z_NULL) {
295  s->status = FINISH_STATE;
296  strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
297  deflateEnd (strm);
298  return Z_MEM_ERROR;
299  }
300  s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
301  s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
302 
303  s->level = level;
304  s->strategy = strategy;
305  s->method = (Byte)method;
306 
307  return deflateReset(strm);
308 }
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.cc:937
const XML_Char * version
uInt hash_bits
Definition: deflate.h:141
ush FAR ushf
Definition: zutil.h:44
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.cc:294
Bytef * window
Definition: deflate.h:116
#define MIN_MATCH
Definition: zutil.h:75
uInt hash_mask
Definition: deflate.h:142
const XML_Char * s
ush Pos
Definition: deflate.h:89
uInt hash_shift
Definition: deflate.h:144
Posf * prev
Definition: deflate.h:131
#define Z_STREAM_ERROR
Definition: zlib.h:177
gz_headerp gzhead
Definition: deflate.h:105
#define Z_FIXED
Definition: zlib.h:195
ulg high_water
Definition: deflate.h:266
#define ERR_MSG(err)
Definition: zutil.h:50
#define ZALLOC(strm, items, size)
Definition: zutil.h:243
z_streamp strm
Definition: deflate.h:98
Posf * head
Definition: deflate.h:137
#define Z_DEFLATED
Definition: zlib.h:205
unsigned short ush
Definition: zutil.h:43
uchf * l_buf
Definition: deflate.h:217
Pos FAR Posf
Definition: deflate.h:90
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.cc:301
#define Z_MEM_ERROR
Definition: zlib.h:179
Bytef * pending_buf
Definition: deflate.h:100
uInt lit_bufsize
Definition: deflate.h:219
ushf * d_buf
Definition: deflate.h:241
#define ZLIB_VERSION
Definition: zlib.h:40
#define FINISH_STATE
Definition: deflate.h:60
#define Z_VERSION_ERROR
Definition: zlib.h:181
unsigned long ulg
Definition: zutil.h:45
ulg pending_buf_size
Definition: deflate.h:101
#define Z_NULL
Definition: zlib.h:208
uch FAR uchf
Definition: zutil.h:42
int ZEXPORT deflateReset(z_streamp strm)
Definition: deflate.cc:411
uInt hash_size
Definition: deflate.h:140
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:189
void wrap(std::string &str, const size_t lineLength=78, const std::string &separators=" \t")
int ZEXPORT deflateInit_ ( z_streamp  strm,
int  level,
const char *  version,
int  stream_size 
)

Definition at line 201 of file deflate.cc.

References DEF_MEM_LEVEL, deflateInit2_(), Z_DEFAULT_STRATEGY, and Z_DEFLATED.

202 {
203  return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
204  Z_DEFAULT_STRATEGY, version, stream_size);
205  /* To do: ignore strm->next_in if we use it as window */
206 }
const XML_Char * version
z_streamp strm
Definition: deflate.h:98
#define Z_DEFLATED
Definition: zlib.h:205
#define DEF_MEM_LEVEL
Definition: gzguts.h:127
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:196
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)
Definition: deflate.cc:209
int ZEXPORT deflateParams ( z_streamp  strm,
int  level,
int  strategy 
)

Definition at line 465 of file deflate.cc.

References deflate(), internal_state::good_match, internal_state::level, internal_state::max_chain_length, internal_state::max_lazy_match, internal_state::nice_match, internal_state::strategy, Z_BLOCK, Z_DEFAULT_COMPRESSION, Z_FIXED, Z_NULL, Z_OK, and Z_STREAM_ERROR.

Referenced by gzsetparams().

466 {
467  deflate_state *s;
468  compress_func func;
469  int err = Z_OK;
470 
471  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
472  s = strm->state;
473 
474 #ifdef FASTEST
475  if (level != 0) level = 1;
476 #else
477  if (level == Z_DEFAULT_COMPRESSION) level = 6;
478 #endif
479  if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
480  return Z_STREAM_ERROR;
481  }
482  func = configuration_table[s->level].func;
483 
484  if ((strategy != s->strategy || func != configuration_table[level].func) &&
485  strm->total_in != 0) {
486  /* Flush the last buffer: */
487  err = deflate(strm, Z_BLOCK);
488  }
489  if (s->level != level) {
490  s->level = level;
495  }
496  s->strategy = strategy;
497  return err;
498 }
uInt good_match
Definition: deflate.h:188
#define Z_BLOCK
Definition: zlib.h:169
uInt max_lazy_match
Definition: deflate.h:174
const XML_Char * s
ush good_length
Definition: deflate.cc:118
#define Z_STREAM_ERROR
Definition: zlib.h:177
#define Z_FIXED
Definition: zlib.h:195
z_streamp strm
Definition: deflate.h:98
compress_func func
Definition: deflate.cc:122
ush max_chain
Definition: deflate.cc:121
ush max_lazy
Definition: deflate.cc:119
local const config configuration_table[10]
Definition: deflate.cc:131
uInt max_chain_length
Definition: deflate.h:168
int nice_match
Definition: deflate.h:191
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.cc:625
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
ush nice_length
Definition: deflate.cc:120
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:189
int ZEXPORT deflatePending ( z_streamp  strm,
unsigned *  pending,
int bits 
)

Definition at line 431 of file deflate.cc.

References Z_NULL, Z_OK, and Z_STREAM_ERROR.

432 {
433  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
434  if (pending != Z_NULL)
435  *pending = strm->state->pending;
436  if (bits != Z_NULL)
437  *bits = strm->state->bi_valid;
438  return Z_OK;
439 }
#define Z_STREAM_ERROR
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:98
uInt pending
Definition: deflate.h:103
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
int ZEXPORT deflatePrime ( z_streamp  strm,
int  bits,
int  value 
)

Definition at line 442 of file deflate.cc.

References _tr_flush_bits(), internal_state::bi_buf, internal_state::bi_valid, Buf_size, internal_state::d_buf, internal_state::pending_out, Z_BUF_ERROR, Z_NULL, Z_OK, and Z_STREAM_ERROR.

443 {
444  deflate_state *s;
445  int put;
446 
447  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
448  s = strm->state;
449  if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
450  return Z_BUF_ERROR;
451  do {
452  put = Buf_size - s->bi_valid;
453  if (put > bits)
454  put = bits;
455  s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
456  s->bi_valid += put;
457  _tr_flush_bits(s);
458  value >>= put;
459  bits -= put;
460  } while (bits);
461  return Z_OK;
462 }
const XML_Char * s
Bytef * pending_out
Definition: deflate.h:102
#define Z_STREAM_ERROR
Definition: zlib.h:177
#define Buf_size
Definition: deflate.h:51
z_streamp strm
Definition: deflate.h:98
unsigned short ush
Definition: zutil.h:43
ushf * d_buf
Definition: deflate.h:241
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
Definition: trees.cc:854
#define Z_BUF_ERROR
Definition: zlib.h:180
const XML_Char int const XML_Char * value
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
int ZEXPORT deflateReset ( z_streamp  strm)

Definition at line 411 of file deflate.cc.

References deflateResetKeep(), lm_init(), and Z_OK.

Referenced by deflateInit2_(), and gz_comp().

412 {
413  int ret;
414 
415  ret = deflateResetKeep(strm);
416  if (ret == Z_OK)
417  lm_init(strm->state);
418  return ret;
419 }
int ZEXPORT deflateResetKeep(z_streamp strm)
Definition: deflate.cc:377
local void lm_init(deflate_state *s)
Definition: deflate.cc:1058
z_streamp strm
Definition: deflate.h:98
#define Z_OK
Definition: zlib.h:173
int ZEXPORT deflateResetKeep ( z_streamp  strm)

Definition at line 377 of file deflate.cc.

References _tr_init(), adler32(), BUSY_STATE, crc32(), INIT_STATE, internal_state::last_flush, internal_state::pending, internal_state::pending_buf, internal_state::pending_out, internal_state::status, internal_state::wrap, Z_NO_FLUSH, Z_NULL, Z_OK, Z_STREAM_ERROR, and Z_UNKNOWN.

Referenced by deflateReset().

378 {
379  deflate_state *s;
380 
381  if (strm == Z_NULL || strm->state == Z_NULL ||
382  strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
383  return Z_STREAM_ERROR;
384  }
385 
386  strm->total_in = strm->total_out = 0;
387  strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
388  strm->data_type = Z_UNKNOWN;
389 
390  s = (deflate_state *)strm->state;
391  s->pending = 0;
392  s->pending_out = s->pending_buf;
393 
394  if (s->wrap < 0) {
395  s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
396  }
397  s->status = s->wrap ? INIT_STATE : BUSY_STATE;
398  strm->adler =
399 #ifdef GZIP
400  s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
401 #endif
402  adler32(0L, Z_NULL, 0);
403  s->last_flush = Z_NO_FLUSH;
404 
405  _tr_init(s);
406 
407  return Z_OK;
408 }
#define INIT_STATE
Definition: deflate.h:54
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.cc:202
#define Z_NO_FLUSH
Definition: zlib.h:164
void ZLIB_INTERNAL _tr_init(deflate_state *s)
Definition: trees.cc:378
#define Z_UNKNOWN
Definition: zlib.h:202
const XML_Char * s
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.cc:65
Bytef * pending_out
Definition: deflate.h:102
#define Z_STREAM_ERROR
Definition: zlib.h:177
#define BUSY_STATE
Definition: deflate.h:59
z_streamp strm
Definition: deflate.h:98
Bytef * pending_buf
Definition: deflate.h:100
uInt pending
Definition: deflate.h:103
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
int last_flush
Definition: deflate.h:108
int ZEXPORT deflateSetDictionary ( z_streamp  strm,
const Bytef *  dictionary,
uInt  dictLength 
)

Definition at line 311 of file deflate.cc.

References adler32(), internal_state::block_start, CLEAR_HASH, fill_window(), internal_state::head, INIT_STATE, internal_state::ins_h, internal_state::insert, internal_state::lookahead, internal_state::match_available, internal_state::match_length, MIN_MATCH, n, internal_state::prev, internal_state::prev_length, internal_state::status, internal_state::strstart, UPDATE_HASH, internal_state::w_mask, internal_state::w_size, internal_state::window, internal_state::wrap, G4INCL::String::wrap(), Z_NULL, Z_OK, and Z_STREAM_ERROR.

312 {
313  deflate_state *s;
314  uInt str, n;
315  int wrap;
316  unsigned avail;
317  unsigned char *next;
318 
319  if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
320  return Z_STREAM_ERROR;
321  s = strm->state;
322  wrap = s->wrap;
323  if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
324  return Z_STREAM_ERROR;
325 
326  /* when using zlib wrappers, compute Adler-32 for provided dictionary */
327  if (wrap == 1)
328  strm->adler = adler32(strm->adler, dictionary, dictLength);
329  s->wrap = 0; /* avoid computing Adler-32 in read_buf */
330 
331  /* if dictionary would fill window, just replace the history */
332  if (dictLength >= s->w_size) {
333  if (wrap == 0) { /* already empty otherwise */
334  CLEAR_HASH(s);
335  s->strstart = 0;
336  s->block_start = 0L;
337  s->insert = 0;
338  }
339  dictionary += dictLength - s->w_size; /* use the tail */
340  dictLength = s->w_size;
341  }
342 
343  /* insert dictionary into window and hash */
344  avail = strm->avail_in;
345  next = strm->next_in;
346  strm->avail_in = dictLength;
347  strm->next_in = (Bytef *)dictionary;
348  fill_window(s);
349  while (s->lookahead >= MIN_MATCH) {
350  str = s->strstart;
351  n = s->lookahead - (MIN_MATCH-1);
352  do {
353  UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
354 #ifndef FASTEST
355  s->prev[str & s->w_mask] = s->head[s->ins_h];
356 #endif
357  s->head[s->ins_h] = (Pos)str;
358  str++;
359  } while (--n);
360  s->strstart = str;
361  s->lookahead = MIN_MATCH-1;
362  fill_window(s);
363  }
364  s->strstart += s->lookahead;
365  s->block_start = (long)s->strstart;
366  s->insert = s->lookahead;
367  s->lookahead = 0;
368  s->match_length = s->prev_length = MIN_MATCH-1;
369  s->match_available = 0;
370  strm->next_in = next;
371  strm->avail_in = avail;
372  s->wrap = wrap;
373  return Z_OK;
374 }
#define INIT_STATE
Definition: deflate.h:54
Bytef * window
Definition: deflate.h:116
#define MIN_MATCH
Definition: zutil.h:75
#define UPDATE_HASH(s, h, c)
Definition: deflate.cc:167
uInt match_length
Definition: deflate.h:156
const XML_Char * s
ush Pos
Definition: deflate.h:89
uInt prev_length
Definition: deflate.h:163
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.cc:65
Posf * prev
Definition: deflate.h:131
#define Z_STREAM_ERROR
Definition: zlib.h:177
uInt lookahead
Definition: deflate.h:161
local void fill_window(deflate_state *s)
Definition: deflate.cc:1334
z_streamp strm
Definition: deflate.h:98
Posf * head
Definition: deflate.h:137
const G4int n
long block_start
Definition: deflate.h:151
int match_available
Definition: deflate.h:158
#define CLEAR_HASH(s)
Definition: deflate.cc:196
uInt strstart
Definition: deflate.h:159
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
void wrap(std::string &str, const size_t lineLength=78, const std::string &separators=" \t")
int ZEXPORT deflateSetHeader ( z_streamp  strm,
gz_headerp  head 
)

Definition at line 422 of file deflate.cc.

References internal_state::head, Z_NULL, Z_OK, and Z_STREAM_ERROR.

423 {
424  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
425  if (strm->state->wrap != 2) return Z_STREAM_ERROR;
426  strm->state->gzhead = head;
427  return Z_OK;
428 }
#define Z_STREAM_ERROR
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:98
Posf * head
Definition: deflate.h:137
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
int ZEXPORT deflateTune ( z_streamp  strm,
int  good_length,
int  max_lazy,
int  nice_length,
int  max_chain 
)

Definition at line 501 of file deflate.cc.

References internal_state::good_match, internal_state::max_chain_length, internal_state::max_lazy_match, internal_state::nice_match, Z_NULL, Z_OK, and Z_STREAM_ERROR.

502 {
503  deflate_state *s;
504 
505  if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
506  s = strm->state;
507  s->good_match = good_length;
508  s->max_lazy_match = max_lazy;
509  s->nice_match = nice_length;
510  s->max_chain_length = max_chain;
511  return Z_OK;
512 }
uInt good_match
Definition: deflate.h:188
uInt max_lazy_match
Definition: deflate.h:174
const XML_Char * s
#define Z_STREAM_ERROR
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:98
uInt max_chain_length
Definition: deflate.h:168
int nice_match
Definition: deflate.h:191
#define Z_OK
Definition: zlib.h:173
#define Z_NULL
Definition: zlib.h:208
local void fill_window ( deflate_state s)

Definition at line 1334 of file deflate.cc.

References Assert, internal_state::block_start, curr(), internal_state::hash_size, internal_state::head, internal_state::high_water, internal_state::ins_h, internal_state::insert, internal_state::lookahead, python.hepunit::m, internal_state::match_start, MAX_DIST, MIN_LOOKAHEAD, MIN_MATCH, n, NIL, internal_state::prev, read_buf(), internal_state::strm, internal_state::strstart, times, UPDATE_HASH, internal_state::w_mask, internal_state::w_size, WIN_INIT, internal_state::window, internal_state::window_size, zmemcpy(), and zmemzero().

Referenced by deflate_fast(), deflate_huff(), deflate_rle(), deflate_slow(), deflate_stored(), and deflateSetDictionary().

1335 {
1336  register unsigned n, m;
1337  register Posf *p;
1338  unsigned more; /* Amount of free space at the end of the window. */
1339  uInt wsize = s->w_size;
1340 
1341  Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
1342 
1343  do {
1344  more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
1345 
1346  /* Deal with !@#$% 64K limit: */
1347  if (sizeof(int) <= 2) {
1348  if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
1349  more = wsize;
1350 
1351  } else if (more == (unsigned)(-1)) {
1352  /* Very unlikely, but possible on 16 bit machine if
1353  * strstart == 0 && lookahead == 1 (input done a byte at time)
1354  */
1355  more--;
1356  }
1357  }
1358 
1359  /* If the window is almost full and there is insufficient lookahead,
1360  * move the upper half to the lower one to make room in the upper half.
1361  */
1362  if (s->strstart >= wsize+MAX_DIST(s)) {
1363 
1364  zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
1365  s->match_start -= wsize;
1366  s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
1367  s->block_start -= (long) wsize;
1368 
1369  /* Slide the hash table (could be avoided with 32 bit values
1370  at the expense of memory usage). We slide even when level == 0
1371  to keep the hash table consistent if we switch back to level > 0
1372  later. (Using level 0 permanently is not an optimal usage of
1373  zlib, so we don't care about this pathological case.)
1374  */
1375  n = s->hash_size;
1376  p = &s->head[n];
1377  do {
1378  m = *--p;
1379  *p = (Pos)(m >= wsize ? m-wsize : NIL);
1380  } while (--n);
1381 
1382  n = wsize;
1383 #ifndef FASTEST
1384  p = &s->prev[n];
1385  do {
1386  m = *--p;
1387  *p = (Pos)(m >= wsize ? m-wsize : NIL);
1388  /* If n is not on any hash chain, prev[n] is garbage but
1389  * its value will never be used.
1390  */
1391  } while (--n);
1392 #endif
1393  more += wsize;
1394  }
1395  if (s->strm->avail_in == 0) break;
1396 
1397  /* If there was no sliding:
1398  * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
1399  * more == window_size - lookahead - strstart
1400  * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
1401  * => more >= window_size - 2*WSIZE + 2
1402  * In the BIG_MEM or MMAP case (not yet supported),
1403  * window_size == input_size + MIN_LOOKAHEAD &&
1404  * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
1405  * Otherwise, window_size == 2*WSIZE so more >= 2.
1406  * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
1407  */
1408  Assert(more >= 2, "more < 2");
1409 
1410  n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
1411  s->lookahead += n;
1412 
1413  /* Initialize the hash value now that we have some input: */
1414  if (s->lookahead + s->insert >= MIN_MATCH) {
1415  uInt str = s->strstart - s->insert;
1416  s->ins_h = s->window[str];
1417  UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
1418 #if MIN_MATCH != 3
1419  Call UPDATE_HASH() MIN_MATCH-3 more times
1420 #endif
1421  while (s->insert) {
1422  UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
1423 #ifndef FASTEST
1424  s->prev[str & s->w_mask] = s->head[s->ins_h];
1425 #endif
1426  s->head[s->ins_h] = (Pos)str;
1427  str++;
1428  s->insert--;
1429  if (s->lookahead + s->insert < MIN_MATCH)
1430  break;
1431  }
1432  }
1433  /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
1434  * but this is not important since only literal bytes will be emitted.
1435  */
1436 
1437  } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1438 
1439  /* If the WIN_INIT bytes after the end of the current data have never been
1440  * written, then zero those bytes in order to avoid memory check reports of
1441  * the use of uninitialized (or uninitialised as Julian writes) bytes by
1442  * the longest match routines. Update the high water mark for the next
1443  * time through here. WIN_INIT is set to MAX_MATCH since the longest match
1444  * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
1445  */
1446  if (s->high_water < s->window_size) {
1447  ulg curr = s->strstart + (ulg)(s->lookahead);
1448  ulg init;
1449 
1450  if (s->high_water < curr) {
1451  /* Previous high water mark below current data -- zero WIN_INIT
1452  * bytes or up to end of window, whichever is less.
1453  */
1454  init = s->window_size - curr;
1455  if (init > WIN_INIT)
1456  init = WIN_INIT;
1457  zmemzero(s->window + curr, (unsigned)init);
1458  s->high_water = curr + init;
1459  }
1460  else if (s->high_water < (ulg)curr + WIN_INIT) {
1461  /* High water mark at or above current data, but below current data
1462  * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
1463  * to end of window, whichever is less.
1464  */
1465  init = (ulg)curr + WIN_INIT - s->high_water;
1466  if (init > s->window_size - s->high_water)
1467  init = s->window_size - s->high_water;
1468  zmemzero(s->window + s->high_water, (unsigned)init);
1469  s->high_water += init;
1470  }
1471  }
1472 
1474  "not enough room for search");
1475 }
local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.cc:1031
Bytef * window
Definition: deflate.h:116
#define MIN_MATCH
Definition: zutil.h:75
#define UPDATE_HASH(s, h, c)
Definition: deflate.cc:167
#define NIL
Definition: deflate.cc:104
ush Pos
Definition: deflate.h:89
const char * p
Definition: xmltok.h:285
#define Assert(cond, msg)
Definition: zutil.h:229
Definition: G4Pair.hh:150
Posf * prev
Definition: deflate.h:131
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.cc:150
uInt match_start
Definition: deflate.h:160
ulg high_water
Definition: deflate.h:266
uInt lookahead
Definition: deflate.h:161
subroutine curr(MNUM, PIM1, PIM2, PIM3, PIM4, HADCUR)
Definition: leptonew.f:2041
#define WIN_INIT
Definition: deflate.h:291
#define MAX_DIST(s)
Definition: deflate.h:286
ulg window_size
Definition: deflate.h:126
void ZLIB_INTERNAL zmemzero(Bytef *dest, uInt len)
Definition: zutil.cc:168
#define MIN_LOOKAHEAD
Definition: deflate.h:281
z_streamp strm
Definition: deflate.h:98
Posf * head
Definition: deflate.h:137
Pos FAR Posf
Definition: deflate.h:90
const G4int n
long block_start
Definition: deflate.h:151
#define times
unsigned long ulg
Definition: zutil.h:45
uInt strstart
Definition: deflate.h:159
uInt hash_size
Definition: deflate.h:140
local void flush_pending ( z_streamp  strm)

Definition at line 603 of file deflate.cc.

References _tr_flush_bits(), internal_state::pending, internal_state::pending_buf, internal_state::pending_out, and zmemcpy().

Referenced by deflate().

604 {
605  unsigned len;
606  deflate_state *s = strm->state;
607 
608  _tr_flush_bits(s);
609  len = s->pending;
610  if (len > strm->avail_out) len = strm->avail_out;
611  if (len == 0) return;
612 
613  zmemcpy(strm->next_out, s->pending_out, len);
614  strm->next_out += len;
615  s->pending_out += len;
616  strm->total_out += len;
617  strm->avail_out -= len;
618  s->pending -= len;
619  if (s->pending == 0) {
620  s->pending_out = s->pending_buf;
621  }
622 }
const XML_Char * s
Bytef * pending_out
Definition: deflate.h:102
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.cc:150
z_streamp strm
Definition: deflate.h:98
Bytef * pending_buf
Definition: deflate.h:100
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
Definition: trees.cc:854
uInt pending
Definition: deflate.h:103
const XML_Char int len
local void lm_init ( deflate_state s)

Definition at line 1058 of file deflate.cc.

References internal_state::block_start, CLEAR_HASH, internal_state::good_match, internal_state::ins_h, internal_state::insert, internal_state::level, internal_state::lookahead, internal_state::match_available, internal_state::match_length, internal_state::max_chain_length, internal_state::max_lazy_match, MIN_MATCH, internal_state::nice_match, internal_state::prev_length, internal_state::strstart, internal_state::w_size, and internal_state::window_size.

Referenced by deflateReset().

1059 {
1060  s->window_size = (ulg)2L*s->w_size;
1061 
1062  CLEAR_HASH(s);
1063 
1064  /* Set the default configuration parameters:
1065  */
1070 
1071  s->strstart = 0;
1072  s->block_start = 0L;
1073  s->lookahead = 0;
1074  s->insert = 0;
1075  s->match_length = s->prev_length = MIN_MATCH-1;
1076  s->match_available = 0;
1077  s->ins_h = 0;
1078 #ifndef FASTEST
1079 #ifdef ASMV
1080  match_init(); /* initialize the asm code */
1081 #endif
1082 #endif
1083 }
uInt good_match
Definition: deflate.h:188
#define MIN_MATCH
Definition: zutil.h:75
uInt max_lazy_match
Definition: deflate.h:174
uInt match_length
Definition: deflate.h:156
uInt prev_length
Definition: deflate.h:163
ush good_length
Definition: deflate.cc:118
uInt lookahead
Definition: deflate.h:161
ulg window_size
Definition: deflate.h:126
ush max_chain
Definition: deflate.cc:121
long block_start
Definition: deflate.h:151
ush max_lazy
Definition: deflate.cc:119
local const config configuration_table[10]
Definition: deflate.cc:131
int match_available
Definition: deflate.h:158
#define CLEAR_HASH(s)
Definition: deflate.cc:196
uInt max_chain_length
Definition: deflate.h:168
int nice_match
Definition: deflate.h:191
unsigned long ulg
Definition: zutil.h:45
uInt strstart
Definition: deflate.h:159
ush nice_length
Definition: deflate.cc:120
local uInt longest_match ( deflate_state s,
IPos  cur_match 
)

Definition at line 1099 of file deflate.cc.

References Assert, internal_state::good_match, internal_state::hash_bits, int(), internal_state::lookahead, internal_state::match_start, internal_state::max_chain_length, MAX_DIST, MAX_MATCH, MIN_LOOKAHEAD, internal_state::nice_match, NIL, internal_state::prev, internal_state::prev_length, internal_state::strstart, internal_state::w_mask, internal_state::window, and internal_state::window_size.

Referenced by deflate_fast(), and deflate_slow().

1100 {
1101  unsigned chain_length = s->max_chain_length;/* max hash chain length */
1102  register Bytef *scan = s->window + s->strstart; /* current string */
1103  register Bytef *match; /* matched string */
1104  register int len; /* length of current match */
1105  int best_len = s->prev_length; /* best match length so far */
1106  int nice_match = s->nice_match; /* stop if match long enough */
1107  IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
1108  s->strstart - (IPos)MAX_DIST(s) : NIL;
1109  /* Stop when cur_match becomes <= limit. To simplify the code,
1110  * we prevent matches with the string of window index 0.
1111  */
1112  Posf *prev = s->prev;
1113  uInt wmask = s->w_mask;
1114 
1115 #ifdef UNALIGNED_OK
1116  /* Compare two bytes at a time. Note: this is not always beneficial.
1117  * Try with and without -DUNALIGNED_OK to check.
1118  */
1119  register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
1120  register ush scan_start = *(ushf*)scan;
1121  register ush scan_end = *(ushf*)(scan+best_len-1);
1122 #else
1123  register Bytef *strend = s->window + s->strstart + MAX_MATCH;
1124  register Byte scan_end1 = scan[best_len-1];
1125  register Byte scan_end = scan[best_len];
1126 #endif
1127 
1128  /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
1129  * It is easy to get rid of this optimization if necessary.
1130  */
1131  Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
1132 
1133  /* Do not waste too much time if we already have a good match: */
1134  if (s->prev_length >= s->good_match) {
1135  chain_length >>= 2;
1136  }
1137  /* Do not look for matches beyond the end of the input. This is necessary
1138  * to make deflate deterministic.
1139  */
1140  if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
1141 
1142  Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
1143 
1144  do {
1145  Assert(cur_match < s->strstart, "no future");
1146  match = s->window + cur_match;
1147 
1148  /* Skip to next match if the match length cannot increase
1149  * or if the match length is less than 2. Note that the checks below
1150  * for insufficient lookahead only occur occasionally for performance
1151  * reasons. Therefore uninitialized memory will be accessed, and
1152  * conditional jumps will be made that depend on those values.
1153  * However the length of the match is limited to the lookahead, so
1154  * the output of deflate is not affected by the uninitialized values.
1155  */
1156 #if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
1157  /* This code assumes sizeof(unsigned short) == 2. Do not use
1158  * UNALIGNED_OK if your compiler uses a different size.
1159  */
1160  if (*(ushf*)(match+best_len-1) != scan_end ||
1161  *(ushf*)match != scan_start) continue;
1162 
1163  /* It is not necessary to compare scan[2] and match[2] since they are
1164  * always equal when the other bytes match, given that the hash keys
1165  * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
1166  * strstart+3, +5, ... up to strstart+257. We check for insufficient
1167  * lookahead only every 4th comparison; the 128th check will be made
1168  * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
1169  * necessary to put more guard bytes at the end of the window, or
1170  * to check more often for insufficient lookahead.
1171  */
1172  Assert(scan[2] == match[2], "scan[2]?");
1173  scan++, match++;
1174  do {
1175  } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1176  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1177  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1178  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1179  scan < strend);
1180  /* The funny "do {}" generates better code on most compilers */
1181 
1182  /* Here, scan <= window+strstart+257 */
1183  Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1184  if (*scan == *match) scan++;
1185 
1186  len = (MAX_MATCH - 1) - (int)(strend-scan);
1187  scan = strend - (MAX_MATCH-1);
1188 
1189 #else /* UNALIGNED_OK */
1190 
1191  if (match[best_len] != scan_end ||
1192  match[best_len-1] != scan_end1 ||
1193  *match != *scan ||
1194  *++match != scan[1]) continue;
1195 
1196  /* The check at best_len-1 can be removed because it will be made
1197  * again later. (This heuristic is not always a win.)
1198  * It is not necessary to compare scan[2] and match[2] since they
1199  * are always equal when the other bytes match, given that
1200  * the hash keys are equal and that HASH_BITS >= 8.
1201  */
1202  scan += 2, match++;
1203  Assert(*scan == *match, "match[2]?");
1204 
1205  /* We check for insufficient lookahead only every 8th comparison;
1206  * the 256th check will be made at strstart+258.
1207  */
1208  do {
1209  } while (*++scan == *++match && *++scan == *++match &&
1210  *++scan == *++match && *++scan == *++match &&
1211  *++scan == *++match && *++scan == *++match &&
1212  *++scan == *++match && *++scan == *++match &&
1213  scan < strend);
1214 
1215  Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1216 
1217  len = MAX_MATCH - (int)(strend - scan);
1218  scan = strend - MAX_MATCH;
1219 
1220 #endif /* UNALIGNED_OK */
1221 
1222  if (len > best_len) {
1223  s->match_start = cur_match;
1224  best_len = len;
1225  if (len >= nice_match) break;
1226 #ifdef UNALIGNED_OK
1227  scan_end = *(ushf*)(scan+best_len-1);
1228 #else
1229  scan_end1 = scan[best_len-1];
1230  scan_end = scan[best_len];
1231 #endif
1232  }
1233  } while ((cur_match = prev[cur_match & wmask]) > limit
1234  && --chain_length != 0);
1235 
1236  if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1237  return s->lookahead;
1238 }
uInt good_match
Definition: deflate.h:188
uInt hash_bits
Definition: deflate.h:141
ush FAR ushf
Definition: zutil.h:44
Bytef * window
Definition: deflate.h:116
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define NIL
Definition: deflate.cc:104
#define Assert(cond, msg)
Definition: zutil.h:229
uInt prev_length
Definition: deflate.h:163
Posf * prev
Definition: deflate.h:131
uInt match_start
Definition: deflate.h:160
uInt lookahead
Definition: deflate.h:161
#define MAX_DIST(s)
Definition: deflate.h:286
ulg window_size
Definition: deflate.h:126
#define MIN_LOOKAHEAD
Definition: deflate.h:281
unsigned short ush
Definition: zutil.h:43
#define MAX_MATCH
Definition: zutil.h:76
Pos FAR Posf
Definition: deflate.h:90
uInt max_chain_length
Definition: deflate.h:168
int nice_match
Definition: deflate.h:191
unsigned long ulg
Definition: zutil.h:45
uInt strstart
Definition: deflate.h:159
const XML_Char int len
unsigned IPos
Definition: deflate.h:91
local void putShortMSB OF ( (deflate_state *s, uInt b)  )
local void flush_pending OF ( (z_streamp strm)  )
local int read_buf OF ( (z_streamp strm, Bytef *buf, unsigned size)  )
local uInt longest_match OF ( (deflate_state *s, IPos cur_match)  )
local void putShortMSB ( deflate_state s,
uInt  b 
)

Definition at line 591 of file deflate.cc.

References put_byte.

Referenced by deflate().

592 {
593  put_byte(s, (Byte)(b >> 8));
594  put_byte(s, (Byte)(b & 0xff));
595 }
#define put_byte(s, c)
Definition: deflate.h:278
local int read_buf ( z_streamp  strm,
Bytef *  buf,
unsigned  size 
)

Definition at line 1031 of file deflate.cc.

References adler32(), crc32(), and zmemcpy().

Referenced by fill_window().

1032 {
1033  unsigned len = strm->avail_in;
1034 
1035  if (len > size) len = size;
1036  if (len == 0) return 0;
1037 
1038  strm->avail_in -= len;
1039 
1040  zmemcpy(buf, strm->next_in, len);
1041  if (strm->state->wrap == 1) {
1042  strm->adler = adler32(strm->adler, buf, len);
1043  }
1044 #ifdef GZIP
1045  else if (strm->state->wrap == 2) {
1046  strm->adler = crc32(strm->adler, buf, len);
1047  }
1048 #endif
1049  strm->next_in += len;
1050  strm->total_in += len;
1051 
1052  return (int)len;
1053 }
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.cc:202
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.cc:65
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.cc:150
z_streamp strm
Definition: deflate.h:98
const XML_Char int len

Variable Documentation

local const config configuration_table[10]
Initial value:
= {
{0, 0, 0, 0, deflate_stored},
{4, 4, 8, 4, deflate_fast},
{4, 5, 16, 8, deflate_fast},
{4, 6, 32, 32, deflate_fast},
{4, 4, 16, 16, deflate_slow},
{8, 16, 32, 32, deflate_slow},
{8, 16, 128, 128, deflate_slow},
{8, 32, 128, 256, deflate_slow},
{32, 128, 258, 1024, deflate_slow},
{32, 258, 258, 4096, deflate_slow}}
local block_state deflate_fast(deflate_state *s, int flush)
Definition: deflate.cc:1569
local block_state deflate_slow(deflate_state *s, int flush)
Definition: deflate.cc:1669
local block_state deflate_stored(deflate_state *s, int flush)
Definition: deflate.cc:1507

Definition at line 131 of file deflate.cc.

const char deflate_copyright[]
Initial value:
=
" deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "

Definition at line 54 of file deflate.cc.