[Lazarus] Passing an array to a function

Martin Friebe lazarus at mfriebe.de
Mon Jan 19 16:12:11 CET 2009


Not sure, but I would try something like

FS.ReadBuffer(fsbuffer[0],recordsize);

The function is declared as 
  ReadBuffer(var Buffer; ....


So in reality a pointer to the variable is passed to the function. Your dyn-array is already a pointer. You are passing in a pointer to the internal pointer, and not to the bytes you allocated.

Martin



Dave Coventry wrote:
> I have a function that I'm trying to pass an array to.
>
> function FieldValueAsString(fsbuffer: array of Byte; fitype,fisize:
> integer): string;
>
> Calling the function:
>
> setlength(fsbuffer,recordsize);
> FS:=TFileStream.Create(fname, fmshareDenyWrite);
> FS.Seek(seekpos,soFromBeginning);
> FS.ReadBuffer(fsbuffer,recordsize);
> dfstring:= FieldValueAsString(fsbuffer,fitype,fisize);
>
> Generates the error "Project raised exception class SIGSEGV"
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>   



More information about the Lazarus mailing list