[fpc-pascal] fpc has trouble with array types

Sven Barth pascaldragon at googlemail.com
Tue Oct 18 11:16:29 CEST 2011


Am 18.10.2011 11:12, schrieb Sven Barth:
> type
> TByteArray = array of Byte;
>
> function XlatPrime(): TByteArray;
> begin
> XlatPrime := TByteArray.Create(
> $64, $73, $66, $64, $3b, $6b, $66, $6f,
> $41, $2c, $2e, $69, $79, $65, $77, $72,
> $6b, $6c, $64, $4a, $4b, $44, $48, $53,
> $55, $42, $73, $67, $76, $63, $61, $36,
> $39, $38, $33, $34, $6e, $63, $78, $76,
> $39, $38, $37, $33, $32, $35, $34, $6b,
> $3b, $66, $67, $38, $37
> );
> end;

Before I forget it: If you use this solution (not the const one) or you 
use "SetLength", you need to free the array using "SetLength(0)" or 
"YourArrayVariable := Nil", otherwise you'll have a memory leak. You 
must not do this if you use the const solution.

Regards,
Sven



More information about the fpc-pascal mailing list