summaryrefslogtreecommitdiff
path: root/gc_cpp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gc_cpp.cc')
-rw-r--r--gc_cpp.cc46
1 files changed, 21 insertions, 25 deletions
diff --git a/gc_cpp.cc b/gc_cpp.cc
index 7ab4a2db..c046aafe 100644
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -33,18 +33,18 @@ built-in "new" and "delete".
#define GC_DONT_INCL_WINDOWS_H
#include "gc/gc.h"
-#include <new> // for bad_alloc, precedes include of gc_cpp.h
+#include <new> // for std, bad_alloc; precedes include of gc_cpp.h
#include "gc/gc_cpp.h" // for GC_OPERATOR_NEW_ARRAY
#if !(defined(_MSC_VER) || defined(__DMC__)) || defined(GC_NO_INLINE_STD_NEW)
-#if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
-# define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
-#else
-// Use bad_alloc() directly instead of GC_throw_bad_alloc() call.
-# define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
-#endif
+# if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
+# define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
+# else
+ // Use bad_alloc() directly instead of GC_throw_bad_alloc() call.
+# define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
+# endif
# if !defined(GC_NEW_DELETE_THROW_NOT_NEEDED) \
&& !defined(GC_NEW_DELETE_NEED_THROW) && GC_GNUC_PREREQ(4, 2) \
@@ -52,19 +52,17 @@ built-in "new" and "delete".
# define GC_NEW_DELETE_NEED_THROW
# endif
-# ifdef GC_NEW_DELETE_NEED_THROW
-# if __cplusplus >= 201703L || _MSVC_LANG >= 201703L
- // The "dynamic exception" syntax had been deprecated in C++11
- // and was removed in C++17.
-# define GC_DECL_NEW_THROW noexcept(false)
-# else
-# define GC_DECL_NEW_THROW throw(std::bad_alloc)
-# endif
-# else
+# ifndef GC_NEW_DELETE_NEED_THROW
# define GC_DECL_NEW_THROW /* empty */
-# endif
+# elif __cplusplus >= 201703L || _MSVC_LANG >= 201703L
+ // The "dynamic exception" syntax had been deprecated in C++11
+ // and was removed in C++17.
+# define GC_DECL_NEW_THROW noexcept(false)
+# else
+# define GC_DECL_NEW_THROW throw(std::bad_alloc)
+# endif // GC_NEW_DELETE_NEED_THROW
- void* operator new(size_t size) GC_DECL_NEW_THROW {
+ void* operator new(std::size_t size) GC_DECL_NEW_THROW {
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
if (0 == obj)
GC_ALLOCATOR_THROW_OR_ABORT();
@@ -73,7 +71,7 @@ built-in "new" and "delete".
# ifdef _MSC_VER
// This new operator is used by VC++ in case of Debug builds.
- void* operator new(size_t size, int /* nBlockUse */,
+ void* operator new(std::size_t size, int /* nBlockUse */,
const char* szFileName, int nLine)
{
# ifdef GC_DEBUG
@@ -93,7 +91,7 @@ built-in "new" and "delete".
}
# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
- void* operator new[](size_t size) GC_DECL_NEW_THROW {
+ void* operator new[](std::size_t size) GC_DECL_NEW_THROW {
void* obj = GC_MALLOC_UNCOLLECTABLE(size);
if (0 == obj)
GC_ALLOCATOR_THROW_OR_ABORT();
@@ -102,7 +100,7 @@ built-in "new" and "delete".
# ifdef _MSC_VER
// This new operator is used by VC++ 7+ in Debug builds.
- void* operator new[](size_t size, int nBlockUse,
+ void* operator new[](std::size_t size, int nBlockUse,
const char* szFileName, int nLine)
{
return operator new(size, nBlockUse, szFileName, nLine);
@@ -115,14 +113,12 @@ built-in "new" and "delete".
# endif // GC_OPERATOR_NEW_ARRAY
# if __cplusplus >= 201402L || _MSVC_LANG >= 201402L // C++14
- void operator delete(void* obj, size_t size) GC_NOEXCEPT {
- (void)size; // size is ignored
+ void operator delete(void* obj, std::size_t) GC_NOEXCEPT {
GC_FREE(obj);
}
# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
- void operator delete[](void* obj, size_t size) GC_NOEXCEPT {
- (void)size;
+ void operator delete[](void* obj, std::size_t) GC_NOEXCEPT {
GC_FREE(obj);
}
# endif