I am new to Objective C and am looking at some code that releases memory back to the system using [MyData release], but get a crash as some of the memory has already been returned to the system.
The object MyData has the following structure:
MyData* (NSCFArray)MyFiles* FileParser* DataCollection*
The object DataCollection* causes the crash because of a double free. I want to be able to check that the DataCollection* object hasn't had it's memory released back to the system.
I just don't know how to do it in objective C.
I am looking to do something like this. I apologies for the psuedocode, but am still learning the syntax for objective C
The object MyData has the following structure:
MyData* (NSCFArray)MyFiles* FileParser* DataCollection*
The object DataCollection* causes the crash because of a double free. I want to be able to check that the DataCollection* object hasn't had it's memory released back to the system.
I just don't know how to do it in objective C.
I am looking to do something like this. I apologies for the psuedocode, but am still learning the syntax for objective C
Code:
// check if the sub-object has been released
if( ! MyData* MyFiles* FileParser* DataCollection* )
{
// allocate some memory to the sub-object.
// Just a quick fix while I track down where the problem is
MyData* MyFiles* FileParser* DataCollection* = new MyData* MyFiles* FileParser* DataCollection*;
}
// release the main objects memory back to the system
[MyData release]