X-Originating-IP: [208.160.246.197] From: "Nimrod Abing" To: djgpp AT delorie DOT com Cc: egon AT chance DOT cz Subject: Re: strdup() with delete[] Date: Wed, 13 Sep 2000 16:02:34 PHT Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 13 Sep 2000 08:02:35.0260 (UTC) FILETIME=[F9DB4BC0:01C01D58] Reply-To: djgpp AT delorie DOT com >From: Egon Eckert >Reply-To: djgpp AT delorie DOT com >To: djgpp AT delorie DOT com >Subject: Re: strdup() with delete[] >Date: Tue, 12 Sep 2000 11:12:52 +0200 > > > delete [] obj_ptr is not obsolete. It is _the_proper_ way to deallocate > > an array of objects. What is obsolete is delete [nn] obj_ptr, where > > NN would be the number of objects that were allocated for the array. > >So, is the delete [] form a hint for the compiler "use vector delete, there >may be more objects", and the 'simple' delete (without []) is faster >(because it doesn't need to find out how many objects there are)? Sort of. If the object array is released using delete [], this would tell the compiler to generate code that will: 1) call the destructor for this class for _every_ object in the array; 2) release the memory that was allocated for _every_ object in the array. >This is the only reason I would accept the existance of these 2 forms. :) If you need more info on this, I suggest reading a book on C++. The one by Bjarne Stroustrup (the creator of C++) is a good one. ---------------- _nimrod_a_abing_ +----------------------------------------------------+ |Homepage: http://www.geocities.com/n_abing/index.htm| +----------------------------------------------------+ _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com.