2007. január 21., vasárnap

Freeing a TList


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;

Nincsenek megjegyzések:

Megjegyzés küldése