Reputation: 207
I'm using Delphi 1 16-bit to learn Pascal (don't laugh, it works fine, plus I can't afford a more recent version). I'm using a TList to hold object references for a simple address book. Each object is added to the TList like so:
DataList.Add(TAddrBookData.Create('Bob', '1 Mill St'));
Do I need to free the TAddrBookData objects myself? Or are they freed when TList.Free is run?
Upvotes: 12
Views: 754
Reputation: 84550
You need to free them yourself. Later versions come with a TObjectList, which is like a TList except it will only accept objects and it has the option to take ownership and free them for you automatically when the list is freed. But I don't believe TObjectList existed in Delphi 1, so you'll have to take care of it manually.
Upvotes: 12