Delphi XE8 bug in TList, need workaround

I found that now the TList<T>.Insert method call TListHelper.InternalInsertX depends on the data size, in my case: procedure TListHelper.InternalInsertN(AIndex: Integer; const Value); var ElemSize: Integer; begin CheckInsertRange(AIndex); InternalGrowCheck(FCount + 1); ElemSize := ElSize; if AIndex <> FCount then Move(PByte(FItems^)[AIndex * ElemSize], PByte(FItems^)[(AIndex * ElemSize) + 1], (FCount – AIndex) * ElemSize); Move(Value, PByte(FItems^)[AIndex * ElemSize], … Read more

Delphi TList of records

The easiest way is to create your own descendant of TList. Here’s a quick sample console app to demonstrate: program Project1; {$APPTYPE CONSOLE} uses SysUtils, Classes; type PMyRec=^TMyRec; TMyRec=record Value: Integer; AByte: Byte; end; TMyRecList=class(TList) private function Get(Index: Integer): PMyRec; public destructor Destroy; override; function Add(Value: PMyRec): Integer; property Items[Index: Integer]: PMyRec read Get; default; … Read more