wsl/hsakmt: Improve error handling in allocation

This change ensures consistent error
handling across build configurations.

Signed-off-by: lyndonli <Lyndon.Li@amd.com>
Signed-off-by: Flora Cui <flora.cui@amd.com>
Reviewed-by: Tianci Yin <tianci.yin@amd.com>
Part-of: <http://10.67.69.192/wsl/rocr-runtime/-/merge_requests/40>
This commit is contained in:
lyndonli
2025-03-10 17:38:46 +08:00
committed by Frank Min
parent f44abf508e
commit b5a9a5c36b
+4 -1
View File
@@ -208,8 +208,11 @@ template <typename Allocator> class SimpleHeap {
cache_size_ -= size;
} else { // Alloc new block - new block may be larger than default.
void* ptr = block_allocator_.alloc(bytes, size);
if (ptr == nullptr) {
fprintf(stderr, "Block allocation failed, Allocator is expected to throw.\n");
return nullptr;
}
base = reinterpret_cast<uintptr_t>(ptr);
assert(ptr != nullptr && "Block allocation failed, Allocator is expected to throw.");
}
in_use_size_ += size;