[fpc-devel] Bug in PWidechar and refcounting

Alexey Barkovoy clootie at ixbt.com
Wed Feb 16 13:19:17 CET 2005

----- Original Message ----- 
From: "DrDiettrich" <drdiettrich at compuserve.de>
To: "FPC developers' list" <fpc-devel at lists.freepascal.org>
Sent: Tuesday, February 15, 2005 4:11 AM
Subject: Re: [fpc-devel] Bug in PWidechar and refcounting

> Alexey Barkovoy wrote:
>> 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.
> In Delphi WideString is not reference counted at all. The layout of the
> string prefix is dictated by the Windows API (BSTR type), and AFAIK
> Windows also doesn't use reference counting with this type, or with
> OLEVariants containing wide strings.

In e-mail above I've not said anywhere about reference-counting, I've said 
WideString are managed by compiler. For example if you declare WideString local 
variable in procedure it will be automatically freed at the end of procedure in 
compiler generated "try ... finally" block. And if you declare PWideChar, 
allocate memory for it, when it's up to you to free this memory after you no 
longer need it. 

More information about the fpc-devel mailing list