[mythtv] delete vs delete[] in dvbrecorder destructor

aczmail at cox.net aczmail at cox.net
Tue Feb 22 15:03:41 UTC 2005


John Pullan wrote:

>On Tue, 2005-02-22 at 20:22 +0800, Tj wrote:
>>John Pullan wrote:
>>>These should be delete[]'s 
>>Does it really make a difference?
It does matter.
delete deletes an element
delete[] deletes an array of elements.

>>I did a backtrace and mythbackend appears to crash at dvbrecorder:341 
>>and a corrupted stack error. Is the corrupted stack caused by delete or 
>>is it because of something else (e.g. gcc optimisations)?
It's unlikely that using delete instead of delete[] would lead to a 
corrupted stack.  Normally, this would result in simply a memory leak.  
Worse case, it could lead to heap corruption depending on the 
implementation of the memory manager.

>>Also changed 'Iterator es' to 'const_iterator es' in the hopes it may 
>>stop mythbackend from crashing my machine occassionally after finishing 
>>a recording (and also a little bit faster).
If changing Iterator es to const_iterator es doesn't cause the compiler 
to fail, barring operator overloading where a different routine is 
called to process whatever es points to, it will not stop mythbackend 
from crashing.  Any kind of performance improvements related to a simple 
change like this will not be noticeable to an end-user.

>I'd vote for commiting this (as if my vote counts :p )
I'd second that.

>------------------------------------------------------------------------
>_______________________________________________
>mythtv-dev mailing list
>mythtv-dev at mythtv.org
>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
>  
>




More information about the mythtv-dev mailing list