Files
XCEngine/docs/api/memory/proxy-allocator/reallocate.md
ssdfasd a9f882f233 docs: 修正 API 文档准确性 (第二轮检查)
修复的问题:
- math: 修复 Quaternion::Normalize 链接错误
- containers: HashMap 迭代器示例使用不存在的 cbegin/cend,删除冗余构造函数声明
- core: RefCounted 析构函数访问级别修正 (protected)
- debug: LogLevelToString 示例返回值大小写修正
- memory: 修正 LinearAllocator::Reallocate 返回 nullptr,ProxyAllocator 统计描述,头文件路径 IAllocator.h -> Allocator.h
- resources: Texture::Create mipLevels 参数描述修正
- rhi: 修复多处链接错误,新增缺失的方法文档
- threading: TaskSystem 配置项未实现状态标注,Wait 方法空实现标注
2026-03-19 00:31:14 +08:00

39 lines
946 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ProxyAllocator::Reallocate
```cpp
void* Reallocate(void* ptr, size_t newSize) override;
```
重新分配内存。调用直接转发到底层分配器,不记录任何统计信息(简化实现)。此方法仅将调用转发给底层分配器。
**参数:**
- `ptr` - 现有内存块指针
- `newSize` - 新的字节大小
**返回:** 成功返回新指针,失败返回 `nullptr`(由底层分配器决定)
**复杂度:** O(n)(底层分配器 + 数据复制)
**示例:**
```cpp
#include <XCEngine/Memory/MemoryManager.h>
#include <XCEngine/Memory/ProxyAllocator.h>
IAllocator* sysAlloc = MemoryManager::Get().GetSystemAllocator();
ProxyAllocator proxy(sysAlloc, "TrackedAlloc");
void* p1 = proxy.Allocate(128);
void* p2 = proxy.Reallocate(p1, 256);
if (p2) {
// 重新分配成功
} else {
// 失败p1 仍然有效
}
```
## 相关文档
- [ProxyAllocator 总览](proxy-allocator.md) - 返回类总览