[fpc-pascal] TIniFile crash/memory loss

José Mejuto joshyfun at gmail.com
Thu Mar 31 20:17:25 CEST 2011


Hello FPC-Pascal,

Thursday, March 31, 2011, 6:52:26 PM, you wrote:

B> This however means that the programmer has to protect TIniFile.Free
B> with a Try..Except block, which is also rather unusual.

It's unusual, but there is an error, or the class does not perform the
save in the free procedure and uses a "flush" (forced) or the class
must raise an exception as the expected job has not been performed.

procedure Example;
var
  INI: TIniFile;
  Earns: integer;
begin
  Earns:=5000;
  INI:=TIniFile.Create('bank-account');
  INI.CacheUpdates:=true;
  INI.WriteString('Money','earned',Earns);
  INI.Free;
  writeln('Great, this month $',Earns,' are in the pocket!');
end;

-- 
Best regards,
 José




More information about the fpc-pascal mailing list