diff --git a/common/dbgnew.hh b/common/dbgnew.hh index c3164531bcbc7c5163125c7392dd3697d5292eb7..2f9ddbb6a48dbab92b3d9641f935849722e9f029 100644 --- a/common/dbgnew.hh +++ b/common/dbgnew.hh @@ -19,6 +19,8 @@ #ifdef MEMORY_DEBUG +#include <new> + class debug_new_counter_t { static int count; @@ -40,8 +42,15 @@ static debug_new_counter_t debug_new_counter; void* operator new(size_t size, const char* file, int line); void* operator new[](size_t size, const char* file, int line); +// TODO: these might be GCC version dependant +void* operator new(size_t size, const std::nothrow_t&, const char* file, int line); +void* operator new[](size_t size, const std::nothrow_t&, const char* file, int line); + +inline void* operator new(size_t, void* __p, const char*, int) { return __p; } +inline void* operator new[](size_t, void* __p, const char*, int) { return __p; } + // Redirect "normal" new to memory-tracking placement new. -#define new new(__FILE__, __LINE__) +#define new(...) new(__VA_ARGS__, __FILE__, __LINE__) #endif // MEMORY_DEBUG diff --git a/common/memory.h b/common/memory.h index 9ae9d88c79309360a4d8918cabbd2113da64158a..6f4a3f8071d88608ed2d7453fe9de670a8bb2284 100644 --- a/common/memory.h +++ b/common/memory.h @@ -143,7 +143,7 @@ extern "C" { #if defined(__GNUC__) && __GNUC__ < 3 # define mprintf(f, args...) mprintf_dbg(__FILE__, __LINE__, f, ## args) #else -# define mprintf(f,...) mprintf_dbg(__FILE__, __LINE__, f, __VA_ARGS__) +# define mprintf(...) mprintf_dbg(__FILE__, __LINE__, __VA_ARGS__) #endif #endif diff --git a/common/new.cc b/common/new.cc index 1b1c43a2d25fc7a474d972451535442fb16bb2d1..fa26100a42f21eabc8797741e48ba4ac1135f108 100644 --- a/common/new.cc +++ b/common/new.cc @@ -13,7 +13,6 @@ ******************************************************************************/ #include "dbgnew.hh" #include <stddef.h> -#include <new> #undef new @@ -56,6 +55,17 @@ void* operator new[](size_t size, const char* file, int line) else return Malloc_dbg(file, line, size); } +void* operator new(size_t size, const std::nothrow_t&, const char* file, int line) +{ + return Malloc_dbg(file, line, size); +} + +void* operator new[](size_t size, const std::nothrow_t&, const char* file, int line) +{ + if (size == 0) return &dummy; + else return Malloc_dbg(file, line, size); +} + int debug_new_counter_t::count = 0; // initial value #if defined(__CYGWIN__) || defined(INTERIX) diff --git a/core/Integer.cc b/core/Integer.cc index 9ac1c32d853b23c680d5743638a72e14eb4df051..52f884e0e88a2055d2f4cfa1f2da079acd166f53 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -598,11 +598,11 @@ long long int INTEGER::get_long_long_val() const // It feels so bad accessing a BIGNUM directly, but faster than string // conversion... // I know, I had to fix this... Bence - if (BN_num_bytes(val.openssl) <= sizeof(BN_ULONG)) { + if ((size_t)BN_num_bytes(val.openssl) <= sizeof(BN_ULONG)) { return !is_negative ? BN_get_word(val.openssl) : -BN_get_word(val.openssl); } - unsigned num_bytes = BN_num_bytes(val.openssl); + int num_bytes = BN_num_bytes(val.openssl); unsigned char* tmp = (unsigned char*)Malloc(num_bytes * sizeof(unsigned char)); BN_bn2bin(val.openssl, tmp); ret_val = tmp[0] & 0xff; @@ -1308,7 +1308,7 @@ int INTEGER::RAW_encode_openssl(const TTCN_Typedescriptor_t& p_td, // Conversion to 2's complement. if (twos_compl) { BN_set_negative(D, 0); - unsigned num_bytes = BN_num_bytes(D); + int num_bytes = BN_num_bytes(D); unsigned char* tmp = (unsigned char*)Malloc(num_bytes * sizeof(unsigned char)); BN_bn2bin(D, tmp); for (int a = 0; a < num_bytes; a++) tmp[a] = ~tmp[a]; diff --git a/core/LoggerPluginManager.cc b/core/LoggerPluginManager.cc index 10a7fd7ec6c8996f0192ce128231fe0c21356302..09c427981e018f5e4aa13c3ed0a3961455462fab 100644 --- a/core/LoggerPluginManager.cc +++ b/core/LoggerPluginManager.cc @@ -1799,8 +1799,6 @@ LoggerPlugin *LoggerPluginManager::find_plugin(const char *name) #undef new #endif -inline void * operator new (size_t, void * p) throw() { return p ; } - LoggerPluginManager::ActiveEvent::ActiveEvent(bool fake_event, event_destination_t dest) : event_() , event_str_(NULL)