Decode an encoded bitstring up to length 1. * If successful returns the length of the bitstring and 'result' contains the decoded bits. * The decoded bitstring is stored in the LSBs of 'result', with the LSB being the last bit decoded. * Any remaining bits in 'result' are reset to 0. * If the decoded bitstring would be too long 'SIMPLICITY_ERR_DATA_OUT_OF_RANGE' is returned ('result' may be mo
| 60 | * NULL != stream |
| 61 | */ |
| 62 | static int32_t decodeUpto1Bit(int32_t* result, bitstream* stream) { |
| 63 | *result = read1Bit(stream); |
| 64 | if (*result <= 0) return *result; |
| 65 | |
| 66 | *result = read1Bit(stream); |
| 67 | if (*result < 0) return *result; |
| 68 | if (0 != *result) return SIMPLICITY_ERR_DATA_OUT_OF_RANGE; |
| 69 | |
| 70 | *result = read1Bit(stream); |
| 71 | if (*result < 0) return *result; |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | /* Decode an encoded number between 1 and 3 inclusive. |
| 76 | * When successful returns the decoded result. |
no test coverage detected