[ODE] alloc vs. malloc again

Adam Moravanszky amoravanszky at dplanet.ch
Fri Jun 21 02:14:27 2002


> memory manager treats the pool like a stack.  In other words, have the
> assumption that allocations and frees will be invoked in stack order like
> push and pop operations.  Anyone know of an existing memory manager that
> works that way?
>

Hi,

Such a manager is absolutely trivial to write: just an array of objects with
a 'last' pointer, you can even use an STL vector -- no need to look for 3rd
party code. I have been doing this for my contacts (and all other often
allocated/freed objects) from day one.  The advantage of this approach is
that you can even reallocate the whole thing if you run out of space, so
there is no fixed max # of objects -- the STL vector will just grow
automatically.  I always thought it is quite foolish to think that ODE
contacts are so special that they require using some weird nonstandard and
dangerous allocator.

--
-- Adam Moravanszky