@@ -72,10 +72,18 @@ class GzipReaderBase
72
72
void throwEx ( const std::string& s,
73
73
int err );
74
74
75
- void resetOutBuf ()
75
+ inline void resetOutBuf ()
76
76
{
77
77
mStream .next_out = &outBuf ()[0 ];
78
78
mStream .avail_out = outBuf ().size ();
79
+
80
+ if ( mStream .next_out == nullptr ) {
81
+ std::cerr << " Output buffer location is null. Can't work with this!\n " ;
82
+ }
83
+
84
+ if ( mStream .avail_out == 0 ) {
85
+ std::cerr << " Available outbut buffer is empty. Can't work with this!\n " ;
86
+ }
79
87
}
80
88
81
89
/* * only used by GzipBlockReader */
@@ -84,7 +92,7 @@ class GzipReaderBase
84
92
void prime ( uint8_t byte,
85
93
size_t bits );
86
94
87
- int step ( int flush = Z_BLOCK ); // One iteration of inflate
95
+ int step ( int flush = Z_BLOCK ); // One iteration of inflate
88
96
89
97
int stepThrow ( int flush = Z_BLOCK );
90
98
@@ -94,15 +102,35 @@ class GzipReaderBase
94
102
95
103
virtual size_t chunkSize () const ;
96
104
97
- virtual Wrapper wrapper () const { return Raw; }
105
+ inline virtual Wrapper wrapper () const { return Raw; }
98
106
99
107
virtual Buffer& outBuf () = 0;
100
108
101
- virtual void writeOut ()
109
+ inline virtual void writeOut ()
102
110
{
103
111
throw std::runtime_error ( " out of space in gzip output buffer" );
104
112
}
105
113
114
+ /* * debug function */
115
+ inline static void
116
+ dumpStream ( const z_stream& stream )
117
+ {
118
+ std::cerr
119
+ << " z_stream:\n "
120
+ << " next input from : " << (void *) stream.next_in << " \n "
121
+ << " available input bytes : " << stream.avail_in << " \n "
122
+ << " input bytes already read : " << stream.total_in << " \n "
123
+ << " \n "
124
+ << " next output to : " << (void *) stream.next_out << " \n "
125
+ << " remaining free output space : " << stream.avail_out << " \n "
126
+ << " output bytes already written : " << stream.total_out << " \n "
127
+ << " \n "
128
+ << " last error message : " << ( stream.msg == nullptr ? " (null)" : stream.msg ) << " \n "
129
+ << " data type guess : " << stream.data_type << " \n "
130
+ << " checksum for uncompressed data : " << stream.adler << " \n "
131
+ << " \n " ;
132
+ }
133
+
106
134
public:
107
135
GzipReaderBase ();
108
136
@@ -123,6 +151,7 @@ class GzipReaderBase
123
151
inline virtual void
124
152
reset ( Wrapper w )
125
153
{
154
+ dumpStream ( mStream );
126
155
CHECK_ZLIB ( inflateReset2 ( &mStream , w ) );
127
156
};
128
157
@@ -304,6 +333,7 @@ class SavingGzipReader : public GzipReaderInternal::PositionedGzipReader
304
333
off_t opos = 0 ) :
305
334
PositionedGzipReader ( fh, opos )
306
335
{
336
+ std::cerr << " Resize buffer to " << windowSize () << " \n " ;
307
337
mOutBuf .resize ( windowSize () );
308
338
}
309
339
0 commit comments