[fpc-pascal] Question about System.Move()
Yuriy Sydorov
jura at cp-lab.com
Sat Jan 9 17:04:42 CET 2021
On 09.01.2021 17:28, Bart via fpc-pascal wrote:
> This may be a silly question.
> I use System.Move() to move items in a dynamic array, like
> Move(FData[0], FData[OldEnd], FStart*SizeOf(T));
> Where T is the type of the elements in the array.
> This seems to work as expected.
>
> I have some questions though:
>
> 1. Does this depend on the alignment of the array?
No. The source and destination pointers may point to unaligned data.
> 2. Is it OK if the elements of the array are (or contain) managed types?
You need to manually finalize/free elements which are overwritten before calling Move.
Also if you intend to use Move for duplication of elements of managed types, it is better to use for-loop to copy each
element separately to allow proper increments of references.
> 3. Are there caveats if T is a specialization of a generic type definition?
No caveats, but see #2.
Yuriy.
More information about the fpc-pascal
mailing list