template <typename T> class ScopedArenaAllocatorAdapter;
// Tag associated with each allocation to help prevent double free. enumclass ArenaFreeTag : uint8_t { // Allocation is used and has not yet been destroyed.
kUsed, // Allocation has been destroyed.
kFree,
};
// Holds a list of Arenas for use by ScopedArenaAllocator stack. // The memory is returned to the ArenaPool when the ArenaStack is destroyed. class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryTool { public: explicit ArenaStack(ArenaPool* arena_pool);
~ArenaStack();
using ArenaAllocatorMemoryTool::IsRunningOnMemoryTool; using ArenaAllocatorMemoryTool::MakeDefined; using ArenaAllocatorMemoryTool::MakeUndefined; using ArenaAllocatorMemoryTool::MakeInaccessible;
// Fast single-threaded allocator. Allocated chunks are _not_ guaranteed to be zero-initialized. // // Unlike the ArenaAllocator, ScopedArenaAllocator is intended for relatively short-lived // objects and allows nesting multiple allocators. Only the top allocator can be used but // once it's destroyed, its memory can be reused by the next ScopedArenaAllocator on the // stack. This is facilitated by returning the memory to the ArenaStack. class ScopedArenaAllocator
: private DebugStackReference, private DebugStackRefCounter, private ArenaAllocatorStats { public:
ScopedArenaAllocator(ScopedArenaAllocator&& other) noexcept; explicit ScopedArenaAllocator(ArenaStack* arena_stack);
~ScopedArenaAllocator();
// Get adapter for use in STL containers. See scoped_arena_containers.h .
ScopedArenaAllocatorAdapter<void> Adapter(ArenaAllocKind kind = kArenaAllocSTL);
size_t ApproximatePeakBytes();
// Allow a delete-expression to destroy but not deallocate allocators created by Create(). staticvoidoperatordelete([[maybe_unused]] void* ptr) {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.