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:
+4
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user