🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #5054

Re: Memory Protection!

#5054
From: Andrew Phillips 289 8712
Date: Tue, 28 Aug 1990 02:07
23 lines
1595 bytes
In article <2905@mindlink.UUCP> a218@mindlink.UUCP (Charlie Gibbs) writes:
>....
>     So could a Unix guru please enlighten me?  Is it actually
>considered evil to free memory yourself, or is it one of those
>conventions that just grew?

Its not evil but I think its more a matter of laziness.  Keeping
track of what memory was allocated can become tricky particularly if
you have an unrecoverable error (in which case you normally just
print a message and exit()).  Saying it is more efficient is merely a
justification for sloppy coding.

As for why you should free all memory.  Apart from the fact that your
program may be used as a subroutine as already mentioned, it makes it
easier to understand the code and maintain it.  For example, it is
unclear whether the memory is still allocated at the end of the
routine or has been released by a routine at a lower level.  So I
believe you should allocate and free all memory (and other resources)
in the same routine or in paired routines of the same level.

Andrew.
-- 
Andrew Phillips (andrew@teslab.lab.oz.au) Phone +61 (Aust) 2 (Sydney) 289 8712
Technical Details
Message-ID: <1033@teslab.lab.OZ>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!metro!pta!teti!teslab!andrew
References: <2905@mindlink.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!metro!pta!teti!teslab!andrew
From: andrew@teslab.lab.OZ (Andrew Phillips  289 8712)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Memory Protection!
Message-ID: <1033@teslab.lab.OZ>
Date: 28 Aug 90 02:07:07 GMT
References: <2905@mindlink.UUCP>
Reply-To: andrew@teslab.lab.oz.au (Andrew Phillips  289 8712)
Organization: Technology Evaluation Section, L.A.B., Sydney
Lines: 23