Fix using memory mapping module allocator if possible

This commit is contained in:
Maschell 2026-03-17 20:27:21 +01:00
parent e9e5f34459
commit f00d4a9dc0

View File

@ -277,7 +277,7 @@ std::vector<ModuleContainer> ModuleManagement::loadAndLinkModules(const std::str
if (auto linkInfo = ModuleLinkInformationFactory::loadAndLink(std::span(file.data(), file.size()), defaultAllocator, error)) {
moduleContainers.emplace_back(std::move(metaInfo), std::move(*linkInfo));
} else {
auto errMsg = string_format("Failed to load/link module %s. %s", metaInfo.getExportName().c_str(), ModuleLinkErrorsToString(error));
auto errMsg = string_format("Failed to load/link module %s. %s", metaInfo.getExportName().c_str(), ModuleLinkErrorsToString(error).data());
DEBUG_FUNCTION_LINE_ERR("%s", errMsg.c_str());
OSFatal(errMsg.c_str());
}
@ -308,10 +308,10 @@ std::vector<ModuleContainer> ModuleManagement::loadAndLinkModules(const std::str
for (auto &[metaInfo, file] : regularModuleMetaInfoWithLoadedFiles) {
ModuleLinkErrors error = ModuleLinkErrors::MODULE_LINK_ERROR_NONE;
if (auto linkInfo = ModuleLinkInformationFactory::loadAndLink(std::span(file.data(), file.size()), defaultAllocator, error)) {
if (auto linkInfo = ModuleLinkInformationFactory::loadAndLink(std::span(file.data(), file.size()), *mappedAllocatorOpt, error)) {
moduleContainers.emplace_back(std::move(metaInfo), std::move(*linkInfo));
} else {
auto errMsg = string_format("Failed to load/link module %s. %s", metaInfo.getExportName().c_str(), ModuleLinkErrorsToString(error));
auto errMsg = string_format("Failed to load/link module %s. %s", metaInfo.getExportName().c_str(), ModuleLinkErrorsToString(error).data());
DEBUG_FUNCTION_LINE_ERR("%s", errMsg.c_str());
OSFatal(errMsg.c_str());
}