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:
37
docs/api/memory/linear-allocator/clear.md
Normal file
37
docs/api/memory/linear-allocator/clear.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# LinearAllocator::Clear
|
||||
|
||||
```cpp
|
||||
void Clear();
|
||||
```
|
||||
|
||||
清空分配器,将内部偏移量重置为 0,所有已分配的内存被视为已释放。下一次 `Allocate` 将从缓冲区起始位置开始。此方法不实际释放或修改底层内存,适合作为帧分配器使用,每帧开始时调用 Clear 重置。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 无
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/LinearAllocator.h>
|
||||
|
||||
LinearAllocator allocator(1024 * 1024);
|
||||
|
||||
// 第一帧
|
||||
void* frame1_ptr = allocator.Allocate(256);
|
||||
void* frame1_ptr2 = allocator.Allocate(128);
|
||||
// ... 第一帧渲染逻辑
|
||||
|
||||
// 帧结束时清空
|
||||
allocator.Clear();
|
||||
|
||||
// 第二帧重新开始
|
||||
void* frame2_ptr = allocator.Allocate(256);
|
||||
// 此时 frame1_ptr 已无效,但内存已被回收复用
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [LinearAllocator 总览](linear-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user