+
Skip to content

Update C++ PluginInterface pointer validity guarantees #141

@Ortham

Description

@Ortham

The documentation for GameInterface::LoadPlugins(), GameInterface::ClearLoadedPlugins(), GameInterface::GetPlugin() and GameInterface::GetLoadedPlugins() predates the switch from const PluginInterface* to std::shared_ptr<const PluginInterface> in v0.26.0 and requires the implementation to keep copies of the pointers it returns. That didn't add any overhead in v0.26.x or v0.27.0, but does as of v0.27.0.

It would be good to update the documentation so that pointer validity is a reflection of the type used, i.e. because it's a std::shared_ptr, it's valid for at least as long as the caller keeps a copy of the shared pointer, and libloot itself may or may not hold its own copies.

The current implementation would also support returning std::unique_ptr<const PluginInterface> instead of std::shared_ptr<const PluginInterface>, but it may be better to keep implementation options open to future changes by sticking to the latter, and the former not being copyable means that elements of std::vector<std::unique_ptr<const PluginInterface>> could be more awkward to work with.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载