… | |
… | |
262 | { |
262 | { |
263 | sfree ((char *)p, s); |
263 | sfree ((char *)p, s); |
264 | } |
264 | } |
265 | }; |
265 | }; |
266 | |
266 | |
|
|
267 | // makes dynamically allocated objects zero-initialised |
|
|
268 | struct slice_allocated |
|
|
269 | { |
|
|
270 | void *operator new (size_t s, void *p) |
|
|
271 | { |
|
|
272 | return p; |
|
|
273 | } |
|
|
274 | |
|
|
275 | void *operator new (size_t s) |
|
|
276 | { |
|
|
277 | return salloc<char> (s); |
|
|
278 | } |
|
|
279 | |
|
|
280 | void *operator new[] (size_t s) |
|
|
281 | { |
|
|
282 | return salloc<char> (s); |
|
|
283 | } |
|
|
284 | |
|
|
285 | void operator delete (void *p, size_t s) |
|
|
286 | { |
|
|
287 | sfree ((char *)p, s); |
|
|
288 | } |
|
|
289 | |
|
|
290 | void operator delete[] (void *p, size_t s) |
|
|
291 | { |
|
|
292 | sfree ((char *)p, s); |
|
|
293 | } |
|
|
294 | }; |
|
|
295 | |
267 | // a STL-compatible allocator that uses g_slice |
296 | // a STL-compatible allocator that uses g_slice |
268 | // boy, this is verbose |
297 | // boy, this is verbose |
269 | template<typename Tp> |
298 | template<typename Tp> |
270 | struct slice_allocator |
299 | struct slice_allocator |
271 | { |
300 | { |
… | |
… | |
364 | int get_range (int r_min, int r_max); |
393 | int get_range (int r_min, int r_max); |
365 | }; |
394 | }; |
366 | |
395 | |
367 | typedef tausworthe_random_generator rand_gen; |
396 | typedef tausworthe_random_generator rand_gen; |
368 | |
397 | |
369 | extern rand_gen rndm; |
398 | extern rand_gen rndm, rmg_rndm; |
370 | |
399 | |
371 | INTERFACE_CLASS (attachable) |
400 | INTERFACE_CLASS (attachable) |
372 | struct refcnt_base |
401 | struct refcnt_base |
373 | { |
402 | { |
374 | typedef int refcnt_t; |
403 | typedef int refcnt_t; |