Skip to content

Commit

Permalink
throw instead of std::cerr
Browse files Browse the repository at this point in the history
microcai committed Nov 10, 2024
1 parent 2c03720 commit 3497743
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/executable_allocator.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@


#ifdef _WIN32
#include <windows.h>
#else
#include <sys/mman.h>
#endif

#include <new>

#include "executable_allocator.hpp"

#ifdef _WIN32
@@ -35,8 +37,6 @@ void ExecutableAllocator::unprotect(void* raw_ptr, std::size_t size)

#else

#include <iostream>

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;
}

0 comments on commit 3497743

Please sign in to comment.