MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / bi_reverse

Function bi_reverse

extlibs/minizip/src/trees.c:1245–1257  ·  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

1243 * IN assertion: 1 <= len <= 15
1244 */
1245local unsigned bi_reverse(code, len)
1246unsigned code; /* the value to invert */
1247int len; /* its bit length */
1248{
1249 register unsigned res = 0;
1250 do
1251 {
1252 res |= code & 1;
1253 code >>= 1 , res <<= 1;
1254 }
1255 while (--len > 0);
1256 return res >> 1;
1257}
1258
1259/* ===========================================================================
1260 * 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