[fpc-pascal] Question about System.Move()

Marco van de Voort fpc at pascalprogramming.org
Sat Jan 9 20:34:44 CET 2021


Op 2021-01-09 om 20:12 schreef Yuriy Sydorov via fpc-pascal:
>  So, if I move Arr[3] to Arr[1], I first have to finilize/free Arr[1].
>> After that move the bytes in Arr[3] are exactly the same as in Arr[1]
>> (by definition of how move works) AFAIU.
>> Is that a problem with refcounts, because they would be the same also
>> but the number of copies increased?
>
> System.Move just copies bytes in the memory. So all handling of 
> managed types must be done manually.
> So if Arr[1] contains a managed value you need to finalize/free it 
> before Move.
> After move Arr[1] and Arr[3] will contain the same value and if you 
> need to keep both you need to increase the refcount manually.

Or overwrite or finalize the old value with fillchar.




More information about the fpc-pascal mailing list