[fpc-devel] Widestring and reference counting
Graeme Geldenhuys
graemeg.lists at gmail.com
Sat Nov 24 13:22:58 CET 2007
Hi,
I was reading a article on Delphi's WideString support. It mentions
that under Delphi, WideStrings are not reference counted, but under
Kylix they are.
http://tobias.feedian.com/2007/05/24/whats-wrong-with-delphis-widestring/
Using the following example program and compiling with 'fpc -al
wstest.pas' under Linux to see the assembler file (not that I can
remember anything of how assembler works). Looking at the asm code I
see a call to FPC_WIDESTR_INCR_REF which I assume confirms that
WideStrings under Linux using FPC is also reference counted.
Is the same true under Windows? Does that mean FPC doesn't have the
WideString issues Delphi has?
-------------------------------------
program wstest;
uses
Classes, SysUtils;
procedure Log(AParam: WideString);
var
lparam: WideString;
begin
lParam := AParam;
end;
begin
Log('This is a test');
end.
----------------------
<....snip....>
# [12] lParam := AParam;
leal -4(%ebp),%eax
call FPC_WIDESTR_INCR_REF
leal -8(%ebp),%eax
call FPC_WIDESTR_DECR_REF
movl -4(%ebp),%eax
movl %eax,-8(%ebp)
<...snip...>
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list