diff --git a/Source/bzip2/bzlib.c b/Source/bzip2/bzlib.c index fe9bdc2c..36ea2019 100644 --- a/Source/bzip2/bzlib.c +++ b/Source/bzip2/bzlib.c @@ -443,12 +443,8 @@ static DState local_state; /*---------------------------------------------------*/ int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm) + ( DState * s) { - DState* s=&local_state; - - s->strm = strm; - strm->state = s; s->state = BZ_X_BLKHDR_1; return BZ_OK; @@ -530,8 +526,8 @@ void unRLE_obuf_to_output_FAST ( DState* s ) Int32 c_k0 = s->k0; UInt32* c_tt = s->tt; UInt32 c_tPos = s->tPos; - char* cs_next_out = s->strm->next_out; - unsigned int cs_avail_out = s->strm->avail_out; + char* cs_next_out = s->next_out; + unsigned int cs_avail_out = s->avail_out; /* end restore */ UInt32 avail_out_INIT = cs_avail_out; @@ -594,8 +590,8 @@ void unRLE_obuf_to_output_FAST ( DState* s ) s->k0 = c_k0; // s->tt = c_tt; s->tPos = c_tPos; - s->strm->next_out = cs_next_out; - s->strm->avail_out = cs_avail_out; + s->next_out = cs_next_out; + s->avail_out = cs_avail_out; /* end save */ } @@ -603,10 +599,8 @@ void unRLE_obuf_to_output_FAST ( DState* s ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) +int BZ_API(BZ2_bzDecompress) ( DState *s ) { - DState* s; - s = strm->state; while (True) { if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; diff --git a/Source/bzip2/bzlib.h b/Source/bzip2/bzlib.h index 40186706..35708293 100644 --- a/Source/bzip2/bzlib.h +++ b/Source/bzip2/bzlib.h @@ -147,18 +147,6 @@ BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm - ); - -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm - ); - /*-- General stuff. --*/ #define BZ_VERSION "1.0.1, 23-June-2000" @@ -236,7 +224,7 @@ typedef unsigned short UInt16; typedef struct { /* pointer back to the struct bz_stream */ - bz_stream* strm; + bz_stream *strm; /* mode this stream is in, and whether inputting */ /* or outputting data */ @@ -386,10 +374,14 @@ typedef struct { typedef struct { /* pointer back to the struct bz_stream */ - bz_stream* strm; + char *next_in; + unsigned int avail_in; + + char *next_out; + unsigned int avail_out; /* state indicator for this stream */ - Int32 state; + char state; /* for doing the final run-length decoding */ UChar state_out_ch; @@ -500,9 +492,19 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + DState *s + ); + +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + DState * s + ); + #endif + /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ #ifdef BZ_NO_STDIO diff --git a/Source/bzip2/decompress.c b/Source/bzip2/decompress.c index c8798f97..fbd8ec79 100644 --- a/Source/bzip2/decompress.c +++ b/Source/bzip2/decompress.c @@ -81,13 +81,11 @@ static int __mygetbits(int *vtmp, int nnn, DState* s) *vtmp = v; return 0; } - if (s->strm->avail_in == 0) return 1; - s->bsBuff = (s->bsBuff << 8) | ((UInt32) (*((UChar*)(s->strm->next_in)))); + if (s->avail_in == 0) return 1; + s->bsBuff = (s->bsBuff << 8) | ((UInt32) (*((UChar*)(s->next_in)))); s->bsLive += 8; - s->strm->next_in++; - s->strm->avail_in--; -// s->strm->total_in_lo32++; - // if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++; + s->next_in++; + s->avail_in--; } } @@ -143,7 +141,6 @@ Int32 BZ2_decompress ( DState* s ) Int32 uc; Int32 retVal; Int32 minLen, maxLen; - bz_stream* strm = s->strm; /* stuff that needs to be saved/restored */ DState_save sv; diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index 4295164f..bd5ee35a 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -13,7 +13,7 @@ #include "../bzip2/bzlib.h" static char bz2_needreinit; -#define z_stream bz_stream +#define z_stream DState #define inflateInit(x) { if (BZ2_bzDecompressInit(x)<0) return _LANG_INVALIDCRC; } #define inflate(x) BZ2_bzDecompress(x) #define inflateReset(x) { if (bz2_needreinit) { inflateInit(x); } else bz2_needreinit++; }