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

Function decodeUpto65535

src/simplicity/bitstream.c:171–177  ·  view source on GitHub ↗

Decode an encoded number between 1 and 65535 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

169 * Precondition: NULL != stream
170 */
171static int32_t decodeUpto65535(bitstream* stream) {
172 int32_t result;
173 int32_t len = decodeUpto15Bits(&result, stream);
174 if (len < 0) return len;
175 result |= 1 << len;
176 return result;
177}
178
179/* Decode an encoded number between 1 and 2^31 - 1 inclusive.
180 * When successful returns the decoded result.

Callers 1

Calls 1

decodeUpto15BitsFunction · 0.85

Tested by

no test coverage detected