Mail Archives: djgpp/1997/02/16/15:00:54
Mark T Logan (fwec AT juno DOT com) wrote:
: My question is this. If I use delete on a pointer which is equal to
: NULL,
: for example...
: char *ptr = NULL;
: delete ptr;
: Will anything bad happen? I have written the linked list to be as simple
I'm not sure whether or not delete minds being passed NULL, but you could
replace the 'delete ptr' line with 'if (ptr) delete ptr;' - then it won't be
executed if ptr is NULL. Since this code isn't called often, the slightly
inefficiency in adding this extra condition if delete already performs such
a check will not be noticeable in your program.
--
George Foot <gfoot AT mc31 DOT merton DOT ox DOT ac DOT uk>
Merton College, Oxford.
- Raw text -