[fpc-pascal] High() and Low() for empty dynamic arrays

Michael Fuchs freepascal at ypa-software.de
Sun Feb 9 13:08:16 CET 2014


Am 09.02.2014 13:05, schrieb Fred van Stappen:
> if length(MyArray) > 0 then
>   for x := 0 to high(MyArray) do
>     MyArray[x].Free;
> 
> But, if i use :
> 
>  setlength(MyArray, 0) ;
> 
> would it do the same job ?

No. Your array contains only references to the objects. The references
where deleted, but the objects remain in memory without any destructor call.

g
Michael



More information about the fpc-pascal mailing list