epifanio 2016-08-29 23:38:01 -04:00
parent eac73873aa
commit bb6e881699
2 changed files with 33 additions and 6 deletions

View File

@ -38,7 +38,11 @@
#define _MM_H
#include <sys/types.h>
// GCC with C++98 and -fexceptions requires exception
// specifiers, however with C++11 and newer, using them causes an error.
#if __cplusplus < 201103L
#define GRASS_MM_USE_EXCEPTION_SPECIFIER
#endif /* __cplusplus < 201103L */
#define MM_REGISTER_VERSION 2
@ -128,10 +132,17 @@ public:
void print();
friend class mm_register_init;
friend void * operator new(size_t) throw(std::bad_alloc);
friend void * operator new[](size_t) throw(std::bad_alloc);
#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
friend void * operator new(size_t) throw (std::bad_alloc);
friend void * operator new[] (size_t) throw (std::bad_alloc);
friend void operator delete(void *) throw();
friend void operator delete[](void *) throw();
#else
friend void * operator new(size_t);
friend void * operator new[] (size_t);
friend void operator delete(void *) noexcept;
friend void operator delete[](void *) noexcept;
#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
};
@ -160,4 +171,4 @@ extern MM_register MM_manager;
#endif // _MM_H
#endif // _MM_H

View File

@ -276,7 +276,11 @@ MM_err MM_register::register_deallocation(size_t sz) {
/* ************************************************************ */
void* operator new[] (size_t sz) throw(std::bad_alloc) {
#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
void* operator new[] (size_t sz) throw (std::bad_alloc) {
#else
void* operator new[] (size_t sz) {
#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
void *p;
MM_DEBUG cout << "new: sz=" << sz << ", register "
@ -327,7 +331,11 @@ void* operator new[] (size_t sz) throw(std::bad_alloc) {
/* ************************************************************ */
void* operator new (size_t sz) throw(std::bad_alloc) {
#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
void* operator new[] (size_t sz) throw (std::bad_alloc) {
#else
void* operator new[] (size_t sz) {
#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
void *p;
MM_DEBUG cout << "new: sz=" << sz << ", register "
@ -379,7 +387,11 @@ void* operator new (size_t sz) throw(std::bad_alloc) {
/* ---------------------------------------------------------------------- */
#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
void operator delete (void *ptr) throw() {
#else
void operator delete (void *ptr) noexcept {
#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
size_t sz;
void *p;
@ -419,7 +431,11 @@ void operator delete (void *ptr) throw() {
/* ---------------------------------------------------------------------- */
#ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER
void operator delete[] (void *ptr) throw() {
#else
void operator delete (void *ptr) noexcept {
#endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */
size_t sz;
void *p;