From cd03a2893b874bd3df7c15a90d8f79163a64beb6 Mon Sep 17 00:00:00 2001 From: yury Date: Fri, 28 Dec 2007 00:02:35 +0000 Subject: [PATCH] * Explicitly increment and decrement ref count to keep copy of destination string in fpc_AnsiStr_Concat_multi and fpc_WideStr_Concat_multi. It prevents note "Local variable "destcopy" is assigned but never used". git-svn-id: trunk@9554 - --- rtl/inc/astrings.inc | 7 +++++-- rtl/inc/wustrings.inc | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rtl/inc/astrings.inc b/rtl/inc/astrings.inc index 6b79b1fc00..1fa9823137 100644 --- a/rtl/inc/astrings.inc +++ b/rtl/inc/astrings.inc @@ -250,13 +250,14 @@ Var p,pc : pointer; Size,NewLen, OldDestLen : SizeInt; - destcopy : ansistring; + destcopy : pointer; begin if high(sarr)=0 then begin DestS:=''; exit; end; + destcopy:=nil; lowstart:=low(sarr); if Pointer(DestS)=Pointer(sarr[lowstart]) then inc(lowstart); @@ -269,7 +270,8 @@ begin { if DestS is used somewhere in the middle of the expression, we need to make sure the original string still exists after we empty/modify DestS } - destcopy:=dests; + destcopy:=pointer(dests); + fpc_AnsiStr_Incr_Ref(destcopy); lowstart:=low(sarr); break; end; @@ -298,6 +300,7 @@ begin inc(pc,size); end; end; + fpc_AnsiStr_Decr_Ref(destcopy); end; diff --git a/rtl/inc/wustrings.inc b/rtl/inc/wustrings.inc index cd297a456c..e4ba5e6280 100644 --- a/rtl/inc/wustrings.inc +++ b/rtl/inc/wustrings.inc @@ -578,13 +578,14 @@ Var p,pc : pointer; Size,NewLen, OldDestLen : SizeInt; - destcopy : widestring; + destcopy : pointer; begin if high(sarr)=0 then begin DestS:=''; exit; end; + destcopy:=nil; lowstart:=low(sarr); if Pointer(DestS)=Pointer(sarr[lowstart]) then inc(lowstart); @@ -597,7 +598,8 @@ begin { if DestS is used somewhere in the middle of the expression, we need to make sure the original string still exists after we empty/modify DestS } - destcopy:=dests; + destcopy:=pointer(dests); + fpc_WideStr_Incr_Ref(destcopy); lowstart:=low(sarr); break; end; @@ -626,6 +628,7 @@ begin inc(pc,size*sizeof(WideChar)); end; end; + fpc_WideStr_Decr_Ref(destcopy); end; {$endif STR_CONCAT_PROCS}