On Wed, Jan 28, 2009 at 09:25:02PM +0000, Jeremy Henty wrote:
On Wed, Jan 28, 2009 at 05:48:20PM -0300, Jorge Arellano Cid wrote:
In the second part of the patch, Why not:
void Image::setUseMap (ImageMapsList *list, object::Object *key) { mapList = list; + if (mapKey && mapKey != key) + delete mapKey; mapKey = key; }
Because I'm ridiculously paranoid about data members pointing to free()-ed values for even a nanosecond. You decide whether Dillo needs to be similarly paranoid/ridiculous. :-)
Interesting. With multithreading, if mapKey was a shared resource, it could be a problem. In that case a mutex solves the problem, making the operation "atomic". AFAIS, with:
if (key != mapKey) { object::Object *oldKey = mapKey; mapKey = key; if (oldKey) delete oldKey; }
If oldKey was a shared resource, there's still the problem of being preempted in the middle of the destructor (delete oldKey). If another thread uses the object then, BUM! Again, a mutex solves the problem. The simpler version was committed. ;-) -- Cheers Jorge.- ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________