FROM : Uli Kusterer
DATE : Wed May 21 22:33:49 2008
Am 21.05.2008 um 18:34 schrieb Gérard Iglesias:
> In fact in its original case, there would be a crash, because
> cityArray would point to a trashed pointer... I don't understand why
> it is not crashing.
Well, it's not a trashed pointer. The memory has been alloced (and
self is set already), so all that would happen is that everything is
probably initialized to zero. If NSObject doesn't do much
initialization work in -init, you might get away with this bug without
crashing. But you wouldn't want to rely on that...
Oh, by the way, let me plug my memory management tutorials again,
they're mainly for C, but the general procedure stays valid for
Objective C:
What is Memory: http://www.masters-of-the-void.com/book5.htm
And here is one that talks a bit about what happens when you use un-
initialized memory:
Lists of Stuff: http://www.masters-of-the-void.com/book7.htm
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
DATE : Wed May 21 22:33:49 2008
Am 21.05.2008 um 18:34 schrieb Gérard Iglesias:
> In fact in its original case, there would be a crash, because
> cityArray would point to a trashed pointer... I don't understand why
> it is not crashing.
Well, it's not a trashed pointer. The memory has been alloced (and
self is set already), so all that would happen is that everything is
probably initialized to zero. If NSObject doesn't do much
initialization work in -init, you might get away with this bug without
crashing. But you wouldn't want to rely on that...
Oh, by the way, let me plug my memory management tutorials again,
they're mainly for C, but the general procedure stays valid for
Objective C:
What is Memory: http://www.masters-of-the-void.com/book5.htm
And here is one that talks a bit about what happens when you use un-
initialized memory:
Lists of Stuff: http://www.masters-of-the-void.com/book7.htm
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de






Cocoa mail archive

