Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is 'delete [] NULL ;' safe ?

Reply
Thread Tools

Is 'delete [] NULL ;' safe ?

 
 
qazmlp
Guest
Posts: n/a
 
      07-29-2003
Say, ptr=0 / ptr=NULL.

delete ptr; //is safe

// Is
delete [ ] ptr; // also safe ?
 
Reply With Quote
 
 
 
 
Jakob Bieling
Guest
Posts: n/a
 
      07-29-2003
"qazmlp" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Say, ptr=0 / ptr=NULL.
>
> delete ptr; //is safe
>
> // Is
> delete [ ] ptr; // also safe ?


Yes.
--
jb

(replace y with x if you want to reply by e-mail)


 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      07-29-2003
On 29 Jul 2003 09:19:43 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (qazmlp) wrote:

>Say, ptr=0 / ptr=NULL.
>
>delete ptr; //is safe
>
>// Is
>delete [ ] ptr; // also safe ?


delete or delete[] of 0 is safe.

NULL may or may not be safe depending on the definition; if it is
the standard NULL from e.g. [cstddef] then yes, that's also safe.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.ChDir() not thread-safe; was : Is tempfile.mkdtemp() thread-safe? Gabriel Rossetti Python 0 08-29-2008 08:30 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
Safe Mode (?) - It is meant to be normal mode but looks like safe mode English Patient Computer Support 3 10-03-2004 11:10 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 12:07 PM
Re: Those cute little "WORK-SAFE" / "NOT WORK-SAFE" tags that people put in the Subject headers of their posts... Soapy Digital Photography 1 08-16-2004 06:24 AM



Advertisments