[fpc-devel] move(xx, ansistring[1] versus ansistring, len)

Sergei Gorelkin sergei_gorelkin at mail.ru
Tue May 13 05:05:53 CEST 2008

Martin Friebe wrote:

> ...
> Many of the occurrances look like
>    SetLength(s, count);
>    move(str^, s[1], count);
> where "s" is a local variable, not used before. So currently it would be 
> safe to skip uniquestring.
> But I consider this as a trap, because future changes may act on "s" 
> before, without the author being aware of the exact behaviour of move.

After call to SetLength() the string is guaranteed to be unique, hence 
there is no trap here.
You may also wish to substitute both calls with a single

   SetString(s, str^, count);

which is shorter and does not treat the string in potentially unsafe way.

Best regards,

More information about the fpc-devel mailing list