[fpc-devel] Bug in PWidechar and refcounting
Alexey Barkovoy
clootie at ixbt.com
Sun Feb 13 11:21:00 CET 2005
> Normally I would aggree with you, but as far as I can see, PWideChar is
> also an automated type. (If not then large parts of the variant-code in
> the RTL has to be rewritten, and probably alsoe the wstrings.inc file)
>
>>From wstrings.inc:
>
> WideString is defined as a 'silent' pwidechar :
> a pwidechar that points to :
>
> @-8 : SizeInt for reference count;
> @-4 : SizeInt for size;
> @ : String + Terminating #0;
> Pwidechar(Widestring) is a valid typecast.
> So WS[i] is converted to the address @WS+i-1.
>
> So there is a bug somewhere. But if they should not be refcounted, that's
> ok. But then I have some fixs for the variant-code
Above is just an internal description of WideString layout in memory, so this
layout allows easy type conversion of WideString to PWideChar. Note: PWideChar,
PAnsiChar, PChar are just pointers and not garbage collected by compiler. But
AnsiString and WideString are compiler managed types. So, as Peter mentioned,
behaviour you are seeing is by design.
More information about the fpc-devel
mailing list