MCPcopy Create free account
hub / github.com/apache/thrift / untransform

Method untransform

lib/cpp/src/thrift/transport/THeaderTransport.cpp:263–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263void THeaderTransport::untransform(uint8_t* ptr, uint32_t sz) {
264 // Update the transform buffer size if needed
265 resizeTransformBuffer();
266
267 for (vector<uint16_t>::const_iterator it = readTrans_.begin(); it != readTrans_.end(); ++it) {
268 const uint16_t transId = *it;
269
270 if (transId == ZLIB_TRANSFORM) {
271 z_stream stream;
272 int err;
273
274 stream.next_in = ptr;
275 stream.avail_in = sz;
276
277 // Setting these to 0 means use the default free/alloc functions
278 stream.zalloc = (alloc_func)nullptr;
279 stream.zfree = (free_func)nullptr;
280 stream.opaque = (voidpf)nullptr;
281 err = inflateInit(&stream);
282 if (err != Z_OK) {
283 throw TApplicationException(TApplicationException::MISSING_RESULT,
284 "Error while zlib deflateInit");
285 }
286 stream.next_out = tBuf_.get();
287 stream.avail_out = tBufSize_;
288 err = inflate(&stream, Z_FINISH);
289 if (err != Z_STREAM_END || stream.avail_out == 0) {
290 throw TApplicationException(TApplicationException::MISSING_RESULT,
291 "Error while zlib deflate");
292 }
293 sz = stream.total_out;
294
295 err = inflateEnd(&stream);
296 if (err != Z_OK) {
297 throw TApplicationException(TApplicationException::MISSING_RESULT,
298 "Error while zlib deflateEnd");
299 }
300
301 memcpy(ptr, tBuf_.get(), sz);
302 } else {
303 throw TApplicationException(TApplicationException::MISSING_RESULT, "Unknown transform");
304 }
305 }
306
307 setReadBuffer(ptr, sz);
308}
309
310/**
311 * We may have updated the wBuf size, update the tBuf size to match.

Callers

nothing calls this directly

Calls 4

beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected