Don't use exceptions in low-level mem allocator

This commit is contained in:
Howard Chu
2022-05-09 17:28:59 +01:00
parent ae8e98b681
commit 6f756473c0
8 changed files with 121 additions and 68 deletions
+6 -3
View File
@@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <new>
#include "allocator.hpp"
#include "intrin_portable.h"
#include "virtual_memory.hpp"
#include "virtual_memory.h"
#include "common.hpp"
namespace randomx {
@@ -50,11 +50,14 @@ namespace randomx {
template struct AlignedAllocator<CacheLineSize>;
void* LargePageAllocator::allocMemory(size_t count) {
return allocLargePagesMemory(count);
void *mem = allocLargePagesMemory(count);
if (mem == nullptr)
throw std::bad_alloc();
return mem;
}
void LargePageAllocator::freeMemory(void* ptr, size_t count) {
freePagedMemory(ptr, count);
};
}
}