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:
43
docs/api/memory/linear-allocator/get-marker.md
Normal file
43
docs/api/memory/linear-allocator/get-marker.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# LinearAllocator::GetMarker
|
||||
|
||||
```cpp
|
||||
void* GetMarker() const;
|
||||
```
|
||||
|
||||
获取当前分配位置的标记。标记是内部偏移量(`m_offset`)的快照,可用于 `SetMarker` 恢复到该位置。此方法用于实现临时分配的撤销功能。
|
||||
|
||||
**参数:** 无
|
||||
|
||||
**返回:** 当前位置标记(偏移量值),类型为 `void*`
|
||||
|
||||
**注意:** 返回值是偏移量数值,不是指针。将其传给 `SetMarker` 可恢复到此分配位置。
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Memory/LinearAllocator.h>
|
||||
|
||||
LinearAllocator allocator(1024);
|
||||
|
||||
// 分配一些数据
|
||||
void* ptr1 = allocator.Allocate(128);
|
||||
|
||||
// 保存标记(用于回滚点)
|
||||
void* marker = allocator.GetMarker();
|
||||
|
||||
// 分配临时数据
|
||||
void* temp = allocator.Allocate(64);
|
||||
void* temp2 = allocator.Allocate(32);
|
||||
|
||||
// 临时数据用完了,恢复到标记位置
|
||||
allocator.SetMarker(marker);
|
||||
|
||||
// 此时 temp 和 temp2 的内存已被回收
|
||||
// ptr1 仍然有效
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [LinearAllocator 总览](linear-allocator.md) - 返回类总览
|
||||
Reference in New Issue
Block a user