--- deliantra/server/include/util.h 2008/04/15 03:16:02 1.68 +++ deliantra/server/include/util.h 2008/04/30 16:26:28 1.72 @@ -22,8 +22,9 @@ #ifndef UTIL_H__ #define UTIL_H__ -#define DEBUG_SALLOC 0 -#define PREFER_MALLOC 1 +#define DEBUG_POISON 0x00 // poison memory before freeing it if != 0 +#define DEBUG_SALLOC 0 // add a debug wrapper around all sallocs +#define PREFER_MALLOC 0 // use malloc and not the slice allocator #if __GNUC__ >= 3 # define is_constant(c) __builtin_constant_p (c) @@ -219,11 +220,20 @@ if (expect_true (ptr)) { slice_alloc -= n * sizeof (T); + if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T)); g_slice_free1 (n * sizeof (T), (void *)ptr); assert (slice_alloc >= 0);//D } } +// nulls the pointer +template +inline void sfree0 (T *&ptr, int n = 1) throw () +{ + sfree (ptr, n); + ptr = 0; +} + // makes dynamically allocated objects zero-initialised struct zero_initialised {