procedure FreeListObjects( l : TStrings);
var i : integer;
BEGIN
FOR i := 0 TO l.Count -1 DO BEGIN
l.Objects[i].Free;
l.Objects[i] := NIL;
END;
end;
PROCEDURE StringListAdd;
VAR i : INTEGER; Code : LONGWORD;
BEGIN
l := Classes.TstringLIST.CREATE;
FOR i := 0 TO 4 DO BEGIN
Code := i ;
l.AddObject('', TObject(code));
END;
Code := LONGWORD(l.Objects[2]);
FreeListObjects(l);
l.Free;
END;
When I use l.OwnsObjects := TRUE
without FreeListObjects(l)
, an error occurs.
Who is to free this string list's objects?