Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2019-08

TFPSList clear but not shrink

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

Is it possible to remove or clear items from TFPSList without actually shrinking the memory (i.e. setting capacity to 0)? Looking the source below I see every time I clear the list it the capacity is set to 0 also. This is fine most of the time unless you want to reuse the list without reallocating memory.

If it’s not possible can I make a patch to include this option?

procedure TFPSList.Clear;
begin
  if Assigned(FList) then
  begin
    SetCount(0);
    SetCapacity(0);
  end;
end;

Regards,
Ryan Joseph