My use case: CudaText's plugin Spell Checker adds lots of marks (200k for example if DE lang is chosen and English file is active). Now user calls "Clear marks" plugin cmd which internally calls DeleteRange with the range 0..Count-1 (it calculates the range basing of current marks, it is not always the whole range!!).
DeleteRange DONT REALLOC MEM when some condition is not met.
procedure TFPSList.DeleteRange(IndexFrom, IndexTo : Integer);
...
System.Move(InternalItems[IndexTo+1]^, InternalItems[IndexFrom]^, (OldCnt - IndexTo-1) * FItemSize);
// Shrink the list if appropriate
if (FCapacity > 256) and (FCount < FCapacity shr 2) then
begin
FCapacity := FCapacity shr 1;
ReallocMem(FList, (FCapacity+1) * FItemSize);
end;
...
end;
I suggest: in DeleteRange, check, if range is from 0 to Count-1. if so, call
This will realloc the mem. Command 'Clear marks' frees mem.