--- deliantra/server/include/util.h 2007/08/06 10:54:12 1.54 +++ deliantra/server/include/util.h 2007/10/16 05:34:24 1.57 @@ -174,6 +174,8 @@ return ((d - 1) & 7) + 1; } +extern size_t slice_alloc; // statistics + // makes dynamically allocated objects zero-initialised struct zero_initialised { @@ -185,21 +187,25 @@ void *operator new (size_t s) { + slice_alloc += s; return g_slice_alloc0 (s); } void *operator new[] (size_t s) { + slice_alloc += s; return g_slice_alloc0 (s); } void operator delete (void *p, size_t s) { + slice_alloc -= s; g_slice_free1 (s, p); } void operator delete[] (void *p, size_t s) { + slice_alloc -= s; g_slice_free1 (s, p); } }; @@ -227,6 +233,7 @@ #ifdef PREFER_MALLOC free (ptr); #else + slice_alloc -= n * sizeof (T); g_slice_free1 (n * sizeof (T), (void *)ptr); #endif } @@ -347,6 +354,7 @@ refcnt_base () : refcnt (0) { } }; +// to avoid branches with more advanced compilers extern refcnt_base::refcnt_t refcnt_dummy; template @@ -546,8 +554,8 @@ int similar_direction (int a, int b); -// like printf, but returns a std::string -const std::string format (const char *format, ...); +// like sprintf, but returns a "static" buffer +const char *format (const char *format, ...); #endif