ScopeWith
Description
Open a scope that borrows an already-initialized allocator pointer. The pointer is exposed as MisraScope for the duration of the block. Nothing is destroyed on block exit - the caller still owns the allocator.
USAGE: typical helper pattern -
void my_helper(Vec(int) *v, Allocator *alloc) { ScopeWith(alloc) { Str scratch = StrInitFromCstr(“hi”, 2); StrDeinit(&scratch); } }
Success
Body runs once with MisraScope bound to alloc_ptr; the pointer is left untouched on block exit (caller still owns the allocator).
Failure
Macro cannot fail. Passing NULL is a usage error – tier-1 macros will dereference MisraScope and crash.
Usage example (Cross-references)
Usage examples (Cross-references)
No external code usages found in the scanned files.
Last updated on