| 102 | * 0 <= n < 16 |
| 103 | */ |
| 104 | void simplicity_read_buffer8(unsigned char* buf, size_t* len, frameItem* src, int n) { |
| 105 | simplicity_debug_assert(0 <= n && n < 16); |
| 106 | *len = 0; |
| 107 | |
| 108 | for (size_t i = (size_t)1 << n; 0 < i; i /= 2) { |
| 109 | if (readBit(src)) { |
| 110 | read8s(buf, i, src); |
| 111 | buf += i; *len += i; |
| 112 | } else { |
| 113 | forwardBits(src, i*8); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /* Write 'len' bytes to a Simplicity buffer of type (TWO^8)^<2^(n+1) from 'buf'. |
| 119 | * Advance the 'dst' frame to the end of the buffer type. |
no test coverage detected