Mirror

Freeing a TList (Views: 6)


Problem/Question/Abstract:

Freeing a TList

Answer:

If there is any possibility of the freeing code being called re-entrantly, make sure to store a nil in the list before freeing the object; your code should look like this:


// original from Ray Lischner
for i := 0 to List.Count - 1 do
begin
  TempNode := List[i];
  List[i] := nil;
  TempNode.Free;
end;
List.Free;

<< Back to main page