summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-21 18:07:14 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-21 18:29:57 +0200
commitc5a603ce2469ef6a23023ff276ccd24ca316f6c2 (patch)
tree1a20fd7fe415d910f9fd15e38e576ab5faeb5727
parentcf53a5d4938f6f64bd6d3fe70dd9b555c9d30d0f (diff)
ZCodec::mpIStm is apparently(?) effectively only used by ReadAsynchron
...(which can be called multiple times in a row). But which actually looks wrong... Change-Id: I2e4914e6fed8ced383e430699dd462add9da8c08
-rw-r--r--include/tools/zcodec.hxx2
-rw-r--r--tools/source/zcodec/zcodec.cxx39
2 files changed, 19 insertions, 22 deletions
diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx
index b93f796983c5..c7424ab592cb 100644
--- a/include/tools/zcodec.hxx
+++ b/include/tools/zcodec.hxx
@@ -54,7 +54,7 @@ class TOOLS_DLLPUBLIC ZCodec
void* mpsC_Stream;
void InitCompress();
- void InitDecompress();
+ void InitDecompress(SvStream & inStream);
void ImplWriteBack();
void UpdateCRC( sal_uInt8* pSource, long nDatSize );
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx
index 1adbca8d1721..47c97dc2fdf4 100644
--- a/tools/source/zcodec/zcodec.cxx
+++ b/tools/source/zcodec/zcodec.cxx
@@ -115,11 +115,10 @@ long ZCodec::Compress( SvStream& rIStm, SvStream& rOStm )
long nOldTotal_In = PZSTREAM->total_in;
assert(meState == STATE_INIT);
- mpIStm = &rIStm;
mpOStm = &rOStm;
InitCompress();
mpInBuf = new sal_uInt8[ mnInBufSize ];
- while (( PZSTREAM->avail_in = mpIStm->Read( PZSTREAM->next_in = mpInBuf, mnInBufSize )) != 0 )
+ while (( PZSTREAM->avail_in = rIStm.Read( PZSTREAM->next_in = mpInBuf, mnInBufSize )) != 0 )
{
if ( PZSTREAM->avail_out == 0 )
ImplWriteBack();
@@ -139,9 +138,8 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
long nOldTotal_Out = PZSTREAM->total_out;
assert(meState == STATE_INIT);
- mpIStm = &rIStm;
mpOStm = &rOStm;
- InitDecompress();
+ InitDecompress(rIStm);
PZSTREAM->next_out = mpOutBuf = new sal_uInt8[ PZSTREAM->avail_out = mnOutBufSize ];
do
{
@@ -149,7 +147,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
if ( PZSTREAM->avail_in == 0 && mnInToRead )
{
nInToRead = ( mnInBufSize > mnInToRead ) ? mnInToRead : mnInBufSize;
- PZSTREAM->avail_in = mpIStm->Read( PZSTREAM->next_in = mpInBuf, nInToRead );
+ PZSTREAM->avail_in = rIStm.Read( PZSTREAM->next_in = mpInBuf, nInToRead );
mnInToRead -= nInToRead;
if ( mbUpdateCrc )
@@ -204,10 +202,9 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize )
if ( mbFinish )
return 0; // PZSTREAM->total_out;
- mpIStm = &rIStm;
if (meState == STATE_INIT)
{
- InitDecompress();
+ InitDecompress(rIStm);
}
PZSTREAM->avail_out = nSize;
PZSTREAM->next_out = pData;
@@ -216,7 +213,7 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize )
if ( PZSTREAM->avail_in == 0 && mnInToRead )
{
nInToRead = (mnInBufSize > mnInToRead) ? mnInToRead : mnInBufSize;
- PZSTREAM->avail_in = mpIStm->Read (
+ PZSTREAM->avail_in = rIStm.Read (
PZSTREAM->next_in = mpInBuf, nInToRead);
mnInToRead -= nInToRead;
@@ -251,8 +248,8 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uIntPtr nSize
if (meState == STATE_INIT)
{
+ InitDecompress(rIStm);
mpIStm = &rIStm;
- InitDecompress();
}
PZSTREAM->avail_out = nSize;
PZSTREAM->next_out = pData;
@@ -340,7 +337,7 @@ void ZCodec::InitCompress()
PZSTREAM->avail_out = mnOutBufSize;
}
-void ZCodec::InitDecompress()
+void ZCodec::InitDecompress(SvStream & inStream)
{
assert(meState == STATE_INIT);
meState = STATE_DECOMPRESS;
@@ -349,45 +346,45 @@ void ZCodec::InitDecompress()
sal_uInt8 n1, n2, j, nMethod, nFlags;
for ( int i = 0; i < 2; i++ ) // gz - magic number
{
- mpIStm->ReadUChar( j );
+ inStream.ReadUChar( j );
if ( j != gz_magic[ i ] )
mbStatus = false;
}
- mpIStm->ReadUChar( nMethod );
- mpIStm->ReadUChar( nFlags );
+ inStream.ReadUChar( nMethod );
+ inStream.ReadUChar( nFlags );
if ( nMethod != Z_DEFLATED )
mbStatus = false;
if ( ( nFlags & GZ_RESERVED ) != 0 )
mbStatus = false;
/* Discard time, xflags and OS code: */
- mpIStm->SeekRel( 6 );
+ inStream.SeekRel( 6 );
/* skip the extra field */
if ( nFlags & GZ_EXTRA_FIELD )
{
- mpIStm->ReadUChar( n1 ).ReadUChar( n2 );
- mpIStm->SeekRel( n1 + ( n2 << 8 ) );
+ inStream.ReadUChar( n1 ).ReadUChar( n2 );
+ inStream.SeekRel( n1 + ( n2 << 8 ) );
}
/* skip the original file name */
if ( nFlags & GZ_ORIG_NAME)
{
do
{
- mpIStm->ReadUChar( j );
+ inStream.ReadUChar( j );
}
- while ( j && !mpIStm->IsEof() );
+ while ( j && !inStream.IsEof() );
}
/* skip the .gz file comment */
if ( nFlags & GZ_COMMENT )
{
do
{
- mpIStm->ReadUChar( j );
+ inStream.ReadUChar( j );
}
- while ( j && !mpIStm->IsEof() );
+ while ( j && !inStream.IsEof() );
}
/* skip the header crc */
if ( nFlags & GZ_HEAD_CRC )
- mpIStm->SeekRel( 2 );
+ inStream.SeekRel( 2 );
if ( mbStatus )
mbStatus = ( inflateInit2( PZSTREAM, -MAX_WBITS) != Z_OK ) ? false : true;
}