On Wed, 25 May 2005, Braun Brelin wrote:
> 1. Garbage collection. No more malloc()/free() issues.
You can do this in C. Refcounts + last decrementer frees is quite
You can do more advanced garbage collection if you want, even a
psuedo-background-GC, if you registered memory references. Something
some_type *foo, *bar;
bar = memnew (sizeof foo);
foo = memref (&foo, bar); /* &foo holds reference to bar */
/* you could now 'memfree' bar.. and not have it free'd until
* &foo is memunref'd or even whenever &foo no longer holds the value
* of bar - in which case memunref would not be needed.
Fully automatic scanning of heap and keeping track of references in
stack (and hence not having to 'register' references) would be quite
difficult in C I suspect (and platform specific)
memnew, memref and memunref are left as an exercise for the reader.
Your system may already provide libraries which implement such things
(eg glib has 'caches' i think).
If you're using malloc/free bare, you're doing something wrong :).
I'd /almost/ argue that general code that fails to compile with
malloc/free defined to something nonsensical is broken.
Paul Jakma paul at clubi.iepaul at jakma.org Key ID: 64A2FF6A
Superior ability breeds superior ambition.
-- Spock, "Space Seed", stardate 3141.9
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!