mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-07 23:18:35 +02:00
* better fix for TFPGSList memory leak: avoid changing allocation behavior (adds one temp entry used for various operations), and clean up in the destructor
git-svn-id: trunk@8433 -
This commit is contained in:
parent
68245771cc
commit
ddc0ac9a43
@ -215,6 +215,9 @@ end;
|
|||||||
destructor TFPSList.Destroy;
|
destructor TFPSList.Destroy;
|
||||||
begin
|
begin
|
||||||
Clear;
|
Clear;
|
||||||
|
// Clear() does not clear the whole list; there is always a single temp entry
|
||||||
|
// at the end which is never freed. Take care of that one here.
|
||||||
|
FreeMem(FList);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -261,8 +264,8 @@ begin
|
|||||||
Error(SListCapacityError, NewCapacity);
|
Error(SListCapacityError, NewCapacity);
|
||||||
if NewCapacity = FCapacity then
|
if NewCapacity = FCapacity then
|
||||||
exit;
|
exit;
|
||||||
ReallocMem(FList, NewCapacity * FItemSize);
|
ReallocMem(FList, (NewCapacity+1) * FItemSize);
|
||||||
FillChar(InternalItems[FCapacity]^, (NewCapacity-FCapacity) * FItemSize, #0);
|
FillChar(InternalItems[FCapacity]^, (NewCapacity+1-FCapacity) * FItemSize, #0);
|
||||||
FCapacity := NewCapacity;
|
FCapacity := NewCapacity;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -315,7 +318,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
SetCount(0);
|
SetCount(0);
|
||||||
SetCapacity(0);
|
SetCapacity(0);
|
||||||
FList := nil;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user