GetDir() Problem: ALLOC xxxxxxxx
| Wed, 2005-11-16 12:14 | |
|
I'm also having a problem with the GetDir() function. I figured somebody here can find out why I'm having "Memory Leak" ALLOC xxxxxxx error when the function is issued.
Here's the code: Code: void CHTMLContainer::SetListData() Â Â { Â Â MDesCArray* itemArray = iList->Model()->ItemTextArray(); CDesCArray* itemList = static_cast<CDesCArray*>(itemArray); TUint a; TText tItem; // connect to the file server RFs fileSession; CDir* dirList; TBuf<30> fileName; TInt stat; _LIT(KDirName, "C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web"); _LIT(KFileSpec,"C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web\\*"); // Connect to the file server stat = fileSession.Connect(); // Get the file list, sorted by name (Leave if an error occurs) Â Â Â Â Â User::LeaveIfError( fileSession.GetDir(KFileSpec, KEntryAttMaskSupported, ESortByName, dirList));Â // [glow=red,2,300]<----- Memory leak error here.[/glow] // Close the connection with the file server fileSession.Close(); // Dynamically build list itemList->Delete(0); for (TInt a=0; a < dirList->Count(); a++) { fileName = (*dirList)[a].iName; itemList->AppendL(fileName); } delete dirList; iList->HandleItemAdditionL();Â } Emulator is Series 60 2nd Ed. SDK for Symbian OS, FP 2, Visual C++, WinXP. Thanks! |
|






Forum posts: 364
Where are your heap mark and checking MACROs placed?
Forum posts: 34
I just figured out the error after several (and I mean several) times of doing the old trial-and-error approach (believe me, if all else fail, you'll do the same).
OK the problem is here:
_LIT(KFileSpec,"C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web\\*");
It should be:
_LIT(KFileSpec,"C:\\Nokia\\MyTindahan\\web\\*.html");
I hope this helps some newbies like me out there. Chow!
Forum posts: 364
How does the path name determine if there is a memory leak or not?
Forum posts: 34
Anyway, the good thing is that my app is workig now.
Thanks.
Forum posts: 2006
There will be a leak when GetDir fails or itemList->AppendL leaves.
But for the remaining, I do not see what could be wrong.
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
Forum posts: 1233
GetDir failed -> Leave (because of User::LeaveIfError) -> program quits -> Alloc panic because stuff wasn't pushed on cleanupstack.
so the function itself didn't raise an alloc panic.
Forum posts: 34