[Lazarus] Passing an array to a function
Andrew Brunner
andrew.t.brunner at gmail.com
Mon Jan 19 15:42:29 CET 2009
Hi Dave,
My first comment would be you must declare the input as a variable.
Next, I probably would type the Array out as well before using it.
Type TByteBuffer=Array of Byte;
function FieldValueAsString(var fsbuffer:TByteBuffer; fitype,fisize:
integer): string;
Byte arrays should not generate an error. There may be a memory leak
for instances where you pass them in as constant values. Because the
Memory manager would need to free that memory as it is a dynamic
array.
-Andy
On Mon, Jan 19, 2009 at 8:20 AM, Dave Coventry <dgcoventry at gmail.com> 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