TStringList.SetCapacity related lazarus / 64-FPC development ---------------------------------------------------------------------- lagprogramming · 2015-10-27 19:19 TStringList.SetCapacity can be found inside stringl.inc. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Procedure TStringList.SetCapacity(NewCapacity: Integer);Var NewList : Pointer;  MSize : Longint;begin  If (NewCapacity<0) then     Error (SListCapacityError,NewCapacity);  If NewCapacity>FCapacity then    begin    GetMem (NewList,NewCapacity*SizeOf(TStringItem));    If NewList=Nil then      Error (SListCapacityError,NewCapacity);    If Assigned(FList) then      begin      MSize:=FCapacity*Sizeof(TStringItem);      System.Move (FList^,NewList^,MSize);      FillWord (Pchar(NewList)[MSize],(NewCapacity-FCapacity)*WordRatio, 0);//<--------------      FreeMem (Flist,MSize);      end;...     I'd like the rationale to be checked. I think somebody tried to optimize the line Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FillByte(Pchar(NewList)[MSize],(NewCapacity- FCapacity)*SizeOf(TStringItem),0);with Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i FillWord (Pchar(NewList)[MSize],(NewCapacity-FCapacity)*WordRatio, 0);    The above lines don't fill with zeros the same size, the existing line fills only half the space difference. This is because classesh.inc has {$H+}, which makes SizeOf(TStringItem)=2*SizeOf(Pointer), while WordRatio = SizeOf(Pointer) Div SizeOf(Word).    I don't think it's very important but, am I wrong? ---------------------------------------------------------------------- engkin · 2015-10-28 04:03 Quote from: lagprogramming on October 27, 2015, 08:19:25 pm   I'd like the rationale to be checked. [...]    The above lines don't fill with zeros the same size, the existing line fills only half the space difference. [...] am I wrong? No, you are right! Edit: Maybe FillDWord was meant to be used instead of FillWord? ---------------------------------------------------------------------- Bart · 2015-10-28 11:20 File a bugreport, otherwise it probably won't get noticed. Bart ---------------------------------------------------------------------- lagprogramming · 2015-10-28 15:40 I know 16-bit is a valid target. For knowledge, will FillDWord work fine for users that want to target msdos i8086? I agree with Bart, somebody might fill a Mantis bug entry. ---------------------------------------------------------------------- engkin · 2015-10-28 17:05 Quote from: lagprogramming on October 28, 2015, 04:40:42 pmwill FillDWord work fine for users that want to target msdos i8086? It is in generic.inc file, which according to system.inc comment: Quote{ Include generic pascal only routines which are not defined in the processor   specific include file } {$I generic.inc}        So it should work ok. ---------------------------------------------------------------------- christian1987 · 2015-10-29 08:37 I was trying to get this to crash... couldn't. Here is why: 1132      Pointer(Flist^[Index].Fstring):=Nil;  // Needed to initialize. TStringList.InsertItem sets it to nil AGAIN. So I think maybe FillWord code is unneccessary? Not sure.