Files
XCSDD/docs/api/memory/linear-allocator/get-used-size.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

866 B

LinearAllocator::GetUsedSize

size_t GetUsedSize() const;

返回当前已使用的字节数,即内部偏移量的值。此值在 Allocate 后增加,在 ClearSetMarker 后可能减少(取决于设置的目标位置)。

参数:

返回: 已使用的字节数

复杂度: O(1)

示例:

#include <XCEngine/Memory/LinearAllocator.h>

LinearAllocator allocator(1024);

size_t before = allocator.GetUsedSize(); // 0

allocator.Allocate(128);
allocator.Allocate(256);

size_t after = allocator.GetUsedSize(); // 384

void* marker = allocator.GetMarker();
allocator.Allocate(64);
size_t with_temp = allocator.GetUsedSize(); // 448

allocator.SetMarker(marker);
size_t after_rollback = allocator.GetUsedSize(); // 384

相关文档