Commit 34cfc823 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Update memstat to respect C++11

parent b8674120
...@@ -33,14 +33,28 @@ FMemStats FMemStats::controler; ...@@ -33,14 +33,28 @@ FMemStats FMemStats::controler;
} }
// Regular scalar delete // Regular scalar delete
void operator delete(void* p) { void operator delete(void* p) noexcept{
if(p){ if(p){
FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) ); FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) );
std::free(static_cast<unsigned char*>(p) - 8); std::free(static_cast<unsigned char*>(p) - 8);
} }
} }
void operator delete[](void* p) { void operator delete[](void* p) noexcept{
if(p){
FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) );
std::free(static_cast<unsigned char*>(p) - 8);
}
}
void operator delete ( void* p, const std::nothrow_t& /*tag*/) {
if(p){
FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) );
std::free(static_cast<unsigned char*>(p) - 8);
}
}
void operator delete[]( void* p, const std::nothrow_t& /*tag*/) {
if(p){ if(p){
FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) ); FMemStats::controler.deallocate( *(reinterpret_cast<size_t*>(static_cast<unsigned char*>(p) - 8)) );
std::free(static_cast<unsigned char*>(p) - 8); std::free(static_cast<unsigned char*>(p) - 8);
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
#include <stdexcept> #include <stdexcept>
#warning You are using mem stats #warning You are using mem stats
void* operator new(std::size_t n); void* operator new(std::size_t n);
void operator delete(void* p); void operator delete(void* p) noexcept;
void operator delete[](void* p); void operator delete[](void* p) noexcept;
void operator delete ( void* ptr, const std::nothrow_t& tag);
void operator delete[]( void* ptr, const std::nothrow_t& tag);
#endif #endif
/** Give the memory allocation details /** Give the memory allocation details
...@@ -64,8 +66,10 @@ private: ...@@ -64,8 +66,10 @@ private:
#ifdef ScalFMM_USE_MEM_STATS #ifdef ScalFMM_USE_MEM_STATS
friend void* operator new(std::size_t n); friend void* operator new(std::size_t n);
friend void operator delete(void* p); friend void operator delete(void* p) noexcept;
friend void operator delete[](void* p); friend void operator delete[](void* p) noexcept;
friend void operator delete ( void* ptr, const std::nothrow_t& tag);
friend void operator delete[]( void* ptr, const std::nothrow_t& tag);
#endif #endif
public: public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment