[fpc-devel] Bug in PWidechar and refcounting

Joost van der Sluis joost at cnoc.nl
Sun Feb 13 11:07:34 CET 2005


> if when someone does pcharvar := ansistringvar or pwidecharvar :=
> widestringvar we increased the refcount every program that used that
> construct would leak memory.

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

Joost






More information about the fpc-devel mailing list