[Qt-interest] Huge memory consumption
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Wed Jul 7 16:55:19 CEST 2010
jjDaNiMoTh wrote on Wednesday, July 07, 2010 3:33 PM:
>> ...
>> if (theData != 0) {
>> delete theData;
>> }
> http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.8
> void destroy (TheData *p) {
> delete p;
> }
Yeah, whatever... that was just me being paranoid ;) I even thought about posting an example code like
void destroy (TheData **theData) {
delete *theData;
*theData = 0;
}
Possible syntax errors left in as an exercise for the reader ;) Or would that work, using a reference?
void destroy (TheData &*theData) {
delete theData;
theData = 0;
}
Hmmm, been a while since I coded stuff like that. Ain't C/C++ such fun... ;)
So when the caller accidentally accesses the same pointer again you would get a "clean and instant" null pointer access. But since I always use the same address space across DLL boundaries anyway, I don't need to write such dodgy "helper destroy" functions anyway (because then you still need to remember which object was allocated where, and pick the proper "destroy" function - if I want to deallocate memory, I just want to be able to call delete, never mind "where" it was allocated in the first place. :)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list