#9 Ошибка TList.Assign

closed-fixed
nobody
None
5
2007-10-18
2007-10-11
mdw
No

Ошибка TList.Assign. Она есть и в основной ветке KOL, я Владимиру уже написал.
строчка
Move( SrcList.FItems[ 0 ], FItems[ 0 ], Sizeof( Pointer ) * fCount );
должна быть:
Move( SrcList.FItems[ 0 ], FItems[ 0 ], Sizeof( Pointer ) * SrcList.fCount );

Вот полный исправленный код метода:
procedure TList.Assign(SrcList: PList);
{$IFDEF TLIST_FAST}
var i, CountCurrent: Integer;
SrcBlock, DstBlock: Pointer;
{$ENDIF}
begin
Clear;
if SrcList.fCount > 0 then
begin
{$IFDEF TLIST_FAST}
if SrcList.fUseBlocks and Assigned( SrcList.fBlockList ) then
begin
fBlockList := NewList;
fBlockList.Assign( SrcList.fBlockList );
for i := 0 to fBlockList.Count div 2 - 1 do
begin
SrcBlock := SrcList.fBlockList.fItems[ i*2 ];
CountCurrent := Integer( fBlockList.fItems[ i*2+1 ] );
GetMem( DstBlock, 256 * Sizeof( Pointer ) );
fBlockList.fItems[ i*2 ] := DstBlock;
move( SrcBlock^, DstBlock^, CountCurrent );
end;
end
else
{$ENDIF}
begin
Capacity := SrcList.fCount;
Move( SrcList.FItems[ 0 ], FItems[ 0 ], Sizeof( Pointer ) * SrcList.fCount );
end;
end;
fCount := SrcList.fCount;
end;

Discussion

  • jura

    jura - 2007-10-18
    • status: open --> closed-fixed
     
  • jura

    jura - 2007-10-18

    Logged In: YES
    user_id=1226674
    Originator: NO

    Исправил. Спасибо.

     

Log in to post a comment.