MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bi_reverse

Function bi_reverse

freebsd/contrib/zlib/trees.c:1158–1168  ·  view source on GitHub ↗

=========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */

(code, len)

Source from the content-addressed store, hash-verified

1156 * IN assertion: 1 <= len <= 15
1157 */
1158local unsigned bi_reverse(code, len)
1159 unsigned code; /* the value to invert */
1160 int len; /* its bit length */
1161{
1162 register unsigned res = 0;
1163 do {
1164 res |= code & 1;
1165 code >>= 1, res <<= 1;
1166 } while (--len > 0);
1167 return res >> 1;
1168}
1169
1170/* ===========================================================================
1171 * Flush the bit buffer, keeping at most 7 bits in it.

Callers 2

tr_static_initFunction · 0.85
gen_codesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected