Hi, > > My difficulties relate to whether or not I'd be > creating memory leaks, and > understanding what needs to be freed by whom. The > TStringList object created > in the last paragraph--when is it freed? Once the > Memo (in Form1) has been > filled, the TStringList is no longer needed. But you > can't just free it at > the end of ShowAllTitles (Form1's Memo needs the > reference). And how about > all those TBook instances referenced in TLibrary's > fBookList? When are they > freed?
The ShowAllTitles methode should has a TStrings parameter. It's responsibility is simply filling the passed TStrings instance with the all available titles. And the caller will be in charge to instantiate and destroying the TStrings will be on the caller. This way you can pass the memo's lines property (which is a TStrings) to ShowAllTitles. Btw, for a huge number of items you may want to use BeginUpdate and EndUpdate of TStrings to avoid flickers. Cheers, Luthfi Hakim __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

