docs: Fix memory module documentation discrepancies
- Add missing PoolAllocator class overview with methods table - Add missing LinearAllocator class overview with methods table - Add missing ProxyAllocator class overview with methods table - Fix PoolAllocator::Allocate example code and comments - Clarify ProxyAllocator::Free totalFreed calculation behavior - Fix CreateLinearAllocator complexity from O(size) to O(1) - Add note about Reallocate thread safety in ProxyAllocator
This commit is contained in:
@@ -19,11 +19,12 @@ void* Allocate(size_t size, size_t alignment = 0) override;
|
||||
```cpp
|
||||
#include <XCEngine/Memory/PoolAllocator.h>
|
||||
|
||||
PoolAllocator pool(sizeof(int) * 100, 50, alignof(int));
|
||||
// 创建能容纳 1000 个整数的内存池
|
||||
PoolAllocator pool(sizeof(int), 1000, alignof(int));
|
||||
|
||||
// 分配(忽略 size 参数)
|
||||
void* block1 = pool.Allocate(1); // 分配 1 字节
|
||||
void* block2 = pool.Allocate(10000); // 也分配一块
|
||||
// 分配(忽略 size 参数,只分配固定大小的块)
|
||||
void* block1 = pool.Allocate(1); // 分配一块(实际大小为 sizeof(int))
|
||||
void* block2 = pool.Allocate(10000); // 也分配一块(实际大小为 sizeof(int))
|
||||
|
||||
if (block1 && block2) {
|
||||
// 使用分配的内存块
|
||||
|
||||
Reference in New Issue
Block a user