On Thu, 13 Apr 2017 19:15:13 +0700
Ryan Joseph <r...@thealchemistguild.com> wrote:

> > On Apr 13, 2017, at 7:08 PM, Mattias Gaertner <nc-gaert...@netcologne.de> 
> > wrote:
> >   
> >> as I understood from 
> >> (http://wiki.freepascal.org/Dynamic_array<http://wiki.freepascal.org/Dynamic_array>),
> >>  SetLength will create a copy of the array and free the memory of the 
> >> shorter array. In this case, a lot of memory operations and copy 
> >> operations are performed thus degrading the performances of the code.  
> > 
> > Correct.  
> 
> Why is it copying the array and freeing instead of resizing the existing 
> block (realloc)? That sounds crazy but I don’t know how memory managers work.

It does not free the elements.
It frees the array.

Mattias
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to