Topic: Should 'delete' set its operand to NULL?
Author: Gordon Tyler <gordo@nynexst.com>
Date: Thu, 16 Dec 93 13:54:03 PST Raw View
There's a thread on comp.lang.c++ about setting 'this' to NULL.
The main need is for program cleanup, so you can check your
global pointers and delete anybody that hasn't been deleted.
I remember spending one afternoon going through my entire
application and explicitly setting pointers to NULL after
I deleted them, so that my cleanup could skip any pointers
that were already NULL.
I was surprised that the pointers were not already set to
NULL- after all, they're not valid anymore! Who's to say
that the freed memory is not immediately used?
Does having the delete operator set its operand to NULL
create any problems? Why isn't it in the standard? There
must be a reason; I'm sure I've overlooked something...
--Gordie.
--------------------------------------------------------
Gordon Tyler NYNEX Science & Technology
gordo@nynexst.com Wireless Lab - Room 2E-4
voice: (914) 644-2053 500 Westchester Avenue
fax: (914) 644-2239 White Plains, NY 10604
--------------------------------------------------------