ev-mold-unique-ptr-sections-001¶
| 字段 | 值 |
|---|---|
| 项目 | rui314/mold |
| 固定 commit | 27162691b71a |
| 路径 | src/mold.h |
| 行段 | L533-L535 |
| 特性 | std::unique_ptr |
| 许可证 | MIT |
| 代码来源 | 项目源码 |
| 级别 | manual |
| 审核 | zyuhao7 @ 2026-10-30 |
| 测试代码 | 否 |
| 发现方式 | manual |
用法¶
用 unique_ptr 成员表达输入段与重定位段的独占所有权
为什么典型¶
段对象生命周期与父对象绑定,容器持有 unique_ptr 即可自动释放,且禁止复制避免重复释放。
摘录¶
std::vector<InputSection<E> *> members;
std::vector<std::unique_ptr<Thunk<E>>> thunks;
std::unique_ptr<RelocSection<E>> reloc_sec;
备注¶
生产路径;thunks 用 vector