[fpc-pascal] Array clearing

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


Am 2017-04-01 um 19:42 schrieb wkitty42 at windstream.net:
 > consider this: when using a string var and writing to a binary file...
 > you reuse the string var for each value written...
 > if you don't clear the string var between fills then the binary will
 > contain "garbage" in the unused positions of the string var...
 > you can see this "garbage" when you view the binary file in hex mode...
 > the "garbage" being older longer string data than the current string 
data in the var...
 > this var may be a global throwaway string var...

This can only happen for older string types where the actual length
can differ from the reserved memory (maximum string length).
With managed strings, this should never be possible as it would write
only the bytes of the current length.

I also don't see how this applies to an array of integers.




More information about the fpc-pascal mailing list