#ifdef MEMORY_DEBUG
+#include <new>
+
class debug_new_counter_t
{
static int count;
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
#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
******************************************************************************/
#include "dbgnew.hh"
#include <stddef.h>
-#include <new>
#undef new
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)
// 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;
// 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];
#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)