Path: utzoo!attcan!uunet!aplcen!samsung!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: free (NULL) Message-ID: <3102@goanna.cs.rmit.oz.au> Date: 30 May 90 06:57:45 GMT References: <1771@mindlink.UUCP> <2574@skye.ed.ac.uk> <1074:May3000:24:1990@stealth.acf.nyu.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 28 In article <1074:May3000:24:1990@stealth.acf.nyu.edu>, brnstnd@stealth.acf.nyu.edu writes: > In article <3078@goanna.cs.rmit.oz.au> ok@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."