<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6001.18099" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>A possible Solution to the potential error in
astrings might be to use interlockedexchange (for pointers)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Attempt:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Procedure fpc_AnsiStr_Assign (Var DestS :
Pointer;S2 : Pointer);[Public,Alias:'FPC_ANSISTR_ASSIGN'];
compilerproc;<BR>{<BR> Assigns S2 to S1 (S1:=S2), taking in account
reference counts.<BR>}</FONT><FONT face=Arial size=2><BR>begin<BR> if
DestS=S2 then<BR> exit;<BR> If S2<>nil
then<BR> If PAnsiRec(S2-FirstOff)^.Ref>0
then<BR>
inclocked(PAnsiRec(S2-FirstOff)^.ref);<BR> { Decrease the reference count
on the old S1 }</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>// Changed part</FONT></DIV>
<DIV><FONT face=Arial size=2>
S2:=InterLockedExchangePointer(DestS,S2); <BR> fpc_ansistr_decr_ref
(S2);</FONT><FONT face=Arial size=2></DIV>
<DIV><BR> { And finally, have DestS pointing to S2 (or its copy) }<BR>//
Removed DestS:=S2;<BR>end;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>That would give us a "Nil" the second time, which
would be ignored by decr_ref then.</FONT></DIV></BODY></HTML>