Files
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

809 B

PoolAllocator::Free

void Free(void* ptr) override;

将内存块归还到空闲链表中。如果 ptrnullptr 则无效果。释放操作将块插入空闲链表头部。必须传入从此池分配的指针,传入外部指针会导致未定义行为。

参数:

  • ptr - 指向要释放的内存块

返回:

复杂度: O(1)

示例:

#include <XCEngine/Memory/PoolAllocator.h>

PoolAllocator pool(sizeof(int), 100);

void* block = pool.Allocate();
if (block) {
    int* num = static_cast<int*>(block);
    *num = 123;
    
    pool.Free(block); // 归还到空闲链表
    block = nullptr;
}

// 检查空闲块数量
size_t freeCount = pool.GetFreeBlockCount();

相关文档