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

Function initReadFrame

src/simplicity/frame.h:31–39  ·  view source on GitHub ↗

Initialize a new read frame. * 'n' is the number of cells for the read frame. * 'from' is a pointer to the beginning of the new slice for the array of UWORDS to hold the frame's cells. * * Precondition: UWORD from[ROUND_UWORD(n)]; */

Source from the content-addressed store, hash-verified

29 * Precondition: UWORD from[ROUND_UWORD(n)];
30 */
31static inline frameItem initReadFrame(size_t n, UWORD* from) {
32 const size_t len = ROUND_UWORD(n);
33/* '(1U * len) * UWORD_BIT - n' equals the number of padding bits in a frame of size 'n'.
34 * Note that even if (len * UWORD_BIT) overflows,
35 * (1) We have ensured an unsigned computation by multiplying by 1U so the behaviour is well-defined.
36 * (2) after subtracting 'n' we are left with a value in the range 0 .. UWORD-BIT - 1.
37 */
38 return (frameItem){ .edge = from + len, .offset = (1U * len) * UWORD_BIT - n };
39}
40
41/* Initialize a new write frame.
42 * 'n' is the number of cells for the write frame.

Callers 3

test_hashBlockFunction · 0.85
runTCOFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_hashBlockFunction · 0.68