… | |
… | |
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) |
… | |
… | |
107 | struct refcounted |
110 | struct refcounted |
108 | { |
111 | { |
109 | mutable int refcnt; |
112 | mutable int refcnt; |
110 | refcounted () : refcnt (0) { } |
113 | refcounted () : refcnt (0) { } |
111 | void refcnt_inc () { ++refcnt; } |
114 | void refcnt_inc () { ++refcnt; } |
112 | void refcnt_dec () { --refcnt; |
115 | void refcnt_dec () { --refcnt; } |
113 | if (refcnt < 0)abort();}//D |
|
|
114 | }; |
116 | }; |
115 | |
117 | |
116 | template<class T> |
118 | template<class T> |
117 | struct refptr |
119 | struct refptr |
118 | { |
120 | { |