|
From: strk <st...@ke...> - 2004-04-28 09:11:54
|
I've added a garbage collector module for ming. Provides a call to add a new object to the allocations list passing object pointer and destructor function pointer and returning a memory node. Provides a call to remove a node from the list. Provides a Ming_collectGarbage() call to go throug the list and destroy all linked objects. Every Ming object module should include registration/removal of allocs if the compile time option TRACK_ALLOCS is defined and evaluates to something != 0. You can see an example in movie.c. Note that the list node pointer is embedded in the movie structure, so to be fast in link/unlink operations. If you do not call Ming_collectGarbage() everything is like before, except for bigger memory consumpion (6 bytes for each ming object in memory). If you don't define TRACK_ALLOCS everything will be *exactly* as before, and calls to Ming_collectGarbage will do nothing. I'd remove mem.c and mem.h for the sake of simplicity, they have a too general approach, which is not even working... Anyone against this ? --strk; |