53#ifndef PROTOCORE_SCRATCH_H
54#define PROTOCORE_SCRATCH_H
A scratch borrow whose acquire and release are one call each.
const pc_span & span() const
The borrowed region; empty if the arena could not satisfy it.
ScratchBorrow(const ScratchBorrow &)=delete
ScratchBorrow & operator=(const ScratchBorrow &)=delete
RAII scope guard for transient scratch borrows.
ScratchScope(const ScratchScope &)=delete
ScratchScope & operator=(const ScratchScope &)=delete
User-facing configuration for ProtoCore.
size_t scratch_mark(void)
Capture the current arena offset (a savepoint for scratch_release()).
pc_span pc_scratch_span(size_t n, size_t align)
Borrow n bytes as a span whose capacity is bound to the allocation.
bool pc_scratch_owns(const void *p)
True if p points inside the plaintext pool.
size_t scratch_capacity(void)
Total arena capacity in bytes (PC_SCRATCH_ARENA_SIZE).
void * scratch_alloc(size_t n, size_t align)
Borrow n bytes of scratch, aligned to align.
int pc_scratch_slot_of(const void *p)
Which plaintext slot owns p, or -1 if p is not in the plaintext pool.
size_t scratch_used(void)
Bytes currently handed out (0 immediately after a reset).
size_t scratch_high_water(void)
Largest scratch_used() value seen since boot (for sizing the arena).
void scratch_reset(void)
Reclaim the whole arena (empties it).
void scratch_release(size_t mark)
Reclaim everything allocated since mark (LIFO).
A byte region whose run length is bound in both directions.
A writable byte region: the storage, the capacity that belongs to it, and what has been produced into...