Mail Archives: djgpp/1996/12/29/00:26:47
Morten Welinder wrote:
>
> "Alaric B. Williams" <alaric AT abwillms DOT demon DOT co DOT uk> writes:
>
> >Conservative GC can be used in C. It works like so:
>
> You cannot garbage collect in C unless you restrict the class
> of valid programs.
>
> Consider:
>
> -----------------------------------------------------------------------------
> m = malloc (...);
> <fill something into m's data area>
> <print m's address to a file, possibly using fprintf's %p>
> m = 0;
> ...
> <let garbage collection happen here>
> ...
> <reread m's address>
> <access m's data area>
> -----------------------------------------------------------------------------
>
> There is no way that the garbage collector could know that m's data
> area was pointed to by something in a file.
>
> But all this should not be taken to mean that a garbage collector
> used in connection with C can not be useful. This is just theory.
>
> Morten
not necessarely.I got a file on my hard that implements a garbage
collector in c++;it automatically deallocates an object when it isn't
pointed at anymore.I got it from the "byte" site,in the archives,on the
oldest '95 entry.
--
tudor 'at' cam 'dot' org
http://www.cam.org/~tudor
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d-(--) s(-):(+) a? C+ UL>++++ P L>+++++ E- W++ N o K---(----) w---
O---- M-- V-? PS+++ PE Y PGP t+ 5-- X+++>++++ R tv b+ DI D+ G e->++
h>++ r- y>+++++
------END GEEK CODE BLOCK------
- Raw text -