ReactOS  0.4.13-dev-100-gc8611ae
deflate.c File Reference
#include "deflate.h"
Include dependency graph for deflate.c:

Go to the source code of this file.

Classes

struct  config_s
 

Macros

#define NIL   0
 
#define TOO_FAR   4096
 
#define RANK(f)   (((f) * 2) - ((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 HCRC_UPDATE(beg)
 
#define check_match(s, start, match, length)
 
#define FLUSH_BLOCK_ONLY(s, last)
 
#define FLUSH_BLOCK(s, last)
 
#define MAX_STORED   65535
 
#define MIN(a, b)   ((a) > (b) ? (b) : (a))
 

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

int deflateStateCheck OF ((z_streamp strm))
 
void slide_hash OF ((deflate_state *s))
 
block_state deflate_stored OF ((deflate_state *s, int flush))
 
void putShortMSB OF ((deflate_state *s, uInt b))
 
unsigned read_buf OF ((z_streamp strm, Bytef *buf, unsigned size))
 
uInt longest_match OF ((deflate_state *s, IPos cur_match))
 
void slide_hash (deflate_state *s)
 
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 deflateStateCheck (z_streamp strm)
 
int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
 
int ZEXPORT deflateGetDictionary (z_streamp strm, 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)
 
void putShortMSB (deflate_state *s, uInt b)
 
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)
 
unsigned read_buf (z_streamp strm, Bytef *buf, unsigned size)
 
void lm_init (deflate_state *s)
 
uInt longest_match (deflate_state *s, IPos cur_match)
 
void fill_window (deflate_state *s)
 
block_state deflate_stored (deflate_state *s, int flush)
 
block_state deflate_fast (deflate_state *s, int flush)
 
block_state deflate_slow (deflate_state *s, int flush)
 
block_state deflate_rle (deflate_state *s, int flush)
 
block_state deflate_huff (deflate_state *s, int flush)
 

Variables

const char deflate_copyright []
 
const config configuration_table [10]
 

Macro Definition Documentation

◆ check_match

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

Definition at line 1472 of file deflate.c.

◆ CLEAR_HASH

#define CLEAR_HASH (   s)
Value:
do { \
s->head[s->hash_size-1] = NIL; \
zmemzero((Bytef *)s->head, \
(unsigned)(s->hash_size-1)*sizeof(*s->head)); \
} while (0)
Byte FAR Bytef
Definition: zconf.h:400
#define NIL
Definition: deflate.c:107
GLdouble s
Definition: gl.h:2039

Definition at line 192 of file deflate.c.

◆ FLUSH_BLOCK

#define FLUSH_BLOCK (   s,
  last 
)
Value:
{ \
FLUSH_BLOCK_ONLY(s, last); \
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
return
Definition: dirsup.c:529
POINT last
Definition: font.c:46
GLdouble s
Definition: gl.h:2039

Definition at line 1620 of file deflate.c.

◆ FLUSH_BLOCK_ONLY

#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; \
flush_pending(s->strm); \
Tracev((stderr,"[FLUSH]")); \
}
POINT last
Definition: font.c:46
unsigned long ulg
Definition: zutil.h:38
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039
FILE * stderr
#define Z_NULL
Definition: zlib.h:212
char FAR charf
Definition: zconf.h:402

Definition at line 1608 of file deflate.c.

◆ HCRC_UPDATE

#define HCRC_UPDATE (   beg)
Value:
do { \
if (s->gzhead->hcrc && s->pending > (beg)) \
strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
s->pending - (beg)); \
} while (0)
UINT32 crc32
Definition: btrfs.c:3877
GLdouble s
Definition: gl.h:2039

Definition at line 758 of file deflate.c.

◆ INSERT_STRING

#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:64
ush Pos
Definition: deflate.h:92
#define UPDATE_HASH(s, h, c)
Definition: deflate.c:163
const WCHAR * str
GLdouble s
Definition: gl.h:2039

Definition at line 182 of file deflate.c.

◆ MAX_STORED

#define MAX_STORED   65535

Definition at line 1626 of file deflate.c.

◆ MIN

#define MIN (   a,
  b 
)    ((a) > (b) ? (b) : (a))

Definition at line 1629 of file deflate.c.

◆ NIL

#define NIL   0

Definition at line 107 of file deflate.c.

◆ RANK

#define RANK (   f)    (((f) * 2) - ((f) > 4 ? 9 : 0))

Definition at line 155 of file deflate.c.

◆ TOO_FAR

#define TOO_FAR   4096

Definition at line 111 of file deflate.c.

◆ UPDATE_HASH

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

Definition at line 163 of file deflate.c.

Typedef Documentation

◆ config

◆ OF

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

Definition at line 73 of file deflate.c.

Enumeration Type Documentation

◆ block_state

Enumerator
need_more 
block_done 
finish_started 
finish_done 

Definition at line 66 of file deflate.c.

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.c:66

Function Documentation

◆ deflate()

int ZEXPORT deflate ( z_streamp  strm,
int  flush 
)

Definition at line 766 of file deflate.c.

769 {
770  int old_flush; /* value of flush param for previous deflate call */
771  deflate_state *s;
772 
773  if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
774  return Z_STREAM_ERROR;
775  }
776  s = strm->state;
777 
778  if (strm->next_out == Z_NULL ||
779  (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
780  (s->status == FINISH_STATE && flush != Z_FINISH)) {
781  ERR_RETURN(strm, Z_STREAM_ERROR);
782  }
783  if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
784 
785  old_flush = s->last_flush;
786  s->last_flush = flush;
787 
788  /* Flush as much pending output as possible */
789  if (s->pending != 0) {
790  flush_pending(strm);
791  if (strm->avail_out == 0) {
792  /* Since avail_out is 0, deflate will be called again with
793  * more output space, but possibly with both pending and
794  * avail_in equal to zero. There won't be anything to do,
795  * but this is not an error situation so make sure we
796  * return OK instead of BUF_ERROR at next call of deflate:
797  */
798  s->last_flush = -1;
799  return Z_OK;
800  }
801 
802  /* Make sure there is something to do and avoid duplicate consecutive
803  * flushes. For repeated and useless calls with Z_FINISH, we keep
804  * returning Z_STREAM_END instead of Z_BUF_ERROR.
805  */
806  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
807  flush != Z_FINISH) {
808  ERR_RETURN(strm, Z_BUF_ERROR);
809  }
810 
811  /* User must not provide more input after the first FINISH: */
812  if (s->status == FINISH_STATE && strm->avail_in != 0) {
813  ERR_RETURN(strm, Z_BUF_ERROR);
814  }
815 
816  /* Write the header */
817  if (s->status == INIT_STATE) {
818  /* zlib header */
819  uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
820  uInt level_flags;
821 
822  if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
823  level_flags = 0;
824  else if (s->level < 6)
825  level_flags = 1;
826  else if (s->level == 6)
827  level_flags = 2;
828  else
829  level_flags = 3;
830  header |= (level_flags << 6);
831  if (s->strstart != 0) header |= PRESET_DICT;
832  header += 31 - (header % 31);
833 
834  putShortMSB(s, header);
835 
836  /* Save the adler32 of the preset dictionary: */
837  if (s->strstart != 0) {
838  putShortMSB(s, (uInt)(strm->adler >> 16));
839  putShortMSB(s, (uInt)(strm->adler & 0xffff));
840  }
841  strm->adler = adler32(0L, Z_NULL, 0);
842  s->status = BUSY_STATE;
843 
844  /* Compression must start with an empty pending buffer */
845  flush_pending(strm);
846  if (s->pending != 0) {
847  s->last_flush = -1;
848  return Z_OK;
849  }
850  }
851 #ifdef GZIP
852  if (s->status == GZIP_STATE) {
853  /* gzip header */
854  strm->adler = crc32(0L, Z_NULL, 0);
855  put_byte(s, 31);
856  put_byte(s, 139);
857  put_byte(s, 8);
858  if (s->gzhead == Z_NULL) {
859  put_byte(s, 0);
860  put_byte(s, 0);
861  put_byte(s, 0);
862  put_byte(s, 0);
863  put_byte(s, 0);
864  put_byte(s, s->level == 9 ? 2 :
865  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
866  4 : 0));
867  put_byte(s, OS_CODE);
868  s->status = BUSY_STATE;
869 
870  /* Compression must start with an empty pending buffer */
871  flush_pending(strm);
872  if (s->pending != 0) {
873  s->last_flush = -1;
874  return Z_OK;
875  }
876  }
877  else {
878  put_byte(s, (s->gzhead->text ? 1 : 0) +
879  (s->gzhead->hcrc ? 2 : 0) +
880  (s->gzhead->extra == Z_NULL ? 0 : 4) +
881  (s->gzhead->name == Z_NULL ? 0 : 8) +
882  (s->gzhead->comment == Z_NULL ? 0 : 16)
883  );
884  put_byte(s, (Byte)(s->gzhead->time & 0xff));
885  put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
886  put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
887  put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
888  put_byte(s, s->level == 9 ? 2 :
889  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
890  4 : 0));
891  put_byte(s, s->gzhead->os & 0xff);
892  if (s->gzhead->extra != Z_NULL) {
893  put_byte(s, s->gzhead->extra_len & 0xff);
894  put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
895  }
896  if (s->gzhead->hcrc)
897  strm->adler = crc32(strm->adler, s->pending_buf,
898  s->pending);
899  s->gzindex = 0;
900  s->status = EXTRA_STATE;
901  }
902  }
903  if (s->status == EXTRA_STATE) {
904  if (s->gzhead->extra != Z_NULL) {
905  ulg beg = s->pending; /* start of bytes to update crc */
906  uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
907  while (s->pending + left > s->pending_buf_size) {
908  uInt copy = s->pending_buf_size - s->pending;
909  zmemcpy(s->pending_buf + s->pending,
910  s->gzhead->extra + s->gzindex, copy);
911  s->pending = s->pending_buf_size;
912  HCRC_UPDATE(beg);
913  s->gzindex += copy;
914  flush_pending(strm);
915  if (s->pending != 0) {
916  s->last_flush = -1;
917  return Z_OK;
918  }
919  beg = 0;
920  left -= copy;
921  }
922  zmemcpy(s->pending_buf + s->pending,
923  s->gzhead->extra + s->gzindex, left);
924  s->pending += left;
925  HCRC_UPDATE(beg);
926  s->gzindex = 0;
927  }
928  s->status = NAME_STATE;
929  }
930  if (s->status == NAME_STATE) {
931  if (s->gzhead->name != Z_NULL) {
932  ulg beg = s->pending; /* start of bytes to update crc */
933  int val;
934  do {
935  if (s->pending == s->pending_buf_size) {
936  HCRC_UPDATE(beg);
937  flush_pending(strm);
938  if (s->pending != 0) {
939  s->last_flush = -1;
940  return Z_OK;
941  }
942  beg = 0;
943  }
944  val = s->gzhead->name[s->gzindex++];
945  put_byte(s, val);
946  } while (val != 0);
947  HCRC_UPDATE(beg);
948  s->gzindex = 0;
949  }
950  s->status = COMMENT_STATE;
951  }
952  if (s->status == COMMENT_STATE) {
953  if (s->gzhead->comment != Z_NULL) {
954  ulg beg = s->pending; /* start of bytes to update crc */
955  int val;
956  do {
957  if (s->pending == s->pending_buf_size) {
958  HCRC_UPDATE(beg);
959  flush_pending(strm);
960  if (s->pending != 0) {
961  s->last_flush = -1;
962  return Z_OK;
963  }
964  beg = 0;
965  }
966  val = s->gzhead->comment[s->gzindex++];
967  put_byte(s, val);
968  } while (val != 0);
969  HCRC_UPDATE(beg);
970  }
971  s->status = HCRC_STATE;
972  }
973  if (s->status == HCRC_STATE) {
974  if (s->gzhead->hcrc) {
975  if (s->pending + 2 > s->pending_buf_size) {
976  flush_pending(strm);
977  if (s->pending != 0) {
978  s->last_flush = -1;
979  return Z_OK;
980  }
981  }
982  put_byte(s, (Byte)(strm->adler & 0xff));
983  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
984  strm->adler = crc32(0L, Z_NULL, 0);
985  }
986  s->status = BUSY_STATE;
987 
988  /* Compression must start with an empty pending buffer */
989  flush_pending(strm);
990  if (s->pending != 0) {
991  s->last_flush = -1;
992  return Z_OK;
993  }
994  }
995 #endif
996 
997  /* Start a new block or continue the current one.
998  */
999  if (strm->avail_in != 0 || s->lookahead != 0 ||
1000  (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1001  block_state bstate;
1002 
1003  bstate = s->level == 0 ? deflate_stored(s, flush) :
1004  s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
1005  s->strategy == Z_RLE ? deflate_rle(s, flush) :
1007 
1008  if (bstate == finish_started || bstate == finish_done) {
1009  s->status = FINISH_STATE;
1010  }
1011  if (bstate == need_more || bstate == finish_started) {
1012  if (strm->avail_out == 0) {
1013  s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
1014  }
1015  return Z_OK;
1016  /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1017  * of deflate should use the same flush parameter to make sure
1018  * that the flush is complete. So we don't have to output an
1019  * empty block here, this will be done at next call. This also
1020  * ensures that for a very small output buffer, we emit at most
1021  * one empty block.
1022  */
1023  }
1024  if (bstate == block_done) {
1025  if (flush == Z_PARTIAL_FLUSH) {
1026  _tr_align(s);
1027  } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1028  _tr_stored_block(s, (char*)0, 0L, 0);
1029  /* For a full flush, this empty block will be recognized
1030  * as a special marker by inflate_sync().
1031  */
1032  if (flush == Z_FULL_FLUSH) {
1033  CLEAR_HASH(s); /* forget history */
1034  if (s->lookahead == 0) {
1035  s->strstart = 0;
1036  s->block_start = 0L;
1037  s->insert = 0;
1038  }
1039  }
1040  }
1041  flush_pending(strm);
1042  if (strm->avail_out == 0) {
1043  s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1044  return Z_OK;
1045  }
1046  }
1047  }
1048 
1049  if (flush != Z_FINISH) return Z_OK;
1050  if (s->wrap <= 0) return Z_STREAM_END;
1051 
1052  /* Write the trailer */
1053 #ifdef GZIP
1054  if (s->wrap == 2) {
1055  put_byte(s, (Byte)(strm->adler & 0xff));
1056  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1057  put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
1058  put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
1059  put_byte(s, (Byte)(strm->total_in & 0xff));
1060  put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
1061  put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
1062  put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
1063  }
1064  else
1065 #endif
1066  {
1067  putShortMSB(s, (uInt)(strm->adler >> 16));
1068  putShortMSB(s, (uInt)(strm->adler & 0xffff));
1069  }
1070  flush_pending(strm);
1071  /* If avail_out is zero, the application will call deflate again
1072  * to flush the rest.
1073  */
1074  if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1075  return s->pending != 0 ? Z_OK : Z_STREAM_END;
1076 }
#define INIT_STATE
Definition: deflate.h:54
GLenum func
Definition: glext.h:6028
char * name
Definition: wpp.c:36
GLint level
Definition: gl.h:1546
#define RANK(f)
Definition: deflate.c:155
#define Z_HUFFMAN_ONLY
Definition: zlib.h:197
void putShortMSB(deflate_state *s, uInt b)
Definition: deflate.c:719
#define HCRC_STATE
Definition: deflate.h:61
#define Z_PARTIAL_FLUSH
Definition: zlib.h:169
unsigned char Byte
Definition: zconf.h:391
#define PRESET_DICT
Definition: zutil.h:68
void ZLIB_INTERNAL _tr_align(deflate_state *s)
Definition: trees.c:896
block_state
Definition: deflate.c:66
UINT32 crc32
Definition: btrfs.c:3877
#define OS_CODE
Definition: zutil.h:139
#define Z_STREAM_ERROR
Definition: zlib.h:181
unsigned long ulg
Definition: zutil.h:38
#define Z_STREAM_END
Definition: zlib.h:178
while(1)
Definition: macro.lex.yy.c:740
#define Z_BUF_ERROR
Definition: zlib.h:184
const config configuration_table[10]
Definition: deflate.c:134
#define BUSY_STATE
Definition: deflate.h:62
#define Z_OK
Definition: zlib.h:177
#define Z_FULL_FLUSH
Definition: zlib.h:171
#define Z_DEFLATED
Definition: zlib.h:209
GLuint GLfloat * val
Definition: glext.h:7180
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
int flush
Definition: zlib.h:309
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
GLint left
Definition: glext.h:7726
#define put_byte(s, c)
Definition: deflate.h:281
#define Z_NO_FLUSH
Definition: zlib.h:168
#define COMMENT_STATE
Definition: deflate.h:60
static const WCHAR L[]
Definition: oid.c:1250
#define CLEAR_HASH(s)
Definition: deflate.c:192
block_state deflate_rle(deflate_state *s, int flush)
Definition: deflate.c:2060
#define NAME_STATE
Definition: deflate.h:59
GLdouble s
Definition: gl.h:2039
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.c:863
#define FINISH_STATE
Definition: deflate.h:63
block_state deflate_stored(deflate_state *s, int flush)
Definition: deflate.c:1646
#define Z_FINISH
Definition: zlib.h:172
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define GZIP_STATE
Definition: deflate.h:56
#define EXTRA_STATE
Definition: deflate.h:58
#define Z_BLOCK
Definition: zlib.h:173
void flush_pending(z_streamp strm)
Definition: deflate.c:733
#define HCRC_UPDATE(beg)
Definition: deflate.c:758
#define Z_RLE
Definition: zlib.h:198
block_state deflate_huff(deflate_state *s, int flush)
Definition: deflate.c:2133
#define Z_NULL
Definition: zlib.h:212
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134
struct CFHEADER header
Definition: fdi.c:109
#define ERR_RETURN(strm, err)
Definition: zutil.h:41
unsigned int uInt
Definition: zconf.h:393

Referenced by CMSZipCodec::Compress(), compress2(), deflateParams(), gz_comp(), zipCloseFileInZipRaw64(), zipWriteInFileInZip(), and zlib_write_compressed_bit().

◆ deflate_fast()

block_state deflate_fast ( deflate_state s,
int  flush 
)

Definition at line 1827 of file deflate.c.

1830 {
1831  IPos hash_head; /* head of the hash chain */
1832  int bflush; /* set if current block must be flushed */
1833 
1834  for (;;) {
1835  /* Make sure that we always have enough lookahead, except
1836  * at the end of the input file. We need MAX_MATCH bytes
1837  * for the next match, plus MIN_MATCH bytes to insert the
1838  * string following the next match.
1839  */
1840  if (s->lookahead < MIN_LOOKAHEAD) {
1841  fill_window(s);
1842  if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1843  return need_more;
1844  }
1845  if (s->lookahead == 0) break; /* flush the current block */
1846  }
1847 
1848  /* Insert the string window[strstart .. strstart+2] in the
1849  * dictionary, and set hash_head to the head of the hash chain:
1850  */
1851  hash_head = NIL;
1852  if (s->lookahead >= MIN_MATCH) {
1853  INSERT_STRING(s, s->strstart, hash_head);
1854  }
1855 
1856  /* Find the longest match, discarding those <= prev_length.
1857  * At this point we have always match_length < MIN_MATCH
1858  */
1859  if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1860  /* To simplify the code, we prevent matches with the string
1861  * of window index 0 (in particular we have to avoid a match
1862  * of the string with itself at the start of the input file).
1863  */
1864  s->match_length = longest_match (s, hash_head);
1865  /* longest_match() sets match_start */
1866  }
1867  if (s->match_length >= MIN_MATCH) {
1868  check_match(s, s->strstart, s->match_start, s->match_length);
1869 
1870  _tr_tally_dist(s, s->strstart - s->match_start,
1871  s->match_length - MIN_MATCH, bflush);
1872 
1873  s->lookahead -= s->match_length;
1874 
1875  /* Insert new strings in the hash table only if the match length
1876  * is not too large. This saves time but degrades compression.
1877  */
1878 #ifndef FASTEST
1879  if (s->match_length <= s->max_insert_length &&
1880  s->lookahead >= MIN_MATCH) {
1881  s->match_length--; /* string at strstart already in table */
1882  do {
1883  s->strstart++;
1884  INSERT_STRING(s, s->strstart, hash_head);
1885  /* strstart never exceeds WSIZE-MAX_MATCH, so there are
1886  * always MIN_MATCH bytes ahead.
1887  */
1888  } while (--s->match_length != 0);
1889  s->strstart++;
1890  } else
1891 #endif
1892  {
1893  s->strstart += s->match_length;
1894  s->match_length = 0;
1895  s->ins_h = s->window[s->strstart];
1896  UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
1897 #if MIN_MATCH != 3
1898  Call UPDATE_HASH() MIN_MATCH-3 more times
1899 #endif
1900  /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
1901  * matter since it will be recomputed at next deflate call.
1902  */
1903  }
1904  } else {
1905  /* No match, output a literal byte */
1906  Tracevv((stderr,"%c", s->window[s->strstart]));
1907  _tr_tally_lit (s, s->window[s->strstart], bflush);
1908  s->lookahead--;
1909  s->strstart++;
1910  }
1911  if (bflush) FLUSH_BLOCK(s, 0);
1912  }
1913  s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1914  if (flush == Z_FINISH) {
1915  FLUSH_BLOCK(s, 1);
1916  return finish_done;
1917  }
1918  if (s->last_lit)
1919  FLUSH_BLOCK(s, 0);
1920  return block_done;
1921 }
#define MIN_MATCH
Definition: zutil.h:64
#define INSERT_STRING(s, str, match_head)
Definition: deflate.c:182
#define check_match(s, start, match, length)
Definition: deflate.c:1472
#define UPDATE_HASH(s, h, c)
Definition: deflate.c:163
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:326
void fill_window(deflate_state *s)
Definition: deflate.c:1485
#define MAX_DIST(s)
Definition: deflate.h:289
#define MIN_LOOKAHEAD
Definition: deflate.h:284
static const struct encodedFiletime times[]
Definition: encode.c:556
#define Tracevv(x)
Definition: zutil.h:199
#define NIL
Definition: deflate.c:107
int flush
Definition: zlib.h:309
#define Z_NO_FLUSH
Definition: zlib.h:168
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:333
GLdouble s
Definition: gl.h:2039
#define Z_FINISH
Definition: zlib.h:172
uInt longest_match(deflate_state *s, IPos cur_match)
Definition: deflate.c:1239
#define FLUSH_BLOCK(s, last)
Definition: deflate.c:1620
FILE * stderr
unsigned IPos
Definition: deflate.h:94

◆ deflate_huff()

block_state deflate_huff ( deflate_state s,
int  flush 
)

Definition at line 2133 of file deflate.c.

2136 {
2137  int bflush; /* set if current block must be flushed */
2138 
2139  for (;;) {
2140  /* Make sure that we have a literal to write. */
2141  if (s->lookahead == 0) {
2142  fill_window(s);
2143  if (s->lookahead == 0) {
2144  if (flush == Z_NO_FLUSH)
2145  return need_more;
2146  break; /* flush the current block */
2147  }
2148  }
2149 
2150  /* Output a literal byte */
2151  s->match_length = 0;
2152  Tracevv((stderr,"%c", s->window[s->strstart]));
2153  _tr_tally_lit (s, s->window[s->strstart], bflush);
2154  s->lookahead--;
2155  s->strstart++;
2156  if (bflush) FLUSH_BLOCK(s, 0);
2157  }
2158  s->insert = 0;
2159  if (flush == Z_FINISH) {
2160  FLUSH_BLOCK(s, 1);
2161  return finish_done;
2162  }
2163  if (s->last_lit)
2164  FLUSH_BLOCK(s, 0);
2165  return block_done;
2166 }
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:326
void fill_window(deflate_state *s)
Definition: deflate.c:1485
#define Tracevv(x)
Definition: zutil.h:199
int flush
Definition: zlib.h:309
#define Z_NO_FLUSH
Definition: zlib.h:168
GLdouble s
Definition: gl.h:2039
#define Z_FINISH
Definition: zlib.h:172
#define FLUSH_BLOCK(s, last)
Definition: deflate.c:1620
FILE * stderr

Referenced by deflate().

◆ deflate_rle()

block_state deflate_rle ( deflate_state s,
int  flush 
)

Definition at line 2060 of file deflate.c.

2063 {
2064  int bflush; /* set if current block must be flushed */
2065  uInt prev; /* byte at distance one to match */
2066  Bytef *scan, *strend; /* scan goes up to strend for length of run */
2067 
2068  for (;;) {
2069  /* Make sure that we always have enough lookahead, except
2070  * at the end of the input file. We need MAX_MATCH bytes
2071  * for the longest run, plus one for the unrolled loop.
2072  */
2073  if (s->lookahead <= MAX_MATCH) {
2074  fill_window(s);
2075  if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
2076  return need_more;
2077  }
2078  if (s->lookahead == 0) break; /* flush the current block */
2079  }
2080 
2081  /* See how many times the previous byte repeats */
2082  s->match_length = 0;
2083  if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
2084  scan = s->window + s->strstart - 1;
2085  prev = *scan;
2086  if (prev == *++scan && prev == *++scan && prev == *++scan) {
2087  strend = s->window + s->strstart + MAX_MATCH;
2088  do {
2089  } while (prev == *++scan && prev == *++scan &&
2090  prev == *++scan && prev == *++scan &&
2091  prev == *++scan && prev == *++scan &&
2092  prev == *++scan && prev == *++scan &&
2093  scan < strend);
2094  s->match_length = MAX_MATCH - (uInt)(strend - scan);
2095  if (s->match_length > s->lookahead)
2096  s->match_length = s->lookahead;
2097  }
2098  Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
2099  }
2100 
2101  /* Emit match if have run of MIN_MATCH or longer, else emit literal */
2102  if (s->match_length >= MIN_MATCH) {
2103  check_match(s, s->strstart, s->strstart - 1, s->match_length);
2104 
2105  _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
2106 
2107  s->lookahead -= s->match_length;
2108  s->strstart += s->match_length;
2109  s->match_length = 0;
2110  } else {
2111  /* No match, output a literal byte */
2112  Tracevv((stderr,"%c", s->window[s->strstart]));
2113  _tr_tally_lit (s, s->window[s->strstart], bflush);
2114  s->lookahead--;
2115  s->strstart++;
2116  }
2117  if (bflush) FLUSH_BLOCK(s, 0);
2118  }
2119  s->insert = 0;
2120  if (flush == Z_FINISH) {
2121  FLUSH_BLOCK(s, 1);
2122  return finish_done;
2123  }
2124  if (s->last_lit)
2125  FLUSH_BLOCK(s, 0);
2126  return block_done;
2127 }
#define MIN_MATCH
Definition: zutil.h:64
struct list * prev
Definition: list.h:39
#define check_match(s, start, match, length)
Definition: deflate.c:1472
#define MAX_MATCH
Definition: zutil.h:65
Byte FAR Bytef
Definition: zconf.h:400
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:326
void fill_window(deflate_state *s)
Definition: deflate.c:1485
#define Assert(cond, msg)
Definition: zutil.h:196
#define Tracevv(x)
Definition: zutil.h:199
int flush
Definition: zlib.h:309
#define Z_NO_FLUSH
Definition: zlib.h:168
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:333
GLdouble s
Definition: gl.h:2039
static IHTMLWindow2 * window
Definition: events.c:77
#define Z_FINISH
Definition: zlib.h:172
#define FLUSH_BLOCK(s, last)
Definition: deflate.c:1620
FILE * stderr
unsigned int uInt
Definition: zconf.h:393

Referenced by deflate().

◆ deflate_slow()

block_state deflate_slow ( deflate_state s,
int  flush 
)

Definition at line 1929 of file deflate.c.

1932 {
1933  IPos hash_head; /* head of hash chain */
1934  int bflush; /* set if current block must be flushed */
1935 
1936  /* Process the input block. */
1937  for (;;) {
1938  /* Make sure that we always have enough lookahead, except
1939  * at the end of the input file. We need MAX_MATCH bytes
1940  * for the next match, plus MIN_MATCH bytes to insert the
1941  * string following the next match.
1942  */
1943  if (s->lookahead < MIN_LOOKAHEAD) {
1944  fill_window(s);
1945  if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1946  return need_more;
1947  }
1948  if (s->lookahead == 0) break; /* flush the current block */
1949  }
1950 
1951  /* Insert the string window[strstart .. strstart+2] in the
1952  * dictionary, and set hash_head to the head of the hash chain:
1953  */
1954  hash_head = NIL;
1955  if (s->lookahead >= MIN_MATCH) {
1956  INSERT_STRING(s, s->strstart, hash_head);
1957  }
1958 
1959  /* Find the longest match, discarding those <= prev_length.
1960  */
1961  s->prev_length = s->match_length, s->prev_match = s->match_start;
1962  s->match_length = MIN_MATCH-1;
1963 
1964  if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
1965  s->strstart - hash_head <= MAX_DIST(s)) {
1966  /* To simplify the code, we prevent matches with the string
1967  * of window index 0 (in particular we have to avoid a match
1968  * of the string with itself at the start of the input file).
1969  */
1970  s->match_length = longest_match (s, hash_head);
1971  /* longest_match() sets match_start */
1972 
1973  if (s->match_length <= 5 && (s->strategy == Z_FILTERED
1974 #if TOO_FAR <= 32767
1975  || (s->match_length == MIN_MATCH &&
1976  s->strstart - s->match_start > TOO_FAR)
1977 #endif
1978  )) {
1979 
1980  /* If prev_match is also MIN_MATCH, match_start is garbage
1981  * but we will ignore the current match anyway.
1982  */
1983  s->match_length = MIN_MATCH-1;
1984  }
1985  }
1986  /* If there was a match at the previous step and the current
1987  * match is not better, output the previous match:
1988  */
1989  if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
1990  uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
1991  /* Do not insert strings in hash table beyond this. */
1992 
1993  check_match(s, s->strstart-1, s->prev_match, s->prev_length);
1994 
1995  _tr_tally_dist(s, s->strstart -1 - s->prev_match,
1996  s->prev_length - MIN_MATCH, bflush);
1997 
1998  /* Insert in hash table all strings up to the end of the match.
1999  * strstart-1 and strstart are already inserted. If there is not
2000  * enough lookahead, the last two strings are not inserted in
2001  * the hash table.
2002  */
2003  s->lookahead -= s->prev_length-1;
2004  s->prev_length -= 2;
2005  do {
2006  if (++s->strstart <= max_insert) {
2007  INSERT_STRING(s, s->strstart, hash_head);
2008  }
2009  } while (--s->prev_length != 0);
2010  s->match_available = 0;
2011  s->match_length = MIN_MATCH-1;
2012  s->strstart++;
2013 
2014  if (bflush) FLUSH_BLOCK(s, 0);
2015 
2016  } else if (s->match_available) {
2017  /* If there was no match at the previous position, output a
2018  * single literal. If there was a match but the current match
2019  * is longer, truncate the previous match to a single literal.
2020  */
2021  Tracevv((stderr,"%c", s->window[s->strstart-1]));
2022  _tr_tally_lit(s, s->window[s->strstart-1], bflush);
2023  if (bflush) {
2024  FLUSH_BLOCK_ONLY(s, 0);
2025  }
2026  s->strstart++;
2027  s->lookahead--;
2028  if (s->strm->avail_out == 0) return need_more;
2029  } else {
2030  /* There is no previous match to compare with, wait for
2031  * the next step to decide.
2032  */
2033  s->match_available = 1;
2034  s->strstart++;
2035  s->lookahead--;
2036  }
2037  }
2038  Assert (flush != Z_NO_FLUSH, "no flush?");
2039  if (s->match_available) {
2040  Tracevv((stderr,"%c", s->window[s->strstart-1]));
2041  _tr_tally_lit(s, s->window[s->strstart-1], bflush);
2042  s->match_available = 0;
2043  }
2044  s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
2045  if (flush == Z_FINISH) {
2046  FLUSH_BLOCK(s, 1);
2047  return finish_done;
2048  }
2049  if (s->last_lit)
2050  FLUSH_BLOCK(s, 0);
2051  return block_done;
2052 }
#define MIN_MATCH
Definition: zutil.h:64
#define INSERT_STRING(s, str, match_head)
Definition: deflate.c:182
#define check_match(s, start, match, length)
Definition: deflate.c:1472
#define TOO_FAR
Definition: deflate.c:111
#define _tr_tally_lit(s, c, flush)
Definition: deflate.h:326
void fill_window(deflate_state *s)
Definition: deflate.c:1485
#define MAX_DIST(s)
Definition: deflate.h:289
#define MIN_LOOKAHEAD
Definition: deflate.h:284
#define Assert(cond, msg)
Definition: zutil.h:196
#define Tracevv(x)
Definition: zutil.h:199
#define NIL
Definition: deflate.c:107
#define Z_FILTERED
Definition: zlib.h:196
int flush
Definition: zlib.h:309
#define Z_NO_FLUSH
Definition: zlib.h:168
#define _tr_tally_dist(s, distance, length, flush)
Definition: deflate.h:333
GLdouble s
Definition: gl.h:2039
#define Z_FINISH
Definition: zlib.h:172
uInt longest_match(deflate_state *s, IPos cur_match)
Definition: deflate.c:1239
#define FLUSH_BLOCK(s, last)
Definition: deflate.c:1620
FILE * stderr
unsigned int uInt
Definition: zconf.h:393
#define FLUSH_BLOCK_ONLY(s, last)
Definition: deflate.c:1608
unsigned IPos
Definition: deflate.h:94

◆ deflate_stored()

block_state deflate_stored ( deflate_state s,
int  flush 
)

Definition at line 1646 of file deflate.c.

1649 {
1650  /* Smallest worthy block size when not flushing or finishing. By default
1651  * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
1652  * large input and output buffers, the stored block size will be larger.
1653  */
1654  unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
1655 
1656  /* Copy as many min_block or larger stored blocks directly to next_out as
1657  * possible. If flushing, copy the remaining available input to next_out as
1658  * stored blocks, if there is enough space.
1659  */
1660  unsigned len, left, have, last = 0;
1661  unsigned used = s->strm->avail_in;
1662  do {
1663  /* Set len to the maximum size block that we can copy directly with the
1664  * available input data and output space. Set left to how much of that
1665  * would be copied from what's left in the window.
1666  */
1667  len = MAX_STORED; /* maximum deflate stored block length */
1668  have = (s->bi_valid + 42) >> 3; /* number of header bytes */
1669  if (s->strm->avail_out < have) /* need room for header */
1670  break;
1671  /* maximum stored block length that will fit in avail_out: */
1672  have = s->strm->avail_out - have;
1673  left = s->strstart - s->block_start; /* bytes left in window */
1674  if (len > (ulg)left + s->strm->avail_in)
1675  len = left + s->strm->avail_in; /* limit len to the input */
1676  if (len > have)
1677  len = have; /* limit len to the output */
1678 
1679  /* If the stored block would be less than min_block in length, or if
1680  * unable to copy all of the available input when flushing, then try
1681  * copying to the window and the pending buffer instead. Also don't
1682  * write an empty block when flushing -- deflate() does that.
1683  */
1684  if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
1685  flush == Z_NO_FLUSH ||
1686  len != left + s->strm->avail_in))
1687  break;
1688 
1689  /* Make a dummy stored block in pending to get the header bytes,
1690  * including any pending bits. This also updates the debugging counts.
1691  */
1692  last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
1693  _tr_stored_block(s, (char *)0, 0L, last);
1694 
1695  /* Replace the lengths in the dummy stored block with len. */
1696  s->pending_buf[s->pending - 4] = len;
1697  s->pending_buf[s->pending - 3] = len >> 8;
1698  s->pending_buf[s->pending - 2] = ~len;
1699  s->pending_buf[s->pending - 1] = ~len >> 8;
1700 
1701  /* Write the stored block header bytes. */
1702  flush_pending(s->strm);
1703 
1704 #ifdef ZLIB_DEBUG
1705  /* Update debugging counts for the data about to be copied. */
1706  s->compressed_len += len << 3;
1707  s->bits_sent += len << 3;
1708 #endif
1709 
1710  /* Copy uncompressed bytes from the window to next_out. */
1711  if (left) {
1712  if (left > len)
1713  left = len;
1714  zmemcpy(s->strm->next_out, s->window + s->block_start, left);
1715  s->strm->next_out += left;
1716  s->strm->avail_out -= left;
1717  s->strm->total_out += left;
1718  s->block_start += left;
1719  len -= left;
1720  }
1721 
1722  /* Copy uncompressed bytes directly from next_in to next_out, updating
1723  * the check value.
1724  */
1725  if (len) {
1726  read_buf(s->strm, s->strm->next_out, len);
1727  s->strm->next_out += len;
1728  s->strm->avail_out -= len;
1729  s->strm->total_out += len;
1730  }
1731  } while (last == 0);
1732 
1733  /* Update the sliding window with the last s->w_size bytes of the copied
1734  * data, or append all of the copied data to the existing window if less
1735  * than s->w_size bytes were copied. Also update the number of bytes to
1736  * insert in the hash tables, in the event that deflateParams() switches to
1737  * a non-zero compression level.
1738  */
1739  used -= s->strm->avail_in; /* number of input bytes directly copied */
1740  if (used) {
1741  /* If any input was used, then no unused input remains in the window,
1742  * therefore s->block_start == s->strstart.
1743  */
1744  if (used >= s->w_size) { /* supplant the previous history */
1745  s->matches = 2; /* clear hash */
1746  zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
1747  s->strstart = s->w_size;
1748  }
1749  else {
1750  if (s->window_size - s->strstart <= used) {
1751  /* Slide the window down. */
1752  s->strstart -= s->w_size;
1753  zmemcpy(s->window, s->window + s->w_size, s->strstart);
1754  if (s->matches < 2)
1755  s->matches++; /* add a pending slide_hash() */
1756  }
1757  zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
1758  s->strstart += used;
1759  }
1760  s->block_start = s->strstart;
1761  s->insert += MIN(used, s->w_size - s->insert);
1762  }
1763  if (s->high_water < s->strstart)
1764  s->high_water = s->strstart;
1765 
1766  /* If the last block was written to next_out, then done. */
1767  if (last)
1768  return finish_done;
1769 
1770  /* If flushing and all input has been consumed, then done. */
1771  if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
1772  s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
1773  return block_done;
1774 
1775  /* Fill the window with any remaining input. */
1776  have = s->window_size - s->strstart - 1;
1777  if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
1778  /* Slide the window down. */
1779  s->block_start -= s->w_size;
1780  s->strstart -= s->w_size;
1781  zmemcpy(s->window, s->window + s->w_size, s->strstart);
1782  if (s->matches < 2)
1783  s->matches++; /* add a pending slide_hash() */
1784  have += s->w_size; /* more space now */
1785  }
1786  if (have > s->strm->avail_in)
1787  have = s->strm->avail_in;
1788  if (have) {
1789  read_buf(s->strm, s->window + s->strstart, have);
1790  s->strstart += have;
1791  }
1792  if (s->high_water < s->strstart)
1793  s->high_water = s->strstart;
1794 
1795  /* There was not enough avail_out to write a complete worthy or flushed
1796  * stored block to next_out. Write a stored block to pending instead, if we
1797  * have enough input for a worthy block, or if flushing and there is enough
1798  * room for the remaining input as a stored block in the pending buffer.
1799  */
1800  have = (s->bi_valid + 42) >> 3; /* number of header bytes */
1801  /* maximum stored block length that will fit in pending: */
1802  have = MIN(s->pending_buf_size - have, MAX_STORED);
1803  min_block = MIN(have, s->w_size);
1804  left = s->strstart - s->block_start;
1805  if (left >= min_block ||
1806  ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
1807  s->strm->avail_in == 0 && left <= have)) {
1808  len = MIN(left, have);
1809  last = flush == Z_FINISH && s->strm->avail_in == 0 &&
1810  len == left ? 1 : 0;
1811  _tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
1812  s->block_start += len;
1813  flush_pending(s->strm);
1814  }
1815 
1816  /* We've done all we can with the available input and output. */
1817  return last ? finish_started : need_more;
1818 }
POINT last
Definition: font.c:46
unsigned long ulg
Definition: zutil.h:38
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
c used
Definition: write.c:2885
if(!(yy_init))
Definition: macro.lex.yy.c:714
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
#define MIN(a, b)
Definition: deflate.c:1629
int flush
Definition: zlib.h:309
GLint left
Definition: glext.h:7726
#define Z_NO_FLUSH
Definition: zlib.h:168
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_STORED
Definition: deflate.c:1626
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.c:863
#define Z_FINISH
Definition: zlib.h:172
void flush_pending(z_streamp strm)
Definition: deflate.c:733
char FAR charf
Definition: zconf.h:402

Referenced by deflate().

◆ deflateBound()

uLong ZEXPORT deflateBound ( z_streamp  strm,
uLong  sourceLen 
)

Definition at line 655 of file deflate.c.

658 {
659  deflate_state *s;
660  uLong complen, wraplen;
661 
662  /* conservative upper bound for compressed data */
663  complen = sourceLen +
664  ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
665 
666  /* if can't get parameters, return conservative bound plus zlib wrapper */
667  if (deflateStateCheck(strm))
668  return complen + 6;
669 
670  /* compute wrapper length */
671  s = strm->state;
672  switch (s->wrap) {
673  case 0: /* raw deflate */
674  wraplen = 0;
675  break;
676  case 1: /* zlib wrapper */
677  wraplen = 6 + (s->strstart ? 4 : 0);
678  break;
679 #ifdef GZIP
680  case 2: /* gzip wrapper */
681  wraplen = 18;
682  if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
683  Bytef *str;
684  if (s->gzhead->extra != Z_NULL)
685  wraplen += 2 + s->gzhead->extra_len;
686  str = s->gzhead->name;
687  if (str != Z_NULL)
688  do {
689  wraplen++;
690  } while (*str++);
691  str = s->gzhead->comment;
692  if (str != Z_NULL)
693  do {
694  wraplen++;
695  } while (*str++);
696  if (s->gzhead->hcrc)
697  wraplen += 2;
698  }
699  break;
700 #endif
701  default: /* for compiler happiness */
702  wraplen = 6;
703  }
704 
705  /* if not default parameters, return conservative bound */
706  if (s->w_bits != 15 || s->hash_bits != 8 + 7)
707  return complen + wraplen;
708 
709  /* default settings: return tight bound for that case */
710  return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
711  (sourceLen >> 25) + 13 - 6 + wraplen;
712 }
Byte FAR Bytef
Definition: zconf.h:400
const WCHAR * str
unsigned long uLong
Definition: zconf.h:394
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
GLdouble s
Definition: gl.h:2039
#define Z_NULL
Definition: zlib.h:212

◆ deflateCopy()

int ZEXPORT deflateCopy ( z_streamp  dest,
z_streamp  source 
)

Definition at line 1105 of file deflate.c.

1108 {
1109 #ifdef MAXSEG_64K
1110  return Z_STREAM_ERROR;
1111 #else
1112  deflate_state *ds;
1113  deflate_state *ss;
1114  ushf *overlay;
1115 
1116 
1117  if (deflateStateCheck(source) || dest == Z_NULL) {
1118  return Z_STREAM_ERROR;
1119  }
1120 
1121  ss = source->state;
1122 
1123  zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
1124 
1125  ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
1126  if (ds == Z_NULL) return Z_MEM_ERROR;
1127  dest->state = (struct internal_state FAR *) ds;
1128  zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
1129  ds->strm = dest;
1130 
1131  ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
1132  ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
1133  ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
1134  overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
1135  ds->pending_buf = (uchf *) overlay;
1136 
1137  if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
1138  ds->pending_buf == Z_NULL) {
1139  deflateEnd (dest);
1140  return Z_MEM_ERROR;
1141  }
1142  /* following zmemcpy do not work for 16-bit MSDOS */
1143  zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
1144  zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
1145  zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
1146  zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
1147 
1148  ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
1149  ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
1150  ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
1151 
1152  ds->l_desc.dyn_tree = ds->dyn_ltree;
1153  ds->d_desc.dyn_tree = ds->dyn_dtree;
1154  ds->bl_desc.dyn_tree = ds->bl_tree;
1155 
1156  return Z_OK;
1157 #endif /* MAXSEG_64K */
1158 }
unsigned char Byte
Definition: zconf.h:391
#define ZALLOC(strm, items, size)
Definition: zutil.h:210
ush Pos
Definition: deflate.h:92
#define ds
Definition: i386-dis.c:434
#define Z_STREAM_ERROR
Definition: zlib.h:181
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.c:1079
Byte FAR Bytef
Definition: zconf.h:400
#define FAR
Definition: guiddef.h:36
#define Z_OK
Definition: zlib.h:177
unsigned short ush
Definition: zutil.h:36
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
Pos FAR Posf
Definition: deflate.h:93
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
Byte FAR * voidpf
Definition: zconf.h:413
static char * dest
Definition: rtl.c:135
ush FAR ushf
Definition: zutil.h:37
#define ss
Definition: i386-dis.c:432
uch FAR uchf
Definition: zutil.h:35
#define Z_NULL
Definition: zlib.h:212
#define Z_MEM_ERROR
Definition: zlib.h:183
unsigned int uInt
Definition: zconf.h:393

◆ deflateEnd()

int ZEXPORT deflateEnd ( z_streamp  strm)

Definition at line 1079 of file deflate.c.

1081 {
1082  int status;
1083 
1084  if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1085 
1086  status = strm->state->status;
1087 
1088  /* Deallocate in reverse order of allocations: */
1089  TRY_FREE(strm, strm->state->pending_buf);
1090  TRY_FREE(strm, strm->state->head);
1091  TRY_FREE(strm, strm->state->prev);
1092  TRY_FREE(strm, strm->state->window);
1093 
1094  ZFREE(strm, strm->state);
1095  strm->state = Z_NULL;
1096 
1097  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1098 }
#define TRY_FREE(s, p)
Definition: zutil.h:213
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define BUSY_STATE
Definition: deflate.h:62
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
#define ZFREE(strm, addr)
Definition: zutil.h:212
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
#define Z_DATA_ERROR
Definition: zlib.h:182
#define Z_NULL
Definition: zlib.h:212
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by CMSZipCodec::Compress(), compress2(), deflateCopy(), deflateInit2_(), gzclose_w(), zipCloseFileInZipRaw64(), and zlib_write_compressed_bit().

◆ deflateGetDictionary()

int ZEXPORT deflateGetDictionary ( z_streamp  strm,
Bytef dictionary,
uInt dictLength 
)

Definition at line 448 of file deflate.c.

452 {
453  deflate_state *s;
454  uInt len;
455 
456  if (deflateStateCheck(strm))
457  return Z_STREAM_ERROR;
458  s = strm->state;
459  len = s->strstart + s->lookahead;
460  if (len > s->w_size)
461  len = s->w_size;
462  if (dictionary != Z_NULL && len)
463  zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
464  if (dictLength != Z_NULL)
465  *dictLength = len;
466  return Z_OK;
467 }
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define Z_NULL
Definition: zlib.h:212
unsigned int uInt
Definition: zconf.h:393

◆ deflateInit2_()

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 243 of file deflate.c.

253 {
254  deflate_state *s;
255  int wrap = 1;
256  static const char my_version[] = ZLIB_VERSION;
257 
258  ushf *overlay;
259  /* We overlay pending_buf and d_buf+l_buf. This works since the average
260  * output size for (length,distance) codes is <= 24 bits.
261  */
262 
263  if (version == Z_NULL || version[0] != my_version[0] ||
264  stream_size != sizeof(z_stream)) {
265  return Z_VERSION_ERROR;
266  }
267  if (strm == Z_NULL) return Z_STREAM_ERROR;
268 
269  strm->msg = Z_NULL;
270  if (strm->zalloc == (alloc_func)0) {
271 #ifdef Z_SOLO
272  return Z_STREAM_ERROR;
273 #else
274  strm->zalloc = zcalloc;
275  strm->opaque = (voidpf)0;
276 #endif
277  }
278  if (strm->zfree == (free_func)0)
279 #ifdef Z_SOLO
280  return Z_STREAM_ERROR;
281 #else
282  strm->zfree = zcfree;
283 #endif
284 
285 #ifdef FASTEST
286  if (level != 0) level = 1;
287 #else
288  if (level == Z_DEFAULT_COMPRESSION) level = 6;
289 #endif
290 
291  if (windowBits < 0) { /* suppress zlib wrapper */
292  wrap = 0;
294  }
295 #ifdef GZIP
296  else if (windowBits > 15) {
297  wrap = 2; /* write gzip wrapper instead */
298  windowBits -= 16;
299  }
300 #endif
301  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
302  windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
303  strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
304  return Z_STREAM_ERROR;
305  }
306  if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
307  s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
308  if (s == Z_NULL) return Z_MEM_ERROR;
309  strm->state = (struct internal_state FAR *)s;
310  s->strm = strm;
311  s->status = INIT_STATE; /* to pass state test in deflateReset() */
312 
313  s->wrap = wrap;
314  s->gzhead = Z_NULL;
315  s->w_bits = (uInt)windowBits;
316  s->w_size = 1 << s->w_bits;
317  s->w_mask = s->w_size - 1;
318 
319  s->hash_bits = (uInt)memLevel + 7;
320  s->hash_size = 1 << s->hash_bits;
321  s->hash_mask = s->hash_size - 1;
322  s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
323 
324  s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
325  s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
326  s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
327 
328  s->high_water = 0; /* nothing written to s->window yet */
329 
330  s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
331 
332  overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
333  s->pending_buf = (uchf *) overlay;
334  s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
335 
336  if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
337  s->pending_buf == Z_NULL) {
338  s->status = FINISH_STATE;
339  strm->msg = ERR_MSG(Z_MEM_ERROR);
340  deflateEnd (strm);
341  return Z_MEM_ERROR;
342  }
343  s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
344  s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
345 
346  s->level = level;
347  s->strategy = strategy;
348  s->method = (Byte)method;
349 
350  return deflateReset(strm);
351 }
#define INIT_STATE
Definition: deflate.h:54
#define MIN_MATCH
Definition: zutil.h:64
GLint level
Definition: gl.h:1546
unsigned char Byte
Definition: zconf.h:391
int windowBits
Definition: zlib.h:813
#define ZALLOC(strm, items, size)
Definition: zutil.h:210
ush Pos
Definition: deflate.h:92
#define MAX_MEM_LEVEL
Definition: zconf.h:260
#define ERR_MSG(err)
Definition: zutil.h:52
#define Z_SOLO
Definition: cabinet.c:13
#define Z_STREAM_ERROR
Definition: zlib.h:181
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.c:1079
unsigned long ulg
Definition: zutil.h:38
Byte FAR Bytef
Definition: zconf.h:400
#define FAR
Definition: guiddef.h:36
#define ZLIB_VERSION
Definition: zlib.h:40
static const WCHAR version[]
Definition: asmname.c:64
#define Z_DEFLATED
Definition: zlib.h:209
int const char int stream_size
Definition: zlib.h:813
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:193
z_streamp strm
Definition: deflate.h:101
unsigned short ush
Definition: zutil.h:36
Pos FAR Posf
Definition: deflate.h:93
method
Definition: dragdrop.c:53
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039
#define FINISH_STATE
Definition: deflate.h:63
Byte FAR * voidpf
Definition: zconf.h:413
#define Z_VERSION_ERROR
Definition: zlib.h:185
void zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.c:173
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.c:164
#define Z_FIXED
Definition: zlib.h:199
int ZEXPORT deflateReset(z_streamp strm)
Definition: deflate.c:508
#define wrap(journal, var)
Definition: recovery.c:207
ush FAR ushf
Definition: zutil.h:37
uch FAR uchf
Definition: zutil.h:35
#define Z_NULL
Definition: zlib.h:212
#define Z_MEM_ERROR
Definition: zlib.h:183
unsigned int uInt
Definition: zconf.h:393

Referenced by deflateInit_().

◆ deflateInit_()

int ZEXPORT deflateInit_ ( z_streamp  strm,
int  level,
const char version,
int  stream_size 
)

Definition at line 231 of file deflate.c.

236 {
239  /* To do: ignore strm->next_in if we use it as window */
240 }
GLint level
Definition: gl.h:1546
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:200
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)
Definition: deflate.c:243
static const WCHAR version[]
Definition: asmname.c:64
#define Z_DEFLATED
Definition: zlib.h:209
int const char int stream_size
Definition: zlib.h:813
z_streamp strm
Definition: deflate.h:101
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define MAX_WBITS
Definition: zconf.h:270

◆ deflateParams()

int ZEXPORT deflateParams ( z_streamp  strm,
int  level,
int  strategy 
)

Definition at line 571 of file deflate.c.

575 {
576  deflate_state *s;
577  compress_func func;
578 
580  s = strm->state;
581 
582 #ifdef FASTEST
583  if (level != 0) level = 1;
584 #else
585  if (level == Z_DEFAULT_COMPRESSION) level = 6;
586 #endif
587  if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
588  return Z_STREAM_ERROR;
589  }
590  func = configuration_table[s->level].func;
591 
592  if ((strategy != s->strategy || func != configuration_table[level].func) &&
593  s->high_water) {
594  /* Flush the last buffer: */
595  int err = deflate(strm, Z_BLOCK);
596  if (err == Z_STREAM_ERROR)
597  return err;
598  if (strm->avail_out == 0)
599  return Z_BUF_ERROR;
600  }
601  if (s->level != level) {
602  if (s->level == 0 && s->matches != 0) {
603  if (s->matches == 1)
604  slide_hash(s);
605  else
606  CLEAR_HASH(s);
607  s->matches = 0;
608  }
609  s->level = level;
610  s->max_lazy_match = configuration_table[level].max_lazy;
611  s->good_match = configuration_table[level].good_length;
612  s->nice_match = configuration_table[level].nice_length;
613  s->max_chain_length = configuration_table[level].max_chain;
614  }
615  s->strategy = strategy;
616  return Z_OK;
617 }
GLenum func
Definition: glext.h:6028
GLint level
Definition: gl.h:1546
ush good_length
Definition: deflate.c:121
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_BUF_ERROR
Definition: zlib.h:184
const config configuration_table[10]
Definition: deflate.c:134
#define Z_OK
Definition: zlib.h:177
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:193
z_streamp strm
Definition: deflate.h:101
compress_func func
Definition: deflate.c:125
ush max_chain
Definition: deflate.c:124
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
#define CLEAR_HASH(s)
Definition: deflate.c:192
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.c:766
GLdouble s
Definition: gl.h:2039
ush max_lazy
Definition: deflate.c:122
#define err(...)
void slide_hash(deflate_state *s)
Definition: deflate.c:204
#define Z_BLOCK
Definition: zlib.h:173
#define Z_FIXED
Definition: zlib.h:199
ush nice_length
Definition: deflate.c:123

Referenced by gzsetparams().

◆ deflatePending()

int ZEXPORT deflatePending ( z_streamp  strm,
unsigned *  pending,
int bits 
)

Definition at line 531 of file deflate.c.

535 {
537  if (pending != Z_NULL)
538  *pending = strm->state->pending;
539  if (bits != Z_NULL)
540  *bits = strm->state->bi_valid;
541  return Z_OK;
542 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
#define Z_NULL
Definition: zlib.h:212

◆ deflatePrime()

int ZEXPORT deflatePrime ( z_streamp  strm,
int  bits,
int  value 
)

Definition at line 545 of file deflate.c.

549 {
550  deflate_state *s;
551  int put;
552 
554  s = strm->state;
555  if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
556  return Z_BUF_ERROR;
557  do {
558  put = Buf_size - s->bi_valid;
559  if (put > bits)
560  put = bits;
561  s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
562  s->bi_valid += put;
563  _tr_flush_bits(s);
564  value >>= put;
565  bits -= put;
566  } while (bits);
567  return Z_OK;
568 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define put(ret, state, sp, n)
Definition: match.c:105
Byte FAR Bytef
Definition: zconf.h:400
#define Z_BUF_ERROR
Definition: zlib.h:184
#define Z_OK
Definition: zlib.h:177
#define Buf_size
Definition: deflate.h:51
z_streamp strm
Definition: deflate.h:101
unsigned short ush
Definition: zutil.h:36
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
Definition: trees.c:886
GLdouble s
Definition: gl.h:2039

◆ deflateReset()

int ZEXPORT deflateReset ( z_streamp  strm)

Definition at line 508 of file deflate.c.

510 {
511  int ret;
512 
514  if (ret == Z_OK)
515  lm_init(strm->state);
516  return ret;
517 }
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
int ret
int ZEXPORT deflateResetKeep(z_streamp strm)
Definition: deflate.c:470
void lm_init(deflate_state *s)
Definition: deflate.c:1197

Referenced by deflateInit2_(), and gz_comp().

◆ deflateResetKeep()

int ZEXPORT deflateResetKeep ( z_streamp  strm)

Definition at line 470 of file deflate.c.

472 {
473  deflate_state *s;
474 
475  if (deflateStateCheck(strm)) {
476  return Z_STREAM_ERROR;
477  }
478 
479  strm->total_in = strm->total_out = 0;
480  strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
481  strm->data_type = Z_UNKNOWN;
482 
483  s = (deflate_state *)strm->state;
484  s->pending = 0;
485  s->pending_out = s->pending_buf;
486 
487  if (s->wrap < 0) {
488  s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
489  }
490  s->status =
491 #ifdef GZIP
492  s->wrap == 2 ? GZIP_STATE :
493 #endif
494  s->wrap ? INIT_STATE : BUSY_STATE;
495  strm->adler =
496 #ifdef GZIP
497  s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
498 #endif
499  adler32(0L, Z_NULL, 0);
500  s->last_flush = Z_NO_FLUSH;
501 
502  _tr_init(s);
503 
504  return Z_OK;
505 }
#define INIT_STATE
Definition: deflate.h:54
UINT32 crc32
Definition: btrfs.c:3877
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define BUSY_STATE
Definition: deflate.h:62
#define Z_OK
Definition: zlib.h:177
#define Z_UNKNOWN
Definition: zlib.h:206
z_streamp strm
Definition: deflate.h:101
void ZLIB_INTERNAL _tr_init(deflate_state *s)
Definition: trees.c:379
if(!(yy_init))
Definition: macro.lex.yy.c:714
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
#define Z_NO_FLUSH
Definition: zlib.h:168
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039
#define GZIP_STATE
Definition: deflate.h:56
#define Z_NULL
Definition: zlib.h:212
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134

Referenced by deflateReset().

◆ deflateSetDictionary()

int ZEXPORT deflateSetDictionary ( z_streamp  strm,
const Bytef dictionary,
uInt  dictLength 
)

Definition at line 379 of file deflate.c.

383 {
384  deflate_state *s;
385  uInt str, n;
386  int wrap;
387  unsigned avail;
388  z_const unsigned char *next;
389 
391  return Z_STREAM_ERROR;
392  s = strm->state;
393  wrap = s->wrap;
394  if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
395  return Z_STREAM_ERROR;
396 
397  /* when using zlib wrappers, compute Adler-32 for provided dictionary */
398  if (wrap == 1)
399  strm->adler = adler32(strm->adler, dictionary, dictLength);
400  s->wrap = 0; /* avoid computing Adler-32 in read_buf */
401 
402  /* if dictionary would fill window, just replace the history */
403  if (dictLength >= s->w_size) {
404  if (wrap == 0) { /* already empty otherwise */
405  CLEAR_HASH(s);
406  s->strstart = 0;
407  s->block_start = 0L;
408  s->insert = 0;
409  }
410  dictionary += dictLength - s->w_size; /* use the tail */
411  dictLength = s->w_size;
412  }
413 
414  /* insert dictionary into window and hash */
415  avail = strm->avail_in;
416  next = strm->next_in;
417  strm->avail_in = dictLength;
418  strm->next_in = (z_const Bytef *)dictionary;
419  fill_window(s);
420  while (s->lookahead >= MIN_MATCH) {
421  str = s->strstart;
422  n = s->lookahead - (MIN_MATCH-1);
423  do {
424  UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
425 #ifndef FASTEST
426  s->prev[str & s->w_mask] = s->head[s->ins_h];
427 #endif
428  s->head[s->ins_h] = (Pos)str;
429  str++;
430  } while (--n);
431  s->strstart = str;
432  s->lookahead = MIN_MATCH-1;
433  fill_window(s);
434  }
435  s->strstart += s->lookahead;
436  s->block_start = (long)s->strstart;
437  s->insert = s->lookahead;
438  s->lookahead = 0;
439  s->match_length = s->prev_length = MIN_MATCH-1;
440  s->match_available = 0;
441  strm->next_in = next;
442  strm->avail_in = avail;
443  s->wrap = wrap;
444  return Z_OK;
445 }
#define INIT_STATE
Definition: deflate.h:54
#define MIN_MATCH
Definition: zutil.h:64
ush Pos
Definition: deflate.h:92
GLdouble n
Definition: glext.h:7729
#define UPDATE_HASH(s, h, c)
Definition: deflate.c:163
#define Z_STREAM_ERROR
Definition: zlib.h:181
static int avail
Definition: adh-main.c:39
#define z_const
Definition: zconf.h:237
Byte FAR Bytef
Definition: zconf.h:400
void fill_window(deflate_state *s)
Definition: deflate.c:1485
#define Z_OK
Definition: zlib.h:177
const WCHAR * str
z_streamp strm
Definition: deflate.h:101
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
static const WCHAR L[]
Definition: oid.c:1250
#define CLEAR_HASH(s)
Definition: deflate.c:192
GLdouble s
Definition: gl.h:2039
static unsigned __int64 next
Definition: rand_nt.c:6
#define long
Definition: qsort.c:33
#define wrap(journal, var)
Definition: recovery.c:207
#define Z_NULL
Definition: zlib.h:212
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134
unsigned int uInt
Definition: zconf.h:393

◆ deflateSetHeader()

int ZEXPORT deflateSetHeader ( z_streamp  strm,
gz_headerp  head 
)

Definition at line 520 of file deflate.c.

523 {
524  if (deflateStateCheck(strm) || strm->state->wrap != 2)
525  return Z_STREAM_ERROR;
526  strm->state->gzhead = head;
527  return Z_OK;
528 }
struct outqueuenode * head
Definition: adnsresfilter.c:66
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356

◆ deflateStateCheck()

int deflateStateCheck ( z_streamp  strm)

Definition at line 356 of file deflate.c.

358 {
359  deflate_state *s;
360  if (strm == Z_NULL ||
361  strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
362  return 1;
363  s = strm->state;
364  if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
365 #ifdef GZIP
366  s->status != GZIP_STATE &&
367 #endif
368  s->status != EXTRA_STATE &&
369  s->status != NAME_STATE &&
370  s->status != COMMENT_STATE &&
371  s->status != HCRC_STATE &&
372  s->status != BUSY_STATE &&
373  s->status != FINISH_STATE))
374  return 1;
375  return 0;
376 }
#define INIT_STATE
Definition: deflate.h:54
#define HCRC_STATE
Definition: deflate.h:61
#define BUSY_STATE
Definition: deflate.h:62
z_streamp strm
Definition: deflate.h:101
#define COMMENT_STATE
Definition: deflate.h:60
#define NAME_STATE
Definition: deflate.h:59
GLdouble s
Definition: gl.h:2039
#define FINISH_STATE
Definition: deflate.h:63
#define GZIP_STATE
Definition: deflate.h:56
#define EXTRA_STATE
Definition: deflate.h:58
#define Z_NULL
Definition: zlib.h:212
#define GZIP
Definition: deflate.h:23

Referenced by deflate(), deflateBound(), deflateCopy(), deflateEnd(), deflateGetDictionary(), deflateParams(), deflatePending(), deflatePrime(), deflateResetKeep(), deflateSetDictionary(), deflateSetHeader(), and deflateTune().

◆ deflateTune()

int ZEXPORT deflateTune ( z_streamp  strm,
int  good_length,
int  max_lazy,
int  nice_length,
int  max_chain 
)

Definition at line 620 of file deflate.c.

626 {
627  deflate_state *s;
628 
630  s = strm->state;
631  s->good_match = (uInt)good_length;
632  s->max_lazy_match = (uInt)max_lazy;
633  s->nice_match = nice_length;
634  s->max_chain_length = (uInt)max_chain;
635  return Z_OK;
636 }
#define Z_STREAM_ERROR
Definition: zlib.h:181
#define Z_OK
Definition: zlib.h:177
z_streamp strm
Definition: deflate.h:101
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
GLdouble s
Definition: gl.h:2039
unsigned int uInt
Definition: zconf.h:393

◆ fill_window()

void fill_window ( deflate_state s)

Definition at line 1485 of file deflate.c.

1487 {
1488  unsigned n;
1489  unsigned more; /* Amount of free space at the end of the window. */
1490  uInt wsize = s->w_size;
1491 
1492  Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
1493 
1494  do {
1495  more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
1496 
1497  /* Deal with !@#$% 64K limit: */
1498  if (sizeof(int) <= 2) {
1499  if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
1500  more = wsize;
1501 
1502  } else if (more == (unsigned)(-1)) {
1503  /* Very unlikely, but possible on 16 bit machine if
1504  * strstart == 0 && lookahead == 1 (input done a byte at time)
1505  */
1506  more--;
1507  }
1508  }
1509 
1510  /* If the window is almost full and there is insufficient lookahead,
1511  * move the upper half to the lower one to make room in the upper half.
1512  */
1513  if (s->strstart >= wsize+MAX_DIST(s)) {
1514 
1515  zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
1516  s->match_start -= wsize;
1517  s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
1518  s->block_start -= (long) wsize;
1519  slide_hash(s);
1520  more += wsize;
1521  }
1522  if (s->strm->avail_in == 0) break;
1523 
1524  /* If there was no sliding:
1525  * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
1526  * more == window_size - lookahead - strstart
1527  * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
1528  * => more >= window_size - 2*WSIZE + 2
1529  * In the BIG_MEM or MMAP case (not yet supported),
1530  * window_size == input_size + MIN_LOOKAHEAD &&
1531  * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
1532  * Otherwise, window_size == 2*WSIZE so more >= 2.
1533  * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
1534  */
1535  Assert(more >= 2, "more < 2");
1536 
1537  n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
1538  s->lookahead += n;
1539 
1540  /* Initialize the hash value now that we have some input: */
1541  if (s->lookahead + s->insert >= MIN_MATCH) {
1542  uInt str = s->strstart - s->insert;
1543  s->ins_h = s->window[str];
1544  UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
1545 #if MIN_MATCH != 3
1546  Call UPDATE_HASH() MIN_MATCH-3 more times
1547 #endif
1548  while (s->insert) {
1549  UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
1550 #ifndef FASTEST
1551  s->prev[str & s->w_mask] = s->head[s->ins_h];
1552 #endif
1553  s->head[s->ins_h] = (Pos)str;
1554  str++;
1555  s->insert--;
1556  if (s->lookahead + s->insert < MIN_MATCH)
1557  break;
1558  }
1559  }
1560  /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
1561  * but this is not important since only literal bytes will be emitted.
1562  */
1563 
1564  } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1565 
1566  /* If the WIN_INIT bytes after the end of the current data have never been
1567  * written, then zero those bytes in order to avoid memory check reports of
1568  * the use of uninitialized (or uninitialised as Julian writes) bytes by
1569  * the longest match routines. Update the high water mark for the next
1570  * time through here. WIN_INIT is set to MAX_MATCH since the longest match
1571  * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
1572  */
1573  if (s->high_water < s->window_size) {
1574  ulg curr = s->strstart + (ulg)(s->lookahead);
1575  ulg init;
1576 
1577  if (s->high_water < curr) {
1578  /* Previous high water mark below current data -- zero WIN_INIT
1579  * bytes or up to end of window, whichever is less.
1580  */
1581  init = s->window_size - curr;
1582  if (init > WIN_INIT)
1583  init = WIN_INIT;
1584  zmemzero(s->window + curr, (unsigned)init);
1585  s->high_water = curr + init;
1586  }
1587  else if (s->high_water < (ulg)curr + WIN_INIT) {
1588  /* High water mark at or above current data, but below current data
1589  * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
1590  * to end of window, whichever is less.
1591  */
1592  init = (ulg)curr + WIN_INIT - s->high_water;
1593  if (init > s->window_size - s->high_water)
1594  init = s->window_size - s->high_water;
1595  zmemzero(s->window + s->high_water, (unsigned)init);
1596  s->high_water += init;
1597  }
1598  }
1599 
1600  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
1601  "not enough room for search");
1602 }
#define MIN_MATCH
Definition: zutil.h:64
ush Pos
Definition: deflate.h:92
GLdouble n
Definition: glext.h:7729
#define UPDATE_HASH(s, h, c)
Definition: deflate.c:163
static int init
Definition: wintirpc.c:33
unsigned long ulg
Definition: zutil.h:38
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
#define WIN_INIT
Definition: deflate.h:294
#define MAX_DIST(s)
Definition: deflate.h:289
const WCHAR * str
#define MIN_LOOKAHEAD
Definition: deflate.h:284
static const struct encodedFiletime times[]
Definition: encode.c:556
#define Assert(cond, msg)
Definition: zutil.h:196
void zmemzero(Bytef *dest, uInt len)
Definition: zutil.c:41
if(!(yy_init))
Definition: macro.lex.yy.c:714
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
GLdouble s
Definition: gl.h:2039
void slide_hash(deflate_state *s)
Definition: deflate.c:204
#define long
Definition: qsort.c:33
unsigned int uInt
Definition: zconf.h:393

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

◆ flush_pending()

void flush_pending ( z_streamp  strm)

Definition at line 733 of file deflate.c.

735 {
736  unsigned len;
737  deflate_state *s = strm->state;
738 
739  _tr_flush_bits(s);
740  len = s->pending;
741  if (len > strm->avail_out) len = strm->avail_out;
742  if (len == 0) return;
743 
744  zmemcpy(strm->next_out, s->pending_out, len);
745  strm->next_out += len;
746  s->pending_out += len;
747  strm->total_out += len;
748  strm->avail_out -= len;
749  s->pending -= len;
750  if (s->pending == 0) {
751  s->pending_out = s->pending_buf;
752  }
753 }
z_streamp strm
Definition: deflate.h:101
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
Definition: trees.c:886
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039

Referenced by deflate(), and deflate_stored().

◆ lm_init()

void lm_init ( deflate_state s)

Definition at line 1197 of file deflate.c.

1199 {
1200  s->window_size = (ulg)2L*s->w_size;
1201 
1202  CLEAR_HASH(s);
1203 
1204  /* Set the default configuration parameters:
1205  */
1206  s->max_lazy_match = configuration_table[s->level].max_lazy;
1207  s->good_match = configuration_table[s->level].good_length;
1208  s->nice_match = configuration_table[s->level].nice_length;
1209  s->max_chain_length = configuration_table[s->level].max_chain;
1210 
1211  s->strstart = 0;
1212  s->block_start = 0L;
1213  s->lookahead = 0;
1214  s->insert = 0;
1215  s->match_length = s->prev_length = MIN_MATCH-1;
1216  s->match_available = 0;
1217  s->ins_h = 0;
1218 #ifndef FASTEST
1219 #ifdef ASMV
1220  match_init(); /* initialize the asm code */
1221 #endif
1222 #endif
1223 }
#define MIN_MATCH
Definition: zutil.h:64
ush good_length
Definition: deflate.c:121
unsigned long ulg
Definition: zutil.h:38
const config configuration_table[10]
Definition: deflate.c:134
ush max_chain
Definition: deflate.c:124
static const WCHAR L[]
Definition: oid.c:1250
#define CLEAR_HASH(s)
Definition: deflate.c:192
GLdouble s
Definition: gl.h:2039
ush max_lazy
Definition: deflate.c:122
ush nice_length
Definition: deflate.c:123

Referenced by deflateReset().

◆ longest_match()

uInt longest_match ( deflate_state s,
IPos  cur_match 
)

Definition at line 1239 of file deflate.c.

1242 {
1243  unsigned chain_length = s->max_chain_length;/* max hash chain length */
1244  register Bytef *scan = s->window + s->strstart; /* current string */
1245  register Bytef *match; /* matched string */
1246  register int len; /* length of current match */
1247  int best_len = (int)s->prev_length; /* best match length so far */
1248  int nice_match = s->nice_match; /* stop if match long enough */
1249  IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
1250  s->strstart - (IPos)MAX_DIST(s) : NIL;
1251  /* Stop when cur_match becomes <= limit. To simplify the code,
1252  * we prevent matches with the string of window index 0.
1253  */
1254  Posf *prev = s->prev;
1255  uInt wmask = s->w_mask;
1256 
1257 #ifdef UNALIGNED_OK
1258  /* Compare two bytes at a time. Note: this is not always beneficial.
1259  * Try with and without -DUNALIGNED_OK to check.
1260  */
1261  register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
1262  register ush scan_start = *(ushf*)scan;
1263  register ush scan_end = *(ushf*)(scan+best_len-1);
1264 #else
1265  register Bytef *strend = s->window + s->strstart + MAX_MATCH;
1266  register Byte scan_end1 = scan[best_len-1];
1267  register Byte scan_end = scan[best_len];
1268 #endif
1269 
1270  /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
1271  * It is easy to get rid of this optimization if necessary.
1272  */
1273  Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
1274 
1275  /* Do not waste too much time if we already have a good match: */
1276  if (s->prev_length >= s->good_match) {
1277  chain_length >>= 2;
1278  }
1279  /* Do not look for matches beyond the end of the input. This is necessary
1280  * to make deflate deterministic.
1281  */
1282  if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
1283 
1284  Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
1285 
1286  do {
1287  Assert(cur_match < s->strstart, "no future");
1288  match = s->window + cur_match;
1289 
1290  /* Skip to next match if the match length cannot increase
1291  * or if the match length is less than 2. Note that the checks below
1292  * for insufficient lookahead only occur occasionally for performance
1293  * reasons. Therefore uninitialized memory will be accessed, and
1294  * conditional jumps will be made that depend on those values.
1295  * However the length of the match is limited to the lookahead, so
1296  * the output of deflate is not affected by the uninitialized values.
1297  */
1298 #if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
1299  /* This code assumes sizeof(unsigned short) == 2. Do not use
1300  * UNALIGNED_OK if your compiler uses a different size.
1301  */
1302  if (*(ushf*)(match+best_len-1) != scan_end ||
1303  *(ushf*)match != scan_start) continue;
1304 
1305  /* It is not necessary to compare scan[2] and match[2] since they are
1306  * always equal when the other bytes match, given that the hash keys
1307  * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
1308  * strstart+3, +5, ... up to strstart+257. We check for insufficient
1309  * lookahead only every 4th comparison; the 128th check will be made
1310  * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
1311  * necessary to put more guard bytes at the end of the window, or
1312  * to check more often for insufficient lookahead.
1313  */
1314  Assert(scan[2] == match[2], "scan[2]?");
1315  scan++, match++;
1316  do {
1317  } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1318  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1319  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1320  *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
1321  scan < strend);
1322  /* The funny "do {}" generates better code on most compilers */
1323 
1324  /* Here, scan <= window+strstart+257 */
1325  Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1326  if (*scan == *match) scan++;
1327 
1328  len = (MAX_MATCH - 1) - (int)(strend-scan);
1329  scan = strend - (MAX_MATCH-1);
1330 
1331 #else /* UNALIGNED_OK */
1332 
1333  if (match[best_len] != scan_end ||
1334  match[best_len-1] != scan_end1 ||
1335  *match != *scan ||
1336  *++match != scan[1]) continue;
1337 
1338  /* The check at best_len-1 can be removed because it will be made
1339  * again later. (This heuristic is not always a win.)
1340  * It is not necessary to compare scan[2] and match[2] since they
1341  * are always equal when the other bytes match, given that
1342  * the hash keys are equal and that HASH_BITS >= 8.
1343  */
1344  scan += 2, match++;
1345  Assert(*scan == *match, "match[2]?");
1346 
1347  /* We check for insufficient lookahead only every 8th comparison;
1348  * the 256th check will be made at strstart+258.
1349  */
1350  do {
1351  } while (*++scan == *++match && *++scan == *++match &&
1352  *++scan == *++match && *++scan == *++match &&
1353  *++scan == *++match && *++scan == *++match &&
1354  *++scan == *++match && *++scan == *++match &&
1355  scan < strend);
1356 
1357  Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1358 
1359  len = MAX_MATCH - (int)(strend - scan);
1360  scan = strend - MAX_MATCH;
1361 
1362 #endif /* UNALIGNED_OK */
1363 
1364  if (len > best_len) {
1365  s->match_start = cur_match;
1366  best_len = len;
1367  if (len >= nice_match) break;
1368 #ifdef UNALIGNED_OK
1369  scan_end = *(ushf*)(scan+best_len-1);
1370 #else
1371  scan_end1 = scan[best_len-1];
1372  scan_end = scan[best_len];
1373 #endif
1374  }
1375  } while ((cur_match = prev[cur_match & wmask]) > limit
1376  && --chain_length != 0);
1377 
1378  if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1379  return s->lookahead;
1380 }
unsigned char Byte
Definition: zconf.h:391
Definition: match.c:28
#define MAX_MATCH
Definition: zutil.h:65
Posf * prev
Definition: deflate.h:134
unsigned long ulg
Definition: zutil.h:38
GLint limit
Definition: glext.h:10326
Byte FAR Bytef
Definition: zconf.h:400
#define MAX_DIST(s)
Definition: deflate.h:289
#define MIN_LOOKAHEAD
Definition: deflate.h:284
struct match match
Definition: match.c:33
unsigned short ush
Definition: zutil.h:36
#define Assert(cond, msg)
Definition: zutil.h:196
#define NIL
Definition: deflate.c:107
Pos FAR Posf
Definition: deflate.h:93
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
static IHTMLWindow2 * window
Definition: events.c:77
int nice_match
Definition: deflate.h:194
uInt strstart
Definition: deflate.h:162
ush FAR ushf
Definition: zutil.h:37
unsigned int uInt
Definition: zconf.h:393
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned IPos
Definition: deflate.h:94

Referenced by deflate_fast(), and deflate_slow().

◆ OF() [1/6]

int deflateStateCheck OF ( (z_streamp strm)  )

◆ OF() [2/6]

◆ OF() [3/6]

◆ OF() [4/6]

◆ OF() [5/6]

unsigned read_buf OF ( (z_streamp strm, Bytef *buf, unsigned size )

◆ OF() [6/6]

uInt longest_match OF ( (deflate_state *s, IPos cur_match)  )

◆ putShortMSB()

void putShortMSB ( deflate_state s,
uInt  b 
)

Definition at line 719 of file deflate.c.

722 {
723  put_byte(s, (Byte)(b >> 8));
724  put_byte(s, (Byte)(b & 0xff));
725 }
unsigned char Byte
Definition: zconf.h:391
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define put_byte(s, c)
Definition: deflate.h:281
GLdouble s
Definition: gl.h:2039

Referenced by deflate().

◆ read_buf()

unsigned read_buf ( z_streamp  strm,
Bytef buf,
unsigned  size 
)

Definition at line 1167 of file deflate.c.

1171 {
1172  unsigned len = strm->avail_in;
1173 
1174  if (len > size) len = size;
1175  if (len == 0) return 0;
1176 
1177  strm->avail_in -= len;
1178 
1179  zmemcpy(buf, strm->next_in, len);
1180  if (strm->state->wrap == 1) {
1181  strm->adler = adler32(strm->adler, buf, len);
1182  }
1183 #ifdef GZIP
1184  else if (strm->state->wrap == 2) {
1185  strm->adler = crc32(strm->adler, buf, len);
1186  }
1187 #endif
1188  strm->next_in += len;
1189  strm->total_in += len;
1190 
1191  return len;
1192 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
UINT32 crc32
Definition: btrfs.c:3877
z_streamp strm
Definition: deflate.h:101
GLsizeiptr size
Definition: glext.h:5919
void zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:17
GLenum GLsizei len
Definition: glext.h:6722
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134

Referenced by deflate_stored(), fill_window(), netcon_secure_connect_setup(), netconn_secure_connect(), test_blocking_rw(), and test_readfileex_pending().

◆ slide_hash()

void slide_hash ( deflate_state s)

Definition at line 204 of file deflate.c.

206 {
207  unsigned n, m;
208  Posf *p;
209  uInt wsize = s->w_size;
210 
211  n = s->hash_size;
212  p = &s->head[n];
213  do {
214  m = *--p;
215  *p = (Pos)(m >= wsize ? m - wsize : NIL);
216  } while (--n);
217  n = wsize;
218 #ifndef FASTEST
219  p = &s->prev[n];
220  do {
221  m = *--p;
222  *p = (Pos)(m >= wsize ? m - wsize : NIL);
223  /* If n is not on any hash chain, prev[n] is garbage but
224  * its value will never be used.
225  */
226  } while (--n);
227 #endif
228 }
ush Pos
Definition: deflate.h:92
GLdouble n
Definition: glext.h:7729
const GLfloat * m
Definition: glext.h:10848
#define NIL
Definition: deflate.c:107
Pos FAR Posf
Definition: deflate.h:93
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int uInt
Definition: zconf.h:393

Referenced by deflateParams(), and fill_window().

Variable Documentation

◆ configuration_table

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}}
block_state deflate_slow(deflate_state *s, int flush)
Definition: deflate.c:1929
block_state deflate_fast(deflate_state *s, int flush)
Definition: deflate.c:1827
block_state deflate_stored(deflate_state *s, int flush)
Definition: deflate.c:1646

Definition at line 134 of file deflate.c.

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

◆ deflate_copyright

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

Definition at line 54 of file deflate.c.