From 3497743b8a8cc5c446870dfcb94ad0f71a8deb58 Mon Sep 17 00:00:00 2001 From: microcai Date: Sun, 10 Nov 2024 22:42:37 +0800 Subject: [PATCH] throw instead of std::cerr --- src/executable_allocator.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/executable_allocator.cpp b/src/executable_allocator.cpp index 5b2dc62..50f651c 100644 --- a/src/executable_allocator.cpp +++ b/src/executable_allocator.cpp @@ -1,10 +1,12 @@ - + #ifdef _WIN32 #include #else #include #endif +#include + #include "executable_allocator.hpp" #ifdef _WIN32 @@ -35,8 +37,6 @@ void ExecutableAllocator::unprotect(void* raw_ptr, std::size_t size) #else -#include - void * ExecutableAllocator::allocate(std::size_t size) { // return malloc(size); @@ -47,8 +47,7 @@ void * ExecutableAllocator::allocate(std::size_t size) #endif if (out == nullptr) { - std::cerr << "unable to alloc executable page\n"; - std::terminate(); + throw std::bad_alloc{}; } return out; }