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
This commit is contained in:
38
docs/api/memory/pool-allocator/free.md
Normal file
38
docs/api/memory/pool-allocator/free.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# PoolAllocator::Free
|
||||
|
||||
```cpp
|
||||
void Free(void* ptr) override;
|
||||
```
|
||||
|
||||
将内存块归还到空闲链表中。如果 `ptr` 为 `nullptr` 则无效果。释放操作将块插入空闲链表头部。必须传入从此池分配的指针,传入外部指针会导致未定义行为。
|
||||
|
||||
**参数:**
|
||||
- `ptr` - 指向要释放的内存块
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#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();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [PoolAllocator 总览](pool-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user