… | |
… | |
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_SALLOC 0 |
25 | #define DEBUG_POISON 0xaa // poison memory before freeing it if != 0 |
26 | #define PREFER_MALLOC 0 |
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 | |
28 | |
28 | #if __GNUC__ >= 3 |
29 | #if __GNUC__ >= 3 |
29 | # define is_constant(c) __builtin_constant_p (c) |
30 | # define is_constant(c) __builtin_constant_p (c) |
30 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
31 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
31 | # define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
32 | # define prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
… | |
… | |
217 | inline void sfree (T *ptr, int n = 1) throw () |
218 | inline void sfree (T *ptr, int n = 1) throw () |
218 | { |
219 | { |
219 | if (expect_true (ptr)) |
220 | if (expect_true (ptr)) |
220 | { |
221 | { |
221 | slice_alloc -= n * sizeof (T); |
222 | slice_alloc -= n * sizeof (T); |
|
|
223 | if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T)); |
222 | g_slice_free1 (n * sizeof (T), (void *)ptr); |
224 | g_slice_free1 (n * sizeof (T), (void *)ptr); |
223 | assert (slice_alloc >= 0);//D |
225 | assert (slice_alloc >= 0);//D |
224 | } |
226 | } |
225 | } |
227 | } |
226 | |
228 | |