ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.70 by root, Sun Apr 20 05:24:55 2008 UTC vs.
Revision 1.72 by root, Wed Apr 30 16:26:28 2008 UTC

20 */ 20 */
21 21
22#ifndef UTIL_H__ 22#ifndef UTIL_H__
23#define UTIL_H__ 23#define UTIL_H__
24 24
25#define DEBUG_POISON 0xaa // poison memory before freeing it if != 0 25#define DEBUG_POISON 0x00 // poison memory before freeing it if != 0
26#define DEBUG_SALLOC 0 // add a debug wrapper around all sallocs 26#define DEBUG_SALLOC 0 // add a debug wrapper around all sallocs
27#define PREFER_MALLOC 0 // use malloc and not the slice allocator 27#define PREFER_MALLOC 0 // use malloc and not the slice allocator
28 28
29#if __GNUC__ >= 3 29#if __GNUC__ >= 3
30# define is_constant(c) __builtin_constant_p (c) 30# define is_constant(c) __builtin_constant_p (c)
222 slice_alloc -= n * sizeof (T); 222 slice_alloc -= n * sizeof (T);
223 if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T)); 223 if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T));
224 g_slice_free1 (n * sizeof (T), (void *)ptr); 224 g_slice_free1 (n * sizeof (T), (void *)ptr);
225 assert (slice_alloc >= 0);//D 225 assert (slice_alloc >= 0);//D
226 } 226 }
227}
228
229// nulls the pointer
230template<typename T>
231inline void sfree0 (T *&ptr, int n = 1) throw ()
232{
233 sfree<T> (ptr, n);
234 ptr = 0;
227} 235}
228 236
229// makes dynamically allocated objects zero-initialised 237// makes dynamically allocated objects zero-initialised
230struct zero_initialised 238struct zero_initialised
231{ 239{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines