--- deliantra/server/include/util.h 2006/11/17 19:40:54 1.16 +++ deliantra/server/include/util.h 2006/12/16 03:08:26 1.17 @@ -45,11 +45,13 @@ }; // strictly the same as g_slice_alloc, but never returns 0 -void *alloc (int s) throw (std::bad_alloc); +void *salloc (int size) throw (std::bad_alloc); +// also copies src into the new area, like "memdup" +void *salloc (int size, void *src) throw (std::bad_alloc); // for symmetry -inline void dealloc (void *p, int s) throw () +inline void sfree (void *ptr, int size) throw () { - g_slice_free1 (s, p); + g_slice_free1 (size, ptr); } // a STL-compatible allocator that uses g_slice @@ -83,12 +85,12 @@ pointer allocate (size_type n, const_pointer = 0) { - return static_cast(alloc (n * sizeof (Tp))); + return static_cast(salloc (n * sizeof (Tp))); } void deallocate (pointer p, size_type n) { - dealloc (static_cast(p), n * sizeof (Tp)); + sfree (static_cast(p), n * sizeof (Tp)); } size_type max_size ()const throw () @@ -224,5 +226,10 @@ assign ((char *)&dst, src, N); } +typedef double tstamp; + +// return current time as timestampe +tstamp now (); + #endif