MCPcopy Create free account
hub / github.com/ElementsProject/elements / decodeUpto15

Function decodeUpto15

src/simplicity/bitstream.c:127–133  ·  view source on GitHub ↗

Decode an encoded number between 1 and 15 inclusive. * When successful returns the decoded result. * If the decoded value would be too large, 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' is returned. * If more bits are needed than available in the 'stream', 'SIMPLICITY_ERR_BITSTRING_EOF' is returned. * If an I/O error occurs when reading from the 'stream', 'SIMPLICITY_ERR_BISTRING_ERROR' is returned. *

Source from the content-addressed store, hash-verified

125 * Precondition: NULL != stream
126 */
127static int32_t decodeUpto15(bitstream* stream) {
128 int32_t result;
129 int32_t len = decodeUpto3Bits(&result, stream);
130 if (len < 0) return len;
131 result |= 1 << len;
132 return result;
133}
134
135/* Decode an encoded bitstring up to length 15.
136 * If successful returns the length of the bitstring and 'result' contains the decoded bits.

Callers 1

decodeUpto15BitsFunction · 0.85

Calls 1

decodeUpto3BitsFunction · 0.85

Tested by

no test coverage detected