[fpc-pascal] Array clearing

J├╝rgen Hestermann juergen.hestermann at gmx.de
Sat Apr 1 16:25:33 CEST 2017


Am 2017-04-01 um 15:09 schrieb Ryan Joseph:
 > Because the array is being iterated and I need to know which values 
are set.
 > Basically I have a dynamic array I grow to a certain size and this 
process happens in a loop.
 > The options are to allocate/free the array every cycle or clear 
memory and allocate the array once.

If you just need to reuse the same array and only need to zero its elements
then of course fillchar would be the fastest approach (it saves the memory
reallocation step).

But this works only for standard array element types (like integer etc.).
Managed types have to be reset element by element.




More information about the fpc-pascal mailing list