Dennis wrote on Fri, 11 Dec 2015:

I just tested, SetLength a string  does not zero its elements (the chars).

However, SetLength a dynamic array seems to zero its elements.

Dynamic arrays are indeed zeroed when changing the length, while strings are not. For dynamic arrays, it is necessary anyway in case it has reference counted elements. Maybe for consistency, it's always done.

Additionally, changing the length of the string without afterwards overwriting the data between the previous and new last character seems something that would happen very seldom (why did you increase the length if you didn't need to write all characters -- any operation with the string, such as writing or concatenating it, will use those characters anyway because the length indicates they're part of the string).

The above are mostly guesses though.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to