+ Bugfix in setcapacity, sizes were wrong

This commit is contained in:
michael 1998-11-09 10:07:24 +00:00
parent c461a33f8a
commit 0d5d65e6bb

View File

@ -94,7 +94,7 @@ Procedure TStrings.ReadData(Reader: TReader);
begin begin
end; end;
Function GetQuotedString (Var P : Pchar) : String; Function GetQuotedString (Var P : Pchar) : AnsiString;
Var P1,L : Pchar; Var P1,L : Pchar;
@ -112,7 +112,7 @@ begin
P:=P+1; P:=P+1;
If P1-P>0 then If P1-P>0 then
begin begin
SetLength(Result,P1-P); SetLength(Result,(P1-P));
L:=Pointer(Result); L:=Pointer(Result);
Move (P^,L^,P1-P); Move (P^,L^,P1-P);
P:=P1+1; P:=P1+1;
@ -711,7 +711,8 @@ end;
Procedure TStringList.SetCapacity(NewCapacity: Integer); Procedure TStringList.SetCapacity(NewCapacity: Integer);
Var NewList,ToFree : Pointer; Var NewList : Pointer;
MSize : Longint;
begin begin
If (NewCapacity<0) then If (NewCapacity<0) then
@ -720,23 +721,21 @@ begin
begin begin
GetMem (NewList,NewCapacity*SizeOf(TStringItem)); GetMem (NewList,NewCapacity*SizeOf(TStringItem));
If NewList=Nil then If NewList=Nil then
//!! Find another one here !!
Error (SListCapacityError,NewCapacity); Error (SListCapacityError,NewCapacity);
If Assigned(FList) then If Assigned(FList) then
begin begin
System.Move (FList^,NewList^,FCapacity*Sizeof(Pointer)); MSize:=FCapacity*Sizeof(TStringItem);
FillWord (Pchar(NewList)[FCapacity],(NewCapacity-FCapacity)*WordRatio, 0); System.Move (FList^,NewList^,MSize);
FreeMem (Flist,FCapacity*SizeOf(Pointer)); FillWord (Pchar(NewList)[MSize],(NewCapacity-FCapacity)*WordRatio, 0);
FreeMem (Flist,MSize);
end; end;
Flist:=NewList; Flist:=NewList;
FCapacity:=NewCapacity; FCapacity:=NewCapacity;
end end
else if NewCapacity<FCapacity then else if NewCapacity<FCapacity then
begin begin
If NewCapacity<0 then NewList:=Flist+NewCapacity*SizeOf(TStringItem);
Error (SListCapacityError,NEwCapacity); FreeMem (NewList, (FCapacity-NewCapacity)*SizeOf(TStringItem));
ToFree:=Flist+NewCapacity*SizeOf(Pointer);
FreeMem (ToFree, (FCapacity-NewCapacity)*SizeOf(Pointer));
FCapacity:=NewCapacity; FCapacity:=NewCapacity;
end; end;
end; end;
@ -899,7 +898,10 @@ end;
{ {
$Log$ $Log$
Revision 1.5 1998-10-30 14:52:52 michael Revision 1.6 1998-11-09 10:07:24 michael
+ Bugfix in setcapacity, sizes were wrong
Revision 1.5 1998/10/30 14:52:52 michael
+ Added format in interface + Added format in interface
+ Some errors in parser fixed, it uses exceptions now + Some errors in parser fixed, it uses exceptions now
+ Strings now has no more syntax errors. + Strings now has no more syntax errors.