RAII guard that marks the current thread as "must not allocate".
Construct a ScopedNoAlloc at the entry of a real-time-safe region (audio callback, paint cycle) and let it destruct on the way out. While any instance is alive on the calling thread, is_in_no_alloc_scope() returns true.
On its own this class only tracks state — it does not intercept operator new. The intent is that:
- Pulp's audio (
Processor::process) and paint (View::paint_all) paths are wrapped in ScopedNoAlloc, so the contract is enforced uniformly.
- Sanitizers / debug allocator hooks can query
is_in_no_alloc_scope() and abort / log if an allocation sneaks into the scope. This class is the contract surface.
- The guard is a no-op in
NDEBUG so it costs nothing in release builds — same shape as PULP_DBG_ASSERT.
Follows the same approach as dedicated RT-safety libraries like radsan, built on the principle that UI paint should be treated as carefully as the audio thread.