MCPcopy Create free account
hub / github.com/RsyncProject/rsync / send_tree

Function send_tree

zlib/trees.c:732–774  ·  view source on GitHub ↗

=========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */

Source from the content-addressed store, hash-verified

730 * bl_tree.
731 */
732local void send_tree(deflate_state *s, ct_data *tree, int max_code)
733{
734 int n; /* iterates over all tree elements */
735 int prevlen = -1; /* last emitted length */
736 int curlen; /* length of current code */
737 int nextlen = tree[0].Len; /* length of next code */
738 int count = 0; /* repeat count of the current code */
739 int max_count = 7; /* max repeat count */
740 int min_count = 4; /* min repeat count */
741
742 /* tree[max_code+1].Len = -1; */ /* guard already set */
743 if (nextlen == 0) max_count = 138, min_count = 3;
744
745 for (n = 0; n <= max_code; n++) {
746 curlen = nextlen; nextlen = tree[n+1].Len;
747 if (++count < max_count && curlen == nextlen) {
748 continue;
749 } else if (count < min_count) {
750 do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
751
752 } else if (curlen != 0) {
753 if (curlen != prevlen) {
754 send_code(s, curlen, s->bl_tree); count--;
755 }
756 Assert(count >= 3 && count <= 6, " 3_6?");
757 send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
758
759 } else if (count <= 10) {
760 send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
761
762 } else {
763 send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
764 }
765 count = 0; prevlen = curlen;
766 if (nextlen == 0) {
767 max_count = 138, min_count = 3;
768 } else if (curlen == nextlen) {
769 max_count = 6, min_count = 3;
770 } else {
771 max_count = 7, min_count = 4;
772 }
773 }
774}
775
776/* ===========================================================================
777 * Construct the Huffman tree for the bit lengths and return the index in

Callers 1

send_all_treesFunction · 0.85

Calls 1

send_bitsFunction · 0.85

Tested by

no test coverage detected