[fpc-pascal] Stack corruption setting UnicodeString Char

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Wed Oct 19 10:14:04 CEST 2011


2011/10/19 Tomas Hajny <XHajT03 at hajny.biz>:
> Sorry for a silly question, but why the difference between the two
> implementations (i.e. why not addressing the WideStr element directly
> without the typecast)?

Actually it should be a pointer operation in the ansistring version
too, because setting chars in a string calls UniqueString, which is
undesirable and inneficient.

> Moreover, even if using the PWideChar, I believe
> that the correct version would be without the '@' (i.e.:
> PWideChar(widestr)[len] := #0), wouldn't it?

Good idea! I think you found the problem.

-- 
Felipe Monteiro de Carvalho



More information about the fpc-pascal mailing list