MCPcopy Create free account
hub / github.com/PDAL/PDAL / run

Method run

pdal/compression/DeflateCompression.cpp:191–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190private:
191 void run(const char *buf, size_t bufsize, int mode)
192 {
193 auto handleError = [](int ret) -> void
194 {
195 switch (ret)
196 {
197 case Z_OK:
198 case Z_STREAM_END:
199 return;
200 case Z_STREAM_ERROR:
201 throw compression_error("Internal error.");
202 case Z_DATA_ERROR:
203 throw compression_error("Corrupted data.");
204 case Z_MEM_ERROR:
205 throw compression_error("Memory allocation failure.");
206 default:
207 throw compression_error();
208 }
209 };
210
211 m_strm.next_in = reinterpret_cast<unsigned char *>(
212 const_cast<char *>(buf));
213 m_strm.avail_in = bufsize;
214 int ret = Z_OK;
215 do
216 {
217 m_strm.avail_out = CHUNKSIZE;
218 m_strm.next_out = m_tmpbuf;
219 ret = inflate(&m_strm, mode);
220 handleError(ret);
221 size_t written = CHUNKSIZE - m_strm.avail_out;
222 if (written)
223 m_cb(reinterpret_cast<char *>(m_tmpbuf), written);
224 } while (m_strm.avail_out == 0);
225 }
226
227private:
228 BlockCb m_cb;

Callers

nothing calls this directly

Calls 1

compression_errorClass · 0.85

Tested by

no test coverage detected