class AllocChecker
Defined at line 29 of file ../../src/devices/lib/dev-operation/include/lib/operation/helpers/alloc_checker.h
An object which is passed to operator new to allow client code to handle
allocation failures. Once armed by operator new, the client must call `check()`
to verify the state of the allocation checker before it goes out of scope.
Use it like this:
AllocChecker ac;
MyObject* obj = new (
&ac
) MyObject();
if (!ac.check()) {
// handle allocation failure (obj will be null)
}
Public Methods
void AllocChecker ()
Defined at line 31 of file ../../src/devices/lib/dev-operation/include/lib/operation/helpers/alloc_checker.h
void ~AllocChecker ()
Defined at line 32 of file ../../src/devices/lib/dev-operation/include/lib/operation/helpers/alloc_checker.h
void arm (size_t size, bool result)
Arm the AllocChecker. Once armed, `check` must be called prior to destruction.
Defined at line 39 of file ../../src/devices/lib/dev-operation/include/lib/operation/helpers/alloc_checker.h
bool check ()
Return true if the previous allocation succeeded.
Defined at line 48 of file ../../src/devices/lib/dev-operation/include/lib/operation/helpers/alloc_checker.h