Debian Codegraph @

gc/gc_badalc.cc

raw
1 /*
2 * Copyright (c) 2018-2020 Ivan Maidanski
3 *
4 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
6 *
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.
12 *
13 */
14
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.
17
18 #ifdef HAVE_CONFIG_H
19 # include "config.h"
20 #endif
21
22 #ifndef GC_BUILD
23 # define GC_BUILD
24 #endif
25
26 #define GC_DONT_INCL_WINDOWS_H
27 #include "gc.h"
28
29 #include <new> // for bad_alloc, precedes include of gc_cpp.h
30
31 #if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
32 # define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
33 #else
34 # define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
35 #endif
36
37 GC_API void GC_CALL GC_throw_bad_alloc() {
38 GC_ALLOCATOR_THROW_OR_ABORT();
39 }