www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/16/12:57:56

To: djgpp AT delorie DOT com
Subject: delete NULL?
Message-ID: <19970216.124451.7287.0.fwec@juno.com>
From: fwec AT juno DOT com (Mark T Logan)
Date: Sun, 16 Feb 1997 12:38:42 EST

I just finished writing a C++ implementation of a circular linked list.

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
as
possible, and as such only one node will ever have a pointer in it
pointing
to NULL.  This node is the dummy node at the beginning of the list, and I
end up calling delete on it in one of my destructors.  

Do I need to avoid this?  Will this become some horrific bug much later
in
my project?

TIA

-Fwec

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019