free (NULL)

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Wed May 30 16:57:45 AEST 1990


In article <1074:May3000:24:1990 at stealth.acf.nyu.edu>, brnstnd at stealth.acf.nyu.edu writes:
> In article <3078 at goanna.cs.rmit.oz.au> ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>   [ on the general problem of how to tell if an object is no longer ]
>   [ being pointed to ]
> > Can anyone suggest a better way of tackling this problem in portable C?

> Your second solution does the job most of the time: keep a count next to
> each pointer. With a disciplined style such as is enforced by, say, C++
> or a good macro set, you'll never forget to deal with the count.

This doesn't quite address my problem.  Obviously, if I am in total
control of a program, I can easily add and maintain counts.  I am quite
familiar with garbage collectors and have written several.  My real
problem is how can I write library packages so that it is easy for
*other* people using them to follow whatever protocol is necessary.
In this case, it seems to require the package users to maintain counts
themselves so they can pass them on.

C++ is another language.  I simply do not have the option of using it,
because most of the computers I have access to haven't got it installed,
and I'm not in control of them.  For my *own* purposes, using a garbage
collector is *more* portable, because the C garbage collector that came
over the net works on every kind of machine _I_ want to use.  (It _does_
work on Encores after all.)

-- 
"A 7th class of programs, correct in every way, is believed to exist by a
few computer scientists.  However, no example could be found to include here."



More information about the Comp.lang.c mailing list