* decr ref doesn't reset pointer

* finalize resets pointer for astring,wstring
This commit is contained in:
peter 2004-07-02 21:21:09 +00:00
parent 695b29bab3
commit 59691cc142
3 changed files with 34 additions and 9 deletions

View File

@ -115,7 +115,9 @@ Begin
If declocked(l^) then If declocked(l^) then
{ Ref count dropped to zero } { Ref count dropped to zero }
DisposeAnsiString (S); { Remove...} DisposeAnsiString (S); { Remove...}
{$ifndef decrrefnotnil}
s:=nil; s:=nil;
{$endif}
end; end;
{$ifdef hascompilerproc} {$ifdef hascompilerproc}
@ -513,7 +515,7 @@ end;
Procedure UniqueString(Var S : AnsiString); [external name 'FPC_ANSISTR_UNIQUE']; Procedure UniqueString(Var S : AnsiString); [external name 'FPC_ANSISTR_UNIQUE'];
Function fpc_ansistr_Unique(Var S : Pointer): Pointer; [Public,Alias : 'FPC_ANSISTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif} Function fpc_ansistr_Unique(Var S : Pointer): Pointer; [Public,Alias : 'FPC_ANSISTR_UNIQUE']; {$ifdef hascompilerproc} compilerproc; {$endif}
{$else} {$else}
Procedure UniqueString(Var S : AnsiString); [Public,Alias : 'FPC_ANSISTR_UNIQUE']; Procedure UniqueString(Var S : AnsiString); [Public,Alias : 'FPC_ANSISTR_UNIQUE'];
{$endif} {$endif}
{ {
Make sure reference count of S is 1, Make sure reference count of S is 1,
@ -525,7 +527,7 @@ Var
begin begin
{$ifdef HASCOMPILERPROC} {$ifdef HASCOMPILERPROC}
pointer(result) := pointer(s); pointer(result) := pointer(s);
{$endif} {$endif}
If Pointer(S)=Nil then If Pointer(S)=Nil then
exit; exit;
if PAnsiRec(Pointer(S)-Firstoff)^.Ref<>1 then if PAnsiRec(Pointer(S)-Firstoff)^.Ref<>1 then
@ -538,7 +540,7 @@ begin
pointer(S):=SNew; pointer(S):=SNew;
{$ifdef HASCOMPILERPROC} {$ifdef HASCOMPILERPROC}
pointer(result):=SNew; pointer(result):=SNew;
{$endif} {$endif}
end; end;
end; end;
@ -876,7 +878,11 @@ end;
{ {
$Log$ $Log$
Revision 1.45 2004-05-29 15:39:08 florian Revision 1.46 2004-07-02 21:21:09 peter
* decr ref doesn't reset pointer
* finalize resets pointer for astring,wstring
Revision 1.45 2004/05/29 15:39:08 florian
* the decr functions set the data now to nil * the decr functions set the data now to nil
Revision 1.44 2004/05/16 16:52:28 peter Revision 1.44 2004/05/16 16:52:28 peter

View File

@ -162,10 +162,16 @@ begin
Temp:=PByte(TypeInfo); Temp:=PByte(TypeInfo);
case temp^ of case temp^ of
tkAstring : tkAstring :
fpc_AnsiStr_Decr_Ref(PPointer(Data)^); begin
fpc_AnsiStr_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$ifdef HASWIDESTRING} {$ifdef HASWIDESTRING}
tkWstring : tkWstring :
fpc_WideStr_Decr_Ref(PPointer(Data)^); begin
fpc_WideStr_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$endif HASWIDESTRING} {$endif HASWIDESTRING}
tkArray : tkArray :
begin begin
@ -206,7 +212,10 @@ begin
end; end;
{$ifdef HASINTF} {$ifdef HASINTF}
tkInterface: tkInterface:
Intf_Decr_Ref(PPointer(Data)^); begin
Intf_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$endif HASINTF} {$endif HASINTF}
tkDynArray: tkDynArray:
fpc_dynarray_decr_ref(PPointer(Data)^,TypeInfo); fpc_dynarray_decr_ref(PPointer(Data)^,TypeInfo);
@ -372,7 +381,11 @@ procedure fpc_finalize_array(data,typeinfo : pointer;count,size : longint); [Pub
{ {
$Log$ $Log$
Revision 1.12 2004-05-31 20:25:04 peter Revision 1.13 2004-07-02 21:21:09 peter
* decr ref doesn't reset pointer
* finalize resets pointer for astring,wstring
Revision 1.12 2004/05/31 20:25:04 peter
* removed warnings * removed warnings
Revision 1.11 2004/03/27 23:22:38 florian Revision 1.11 2004/03/27 23:22:38 florian

View File

@ -201,7 +201,9 @@ Begin
If declocked(l^) then If declocked(l^) then
{ Ref count dropped to zero } { Ref count dropped to zero }
DisposeWideString (S); { Remove...} DisposeWideString (S); { Remove...}
{$ifndef decrrefnotnil}
s:=nil; s:=nil;
{$endif}
end; end;
{$ifdef hascompilerproc} {$ifdef hascompilerproc}
@ -1042,7 +1044,11 @@ end;
{ {
$Log$ $Log$
Revision 1.39 2004-05-31 14:31:57 peter Revision 1.40 2004-07-02 21:21:09 peter
* decr ref doesn't reset pointer
* finalize resets pointer for astring,wstring
Revision 1.39 2004/05/31 14:31:57 peter
* remove comment warnings * remove comment warnings
Revision 1.38 2004/05/29 15:39:08 florian Revision 1.38 2004/05/29 15:39:08 florian