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.64 by root, Mon Mar 24 20:39:34 2008 UTC vs.
Revision 1.65 by root, Tue Apr 1 19:50:38 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 PREFER_MALLOC
26#define DEBUG_SALLOC 25#define DEBUG_SALLOC 0
26#define PREFER_MALLOC 0
27 27
28#if __GNUC__ >= 3 28#if __GNUC__ >= 3
29# define is_constant(c) __builtin_constant_p (c) 29# define is_constant(c) __builtin_constant_p (c)
30# define expect(expr,value) __builtin_expect ((expr),(value)) 30# define expect(expr,value) __builtin_expect ((expr),(value))
31# define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) 31# define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality)
53#include <glib.h> 53#include <glib.h>
54 54
55#include <shstr.h> 55#include <shstr.h>
56#include <traits.h> 56#include <traits.h>
57 57
58#ifdef DEBUG_SALLOC 58#if DEBUG_SALLOC
59# define g_slice_alloc0(s) debug_slice_alloc0(s) 59# define g_slice_alloc0(s) debug_slice_alloc0(s)
60# define g_slice_alloc(s) debug_slice_alloc(s) 60# define g_slice_alloc(s) debug_slice_alloc(s)
61# define g_slice_free1(s,p) debug_slice_free1(s,p) 61# define g_slice_free1(s,p) debug_slice_free1(s,p)
62void *g_slice_alloc (unsigned long size); 62void *g_slice_alloc (unsigned long size);
63void *g_slice_alloc0 (unsigned long size); 63void *g_slice_alloc0 (unsigned long size);
241 241
242// for symmetry 242// for symmetry
243template<typename T> 243template<typename T>
244inline void sfree (T *ptr, int n = 1) throw () 244inline void sfree (T *ptr, int n = 1) throw ()
245{ 245{
246#ifdef PREFER_MALLOC 246#if PREFER_MALLOC
247 free (ptr); 247 free (ptr);
248#else 248#else
249 slice_alloc -= n * sizeof (T); 249 slice_alloc -= n * sizeof (T);
250 g_slice_free1 (n * sizeof (T), (void *)ptr); 250 g_slice_free1 (n * sizeof (T), (void *)ptr);
251#endif 251#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines