MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / DeCompress

Function DeCompress

extra/yassl/src/yassl_int.cpp:2714–2746  ·  view source on GitHub ↗

get uncompressed size in front

Source from the content-addressed store, hash-verified

2712
2713 // get uncompressed size in front
2714 int DeCompress(input_buffer& in, int sz, input_buffer& out)
2715 {
2716 byte tmp[LENGTH_SZ];
2717
2718 tmp[0] = in[AUTO];
2719 tmp[1] = in[AUTO];
2720
2721 uint16 len;
2722 ato16(tmp, len);
2723
2724 out.allocate(len);
2725
2726 z_stream d_stream; /* decompression stream */
2727
2728 d_stream.zalloc = myAlloc;
2729 d_stream.zfree = myFree;
2730 d_stream.opaque = (voidpf)0;
2731
2732 d_stream.next_in = in.get_buffer() + in.get_current();
2733 d_stream.avail_in = sz - sizeof(tmp);
2734 d_stream.next_out = out.get_buffer();
2735 d_stream.avail_out = out.get_capacity();
2736
2737 if (inflateInit(&d_stream) != Z_OK) return -1;
2738 int err = inflate(&d_stream, Z_FINISH);
2739 inflateEnd(&d_stream);
2740 if (err != Z_OK && err != Z_STREAM_END) return -1;
2741
2742 out.add_size(d_stream.total_out);
2743 in.set_current(in.get_current() + sz - sizeof(tmp));
2744
2745 return 0;
2746 }
2747
2748
2749#else // LIBZ

Callers 1

ProcessMethod · 0.85

Calls 7

ato16Function · 0.85
get_capacityMethod · 0.80
add_sizeMethod · 0.80
set_currentMethod · 0.80
allocateMethod · 0.45
get_bufferMethod · 0.45
get_currentMethod · 0.45

Tested by

no test coverage detected