--- deliantra/server/include/util.h 2008/01/25 18:09:23 1.61 +++ deliantra/server/include/util.h 2008/04/01 19:50:38 1.65 @@ -22,8 +22,8 @@ #ifndef UTIL_H__ #define UTIL_H__ -//#define PREFER_MALLOC -//#define DEBUG_SALLOC +#define DEBUG_SALLOC 0 +#define PREFER_MALLOC 0 #if __GNUC__ >= 3 # define is_constant(c) __builtin_constant_p (c) @@ -55,7 +55,7 @@ #include #include -#ifdef DEBUG_SALLOC +#if 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) @@ -92,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) @@ -240,7 +243,7 @@ template inline void sfree (T *ptr, int n = 1) throw () { -#ifdef PREFER_MALLOC +#if PREFER_MALLOC free (ptr); #else slice_alloc -= n * sizeof (T); @@ -268,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 () { } @@ -287,7 +290,7 @@ sfree (p, n); } - size_type max_size ()const throw () + size_type max_size () const throw () { return size_t (-1) / sizeof (Tp); }