Added: dSpaceSetSublevel/dSpaceGetSublevel and possibility to collide a space as...
[ode.git] / ode / src / obstack.h
blobb5f715bafc5442367ee7eee472926a7c30ceaf3a
1 /*************************************************************************
2 * *
3 * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. *
4 * All rights reserved. Email: russ@q12.org Web: www.q12.org *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of EITHER: *
8 * (1) The GNU Lesser General Public License as published by the Free *
9 * Software Foundation; either version 2.1 of the License, or (at *
10 * your option) any later version. The text of the GNU Lesser *
11 * General Public License is included with this library in the *
12 * file LICENSE.TXT. *
13 * (2) The BSD-style license that is included with this library in *
14 * the file LICENSE-BSD.TXT. *
15 * *
16 * This library is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files *
19 * LICENSE.TXT and LICENSE-BSD.TXT for more details. *
20 * *
21 *************************************************************************/
23 #ifndef _ODE_OBSTACK_H_
24 #define _ODE_OBSTACK_H_
26 #include "objects.h"
28 // each obstack Arena pointer points to a block of this many bytes
29 #define dOBSTACK_ARENA_SIZE 16384
32 struct dObStack : public dBase {
33 struct Arena {
34 Arena *next; // next arena in linked list
35 size_t used; // total number of bytes used in this arena, counting
36 }; // this header
38 Arena *first; // head of the arena linked list. 0 if no arenas yet
39 Arena *last; // arena where blocks are currently being allocated
41 // used for iterator
42 Arena *current_arena;
43 size_t current_ofs;
45 dObStack();
46 ~dObStack();
48 void *alloc (int num_bytes);
49 // allocate a block in the last arena, allocating a new arena if necessary.
50 // it is a runtime error if num_bytes is larger than the arena size.
52 void freeAll();
53 // free all blocks in all arenas. this does not deallocate the arenas
54 // themselves, so future alloc()s will reuse them.
56 void *rewind();
57 // rewind the obstack iterator, and return the address of the first
58 // allocated block. return 0 if there are no allocated blocks.
60 void *next (int num_bytes);
61 // return the address of the next allocated block. 'num_bytes' is the size
62 // of the previous block. this returns null if there are no more arenas.
63 // the sequence of 'num_bytes' parameters passed to next() during a
64 // traversal of the list must exactly match the parameters passed to alloc().
68 #endif