diff options
author | jbj <devnull@localhost> | 2001-11-22 21:12:46 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-11-22 21:12:46 +0000 |
commit | 9d66753a5b99ecd9ae022c5ff42eec58b57d8c13 (patch) | |
tree | d7f987e75f8fecefc2342001779efd60da0a7d1e /zlib/deflate.c | |
parent | d77eeb993d5f2f63facad07452169f547f614503 (diff) | |
download | librpm-tizen-9d66753a5b99ecd9ae022c5ff42eec58b57d8c13.tar.gz librpm-tizen-9d66753a5b99ecd9ae022c5ff42eec58b57d8c13.tar.bz2 librpm-tizen-9d66753a5b99ecd9ae022c5ff42eec58b57d8c13.zip |
More annotations.
CVS patchset: 5206
CVS date: 2001/11/22 21:12:46
Diffstat (limited to 'zlib/deflate.c')
-rw-r--r-- | zlib/deflate.c | 138 |
1 files changed, 57 insertions, 81 deletions
diff --git a/zlib/deflate.c b/zlib/deflate.c index 25d5818e2..5541481c8 100644 --- a/zlib/deflate.c +++ b/zlib/deflate.c @@ -47,10 +47,11 @@ * */ -/* @(#) $Id$ */ +/* @(#) $Id: deflate.c,v 1.1.1.1 2001/11/21 19:43:12 jbj Exp $ */ #include "deflate.h" +/*@observer@*/ const char deflate_copyright[] = " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly "; /* @@ -70,29 +71,44 @@ typedef enum { finish_done /* finish done, accept no more input or output */ } block_state; -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +typedef block_state (*compress_func) OF((deflate_state *s, int flush)) + /*@modifies *s @*/; /* Compression function. Returns the block state after the call. */ -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -local block_state deflate_slow OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -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 void fill_window OF((deflate_state *s)) + /*@modifies *s @*/; +local block_state deflate_stored OF((deflate_state *s, int flush)) + /*@modifies *s @*/; +local block_state deflate_fast OF((deflate_state *s, int flush)) + /*@modifies *s @*/; +local block_state deflate_slow OF((deflate_state *s, int flush)) + /*@modifies *s @*/; +local void lm_init OF((deflate_state *s)) + /*@modifies *s @*/; +local void putShortMSB OF((deflate_state *s, uInt b)) + /*@modifies *s @*/; +local void flush_pending OF((z_streamp strm)) + /*@modifies strm @*/; +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)) + /*@modifies strm, *buf @*/; #ifdef ASMV - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); + void match_init OF((void)) /* asm code initialization */ + /*@*/; + uInt longest_match OF((deflate_state *s, IPos cur_match)) + /*@modifies s @*/; #else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); +local uInt longest_match OF((deflate_state *s, IPos cur_match)) + /*@modifies s @*/; #endif #ifdef DEBUG local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); + int length)) + /*@*/; #endif +/*@access z_streamp @*/ + /* =========================================================================== * Local data */ @@ -187,11 +203,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); @@ -199,19 +211,12 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size) } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - 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) { deflate_state *s; int noheader = 0; +/*@observer@*/ static const char* my_version = ZLIB_VERSION; ushf *overlay; @@ -273,7 +278,9 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { +/*@-assignexpose@*/ strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); +/*@=assignexpose@*/ deflateEnd (strm); return Z_MEM_ERROR; } @@ -288,10 +295,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; +int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength) { deflate_state *s; uInt length = dictLength; @@ -329,8 +333,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) } /* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; +int ZEXPORT deflateReset (z_streamp strm) { deflate_state *s; @@ -359,10 +362,7 @@ int ZEXPORT deflateReset (strm) } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -399,9 +399,7 @@ int ZEXPORT deflateParams(strm, level, strategy) * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; +local void putShortMSB (deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); @@ -413,8 +411,7 @@ local void putShortMSB (s, b) * to avoid allocating a large strm->next_out buffer and copying into it. * (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; +local void flush_pending(z_streamp strm) { unsigned len = strm->state->pending; @@ -433,9 +430,7 @@ local void flush_pending(strm) } /* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; +int ZEXPORT deflate (z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -567,8 +562,7 @@ int ZEXPORT deflate (strm, flush) } /* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; +int ZEXPORT deflateEnd (z_streamp strm) { int status; @@ -597,9 +591,7 @@ int ZEXPORT deflateEnd (strm) * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; +int ZEXPORT deflateCopy (z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K return Z_STREAM_ERROR; @@ -659,10 +651,7 @@ int ZEXPORT deflateCopy (dest, source) * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -local int read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; +local int read_buf(z_streamp strm, Bytef *buf, unsigned size) { unsigned len = strm->avail_in; @@ -684,8 +673,7 @@ local int read_buf(strm, buf, size) /* =========================================================================== * Initialize the "longest match" routines for a new zlib stream */ -local void lm_init (s) - deflate_state *s; +local void lm_init (deflate_state *s) { s->window_size = (ulg)2L*s->w_size; @@ -723,9 +711,7 @@ local void lm_init (s) * match.S. The code will be functionally equivalent. */ #ifndef FASTEST -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ @@ -865,9 +851,7 @@ local uInt longest_match(s, cur_match) /* --------------------------------------------------------------------------- * Optimized version for level == 1 only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ @@ -924,10 +908,7 @@ local uInt longest_match(s, cur_match) /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ if (zmemcmp(s->window + match, @@ -958,8 +939,7 @@ local void check_match(s, start, match, length) * performed for at least two bytes (required for the zip translate_eol * option -- not supported here). */ -local void fill_window(s) - deflate_state *s; +local void fill_window(deflate_state *s) { register unsigned n, m; register Posf *p; @@ -984,7 +964,9 @@ local void fill_window(s) */ } else if (s->strstart >= wsize+MAX_DIST(s)) { +/*@-aliasunique@*/ zmemcpy(s->window, s->window+wsize, (unsigned)wsize); +/*@=aliasunique@*/ s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; @@ -1078,9 +1060,7 @@ local void fill_window(s) * NOTE: this function should be optimized to avoid extra copying from * window to pending_buf. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; +local block_state deflate_stored(deflate_state *s, int flush) { /* Stored blocks are limited to 0xffff bytes, pending_buf is limited * to pending_buf_size, and each stored block has a 5 byte header: @@ -1136,9 +1116,7 @@ local block_state deflate_stored(s, flush) * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ @@ -1173,7 +1151,7 @@ local block_state deflate_fast(s, flush) * of the string with itself at the start of the input file). */ if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); +/*@i@*/ s->match_length = longest_match (s, hash_head); } /* longest_match() sets match_start */ } @@ -1232,9 +1210,7 @@ local block_state deflate_fast(s, flush) * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of hash chain */ int bflush; /* set if current block must be flushed */ @@ -1273,7 +1249,7 @@ local block_state deflate_slow(s, flush) * of the string with itself at the start of the input file). */ if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); +/*@i@*/ s->match_length = longest_match (s, hash_head); } /* longest_match() sets match_start */ |