On Tue, Jul 31, 2018 at 11:39 AM Santiago A. <s...@ciberpiula.net> wrote:

> I'm not very sure how open arrays are copied
>
In your example you don't have open arrays used - you have dynamic arrays.


> I looks like working fine.  MyArray.ArrayInt[0] is still 5. But I wonder
> whether it is really right or just luck. Open arrays are pointers, so,
> when tmpList gets out of scope then tmpList.arrayInt is freed.


The compiler is aware of managed (reference counted) type fields within a
dynamic array body.
Thus each ArrayInt in "aList" would have reference count increased.
Thus when tmpList is released ArrayInt stays, as its reference count
doesn't reach zero.

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

Reply via email to