SWDEV-569319 Fix dangling reference warning (#2509)

* SWDEV-569319 Fix dangling reference warning

* fix nullptr warning

* use emplace

* return regular pointer
Bu işleme şunda yer alıyor:
pghoshamd authored and GitHub committed 2026-01-13 15:39:03 -06:00
1 ebeveyn 9dc2488b6b
işleme d2a1fc945e
3 files changed
+13 -13

No files matched your search

+6 -6
Dosyayı Görüntüle
@@ -1742,19 +1742,19 @@ namespace code {
return false;
}
const std::shared_ptr<AmdHsaCode>& AmdHsaCodeManager::FromHandle(hsa_code_object_t c)
AmdHsaCode* AmdHsaCodeManager::FromHandle(hsa_code_object_t c)
{
CodeMap::iterator i = codeMap.find(c.handle);
if (i == codeMap.end()) {
std::shared_ptr<AmdHsaCode> code = std::make_shared<AmdHsaCode>();
std::unique_ptr<AmdHsaCode> code = std::make_unique<AmdHsaCode>();
const void* buffer = reinterpret_cast<const void*>(c.handle);
if (!code->InitAsBuffer(buffer, 0)) {
return 0;
return nullptr;
}
codeMap[c.handle] = code;
return code;
auto res = codeMap.emplace(c.handle, std::move(code));
return res.first->second.get();
}
return i->second;
return i->second.get();
}
bool AmdHsaCodeManager::Destroy(hsa_code_object_t c)