[Lazarus] PDF generator, try 2

Martin Schreiber mse00000 at gmail.com
Thu Apr 7 15:02:58 CEST 2016


On Thursday 07 April 2016 13:49:06 Graeme Geldenhuys wrote:
> I was about to mention that. This was discussed before, and there was a
> reason (which eludes me now) why FillChar() will not be changed.

Because out parameters are finalised on caller side:

"
Procedure FillChar1(out x;count:SizeInt;Value:Byte);
begin
 fillchar(x,count,value);
end;

procedure tmainfo.exe(const sender: TObject);
type
 testty = record
  a: int32;
  b: string;
 end;
 ptestty = ^testty;
var
 po1: ptestty;
begin
 getmem(po1,sizeof(testty));
 pointer(po1^.b):= pointer(123467); //random value
// fillchar(po1^,sizeof(testty),0); //OK
 fillchar1(po1^,sizeof(testty),0); //crash because out paramters are 
                                   //finalized on caller side
 po1^.b:= 'abc';
 finalize(po1^);
 freemem(po1);
end;
"

Martin




More information about the Lazarus mailing list