Fetches 'len' 'uint32_t's from 'stream' into 'result'. * The bits in each 'uint32_t' are set from the MSB to the LSB and the 'uint32_t's of 'result' are set from 0 up to 'len'. * Returns 'SIMPLICITY_ERR_BITSTREAM_EOF' if not enough bits are available ('result' may be modified). * Returns 'SIMPLICITY_NO_ERROR' if successful. * * Precondition: uint32_t result[len]; * NULL != stre
| 14 | * NULL != stream |
| 15 | */ |
| 16 | static simplicity_err getWord32Array(uint32_t* result, const size_t len, bitstream* stream) { |
| 17 | for (size_t i = 0; i < len; ++i) { |
| 18 | /* Due to error codes, readNBits cannot fetch 32 bits at once. Instead we fetch two groups of 16 bits. */ |
| 19 | int32_t bits16 = simplicity_readNBits(16, stream); |
| 20 | if (bits16 < 0) return (simplicity_err)bits16; |
| 21 | result[i] = (uint32_t)bits16 << 16; |
| 22 | bits16 = simplicity_readNBits(16, stream); |
| 23 | if (bits16 < 0) return (simplicity_err)bits16; |
| 24 | result[i] |= (uint32_t)bits16; |
| 25 | } |
| 26 | return SIMPLICITY_NO_ERROR; |
| 27 | } |
| 28 | |
| 29 | /* Fetches a 256-bit hash value from 'stream' into 'result'. |
| 30 | * Returns 'SIMPLICITY_ERR_BITSTREAM_EOF' if not enough bits are available ('result' may be modified). |
no test coverage detected