Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!mailrus!uunet!mcsun!ukc!edcastle!aiai!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.lang.c Subject: Re: free (NULL) Message-ID: <2614@skye.ed.ac.uk> Date: 31 May 90 10:55:46 GMT References: <1771@mindlink.UUCP> <2574@skye.ed.ac.uk> <3078@goanna.cs.rmit.oz.au> Reply-To: richard@aiai.UUCP (Richard Tobin) Organization: AIAI, University of Edinburgh, Scotland Lines: 21 In article <3078@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: [Description of the all-too-common problem of not knowing whether it's safe to free something.] One approach (which of course only solves part of the problem) is to write your own allocator, with a free() function that ignores attempts to free space that it didn't allocate. It can do this in various ways, such as looking at the pointer to see whether it's in the range of addresses it allocates (I suppose this is not strictly portable, as it will involve comparing pointers to different objects, but maybe you don't care about *that* sort of processor). This of course will further enrage those people who object to free(0), who needn't bother flaming about sloppy programming, thank you. -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin