🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.oop.macapp3
1 messages
1 total messages Started by Germany - C Brinkschulte Berlin,... Tue, 15 Dec 1992 17:19
Bug In TDynamicArray (MA3.0.1)
#144
Author: Germany - C Brinkschulte Berlin,...
Date: Tue, 15 Dec 1992 17:19
42 lines
1837 bytes
Hi, MacAppers,
 
There is a Bug in MacApp 3.0.1 in the class "TDynamicArray".
 
The problem arises when a TDynamicArray is cloned while an Iterator which was
used for the TDynamicArray is stil in scope. TDynamicArray has a field named
fIteratorPtr, which contains a linked list of Iterators currently in use for
the TDynamicArray. When a TDynamicArray gets cloned, both (the old and the
cloned Array's) fIteratorPtrs point to the same Iterator. If the CArrayIterator
is destructed, the fIteratorPtr of the cloned TDynamicArray points to an
invalid Memory-Address.
 
The solution is to override TObject::Clone in TDynamicArray and set the
fIteratorPtr-field of the cloned Array
to NULL.
 
TObject* TDynamicArray::Clone () // override
{
    TDynamicArray* clonedArray = (TDynamicArray*) inherited:Clone ();
    clonedArray->fIteratorPtr = NULL;
    return clonedArray;
}
 
A Workaround is to manually set the fIteratorPtr of the CDynamicArray to NULL
after cloning a TDynamicArray.
 
TDynamicArray* aDynamicArray = new TDynamicArray;
aDynamicArray->IDynamicArray (0, sizeof (myStruct));
 
[...]
 
TDynamicArray* clonedArray = aDynamicArray->Clone ();
clonedArray->fIteratorPtr = NULL;
 
 
I am not part of MacAppTech$ anymore, because it has flooded my In-Box too
much, so please send a copy of any replys directly to me (thanks).
 
 
Carsten Brinkschulte
GER.XSE0039
 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads