[fpc-pascal] dynamic array contents and system.move
David Emerson
dle3ab at angelbase.com
Sat May 1 22:13:57 CEST 2010
Jürgen Hestermann wrote:
> Although I would have expected that special procedures exist to insert
> and remove array elements so that there is no need to do such things
> manually ...
These must be written on a case-by-case basis, for each type of array element.
Perhaps I'll tackle this someday as my first contribution to the fpc codebase.
As for the rest, I have addressed these very issues in the last week...
> ... which also requires knowledge of the exact handling of dynamic
> arrays which is not fully documented so you are never sure.
See my test program, http://david9.freepgs.com/fpc/dynamic-arrays.pas
also: http://lists.freepascal.org/lists/fpc-pascal/2010-April/024840.html
You can figure out how all this stuff works relatively easily -- if it is so
important to you to be able to use system.move on dynamic array contents.
> For example, in the above example, a[10] still exists and
> points to the same data as a[9], correct? And how do I *insert* elements?
> I would need to extend the allocated memory but how to do that without
> distroying reference counters etc.?
http://lists.freepascal.org/lists/fpc-pascal/2010-April/024845.html
Of course you need to use setlength to extend allocated memory.
Cheers,
David
More information about the fpc-pascal
mailing list