[fpc-pascal] Assigning open array

Dmitry Boyarintsev skalogryz.lists at gmail.com
Tue Jul 31 21:54:32 CEST 2018


On Tue, Jul 31, 2018 at 11:39 AM Santiago A. <svaa at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180731/182b3186/attachment.html>


More information about the fpc-pascal mailing list