Decode an encoded number between 1 and 3 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. *
| 81 | * Precondition: NULL != stream |
| 82 | */ |
| 83 | static int32_t decodeUpto3(bitstream* stream) { |
| 84 | int32_t result; |
| 85 | int32_t len = decodeUpto1Bit(&result, stream); |
| 86 | if (len < 0) return len; |
| 87 | result |= 1 << len; |
| 88 | return result; |
| 89 | } |
| 90 | |
| 91 | /* Decode an encoded bitstring up to length 3. |
| 92 | * If successful returns the length of the bitstring and 'result' contains the decoded bits. |
no test coverage detected