--- deliantra/server/include/util.h 2007/12/16 02:50:33 1.59 +++ deliantra/server/include/util.h 2008/03/24 20:39:34 1.64 @@ -23,6 +23,7 @@ #define UTIL_H__ //#define PREFER_MALLOC +#define DEBUG_SALLOC #if __GNUC__ >= 3 # define is_constant(c) __builtin_constant_p (c) @@ -54,6 +55,15 @@ #include #include +#ifdef DEBUG_SALLOC +# define g_slice_alloc0(s) debug_slice_alloc0(s) +# define g_slice_alloc(s) debug_slice_alloc(s) +# define g_slice_free1(s,p) debug_slice_free1(s,p) +void *g_slice_alloc (unsigned long size); +void *g_slice_alloc0 (unsigned long size); +void g_slice_free1 (unsigned long size, void *ptr); +#endif + // use C0X decltype for auto declarations until ISO C++ sanctifies them (if ever) #define auto(var,expr) decltype(expr) var = (expr) @@ -82,6 +92,9 @@ template static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } +template static inline T min (T a, U b, V c) { return min (a, min (b, c)); } +template static inline T max (T a, U b, V c) { return max (a, max (b, c)); } + template static inline T lerp (T val, T min_in, T max_in, T min_out, T max_out) @@ -258,7 +271,7 @@ }; slice_allocator () throw () { } - slice_allocator (const slice_allocator &o) throw () { } + slice_allocator (const slice_allocator &) throw () { } template slice_allocator (const slice_allocator &) throw () { } @@ -277,7 +290,7 @@ sfree (p, n); } - size_type max_size ()const throw () + size_type max_size () const throw () { return size_t (-1) / sizeof (Tp); }