2 * Copyright (c) 2018-2019 Ivan Maidanski
4 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 * Permission is hereby granted to use or copy this program
8 * for any purpose, provided the above notices are retained on all copies.
9 * Permission to modify the code and to distribute modified code is granted,
10 * provided the above notices are retained, and a notice that the code was
11 * modified is included with the above copyright notice.
15 // This file provides the implementation of GC_throw_bad_alloc() which
16 // is invoked by GC operator "new" in case of an out-of-memory event.
26 #define GC_DONT_INCL_WINDOWS_H
29 #include <new> // for bad_alloc, precedes include of gc_cpp.h
31 #include "gc_cpp.h" // for GC_NEW_ABORTS_ON_OOM
33 #if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
34 # define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
36 # define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
39 GC_API void GC_CALL GC_throw_bad_alloc() {
40 GC_ALLOCATOR_THROW_OR_ABORT();