[fpc-devel] Customer Done procedure for dynamic arrays

Marc Weustink marc at dommelstein.net
Fri May 28 17:56:42 CEST 2010

Andrew Brunner wrote:
> I use dynamic arrays for data structures and sometimes types.
> Under linux I have had no problems with transversing the list of data
> and calling "Done" on all types then calling finalize on the list
> itself.
> Under windows I just executed the same code that worked under linux
> but crashed under windows.
> TInt64Array=Array of Int64;
> procedure Done(var List:TInt64Array);
> begin
>   Finalize(List);
> end;
> procedure Empty(var List:TInt64Array);
> begin
>   SetLength(List,0);
> end;
> In the above case the two procedures worked under linux.  Under
> Windows Done crashes.  Is this a bug that needs to be reported or is
> the memory manager performing different under Linux than under
> Windows.
> This is a basic example.  Some of my data structures involve strings
> and sub-arrays to other data structures or pointers thereto.  To fix
> the problem I just use Empty instead of Done but I am looking to find
> out why can use Finalize on Linux but not on Windows?

Why do you want to finalize it ? This is automatically done by fpc when 
you set the length to 0 (or when the array goes out of scope)


More information about the fpc-devel mailing list