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

Function compress_block

zlib/trees.c:1072–1118  ·  view source on GitHub ↗

=========================================================================== * Send the block data compressed using the given Huffman trees */

(s, ltree, dtree)

Source from the content-addressed store, hash-verified

1070 * Send the block data compressed using the given Huffman trees
1071 */
1072local void compress_block(s, ltree, dtree)
1073 deflate_state *s;
1074 ct_data *ltree; /* literal tree */
1075 ct_data *dtree; /* distance tree */
1076{
1077 unsigned dist; /* distance of matched string */
1078 int lc; /* match length or unmatched char (if dist == 0) */
1079 unsigned lx = 0; /* running index in l_buf */
1080 unsigned code; /* the code to send */
1081 int extra; /* number of extra bits to send */
1082
1083 if (s->last_lit != 0) do {
1084 dist = s->d_buf[lx];
1085 lc = s->l_buf[lx++];
1086 if (dist == 0) {
1087 send_code(s, lc, ltree); /* send a literal byte */
1088 Tracecv(isgraph(lc), (stderr," '%c' ", lc));
1089 } else {
1090 /* Here, lc is the match length - MIN_MATCH */
1091 code = _length_code[lc];
1092 send_code(s, code+LITERALS+1, ltree); /* send the length code */
1093 extra = extra_lbits[code];
1094 if (extra != 0) {
1095 lc -= base_length[code];
1096 send_bits(s, lc, extra); /* send the extra length bits */
1097 }
1098 dist--; /* dist is now the match distance - 1 */
1099 code = d_code(dist);
1100 Assert (code < D_CODES, "bad d_code");
1101
1102 send_code(s, code, dtree); /* send the distance code */
1103 extra = extra_dbits[code];
1104 if (extra != 0) {
1105 dist -= base_dist[code];
1106 send_bits(s, dist, extra); /* send the extra distance bits */
1107 }
1108 } /* literal or match pair ? */
1109
1110 /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
1111 Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
1112 "pendingBuf overflow");
1113
1114 } while (lx < s->last_lit);
1115
1116 send_code(s, END_BLOCK, ltree);
1117 s->last_eob_len = ltree[END_BLOCK].Len;
1118}
1119
1120/* ===========================================================================
1121 * Set the data type to BINARY or TEXT, using a crude approximation:

Callers 1

trees.cFile · 0.85

Calls 1

send_bitsFunction · 0.85

Tested by

no test coverage detected