Skip to content

Commit 1b87519

Browse files
committed
pmr: make default resource throw on failure
1 parent 3f94857 commit 1b87519

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

api/util/alloc_pmr.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ namespace os::mem {
106106

107107
struct Default_pmr : public std::pmr::memory_resource {
108108
void* do_allocate(std::size_t size, std::size_t align) override {
109-
return memalign(align, size);
109+
auto* res = memalign(align, size);
110+
if (res == nullptr)
111+
throw std::bad_alloc();
112+
return res;
110113
}
111114

112115
void do_deallocate (void* ptr, size_t, size_t) override {

0 commit comments

Comments
 (0)