From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,345a8b767542016e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-16 21:43:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline@optelnow.net (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: memory leakages with Ada? Date: 16 Mar 2002 21:43:03 -0800 Organization: http://groups.google.com/ Message-ID: References: <3c90af1e@news.starhub.net.sg> <3c91bfa3.1987537@news.demon.co.uk> <3C921A81.9060708@mail.com> NNTP-Posting-Host: 24.219.81.150 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1016343783 14623 127.0.0.1 (17 Mar 2002 05:43:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 17 Mar 2002 05:43:03 GMT Xref: archiver1.google.com comp.lang.ada:21356 Date: 2002-03-17T05:43:03+00:00 List-Id: "Chad R. Meiners" wrote in message news:... > "Hyman Rosen" wrote in message > news:3C921A81.9060708@mail.com... > > The counter argument is that dangling pointers are a problem where they > > have been copied into other data structures, so nulling one particular > > variable which is holding the pointer isn't all that useful. Also, > > freeing memory tends to happen as part of the process of cleaning up a > > data structure which is itself about to disappear, so again nulling the > > pointer isn't going to accomplish much. > > > > This counter argument is weak at best since it is very poor design to allow > more than one pointer to a block of allocated memory without having the > ablility to invalidate them all when you deallocate that block. Therefore, > since proper program design avoids the dangling pointer problem, nulling the > pointer provides a useful safeguard against accessing deallocated memory. Dereferencing nil is just as fatal to program execution. The only advantage is that it is more easily debugged because the crash is immediate. Any code that keeps invalid pointers around, whether null or not, is poorly crafted. Good programmers don't much care about the state of a pointer variable after delallocation because the variable is either going to be reassigned immediately or is going out of scope.