… | |
… | |
8 | #endif |
8 | #endif |
9 | |
9 | |
10 | #include <cstddef> |
10 | #include <cstddef> |
11 | |
11 | |
12 | #include <glib.h> |
12 | #include <glib.h> |
|
|
13 | |
|
|
14 | // use a gcc extension for auto declarations until ISO C++ sanctifies them |
|
|
15 | #define AUTODECL(var,expr) typeof(expr) var = (expr) |
13 | |
16 | |
14 | // makes dynamically allocated objects zero-initialised |
17 | // makes dynamically allocated objects zero-initialised |
15 | struct zero_initialised |
18 | struct zero_initialised |
16 | { |
19 | { |
17 | void *operator new (size_t s, void *p) |
20 | void *operator new (size_t s, void *p) |
… | |
… | |
83 | return static_cast<pointer>(alloc (n * sizeof (Tp))); |
86 | return static_cast<pointer>(alloc (n * sizeof (Tp))); |
84 | } |
87 | } |
85 | |
88 | |
86 | void deallocate (pointer p, size_type n) |
89 | void deallocate (pointer p, size_type n) |
87 | { |
90 | { |
88 | dealloc (static_cast<void *>(p), n); |
91 | dealloc (static_cast<void *>(p), n * sizeof (Tp)); |
89 | } |
92 | } |
90 | |
93 | |
91 | size_type max_size ()const throw () |
94 | size_type max_size ()const throw () |
92 | { |
95 | { |
93 | return size_t (-1) / sizeof (Tp); |
96 | return size_t (-1) / sizeof (Tp); |