* 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
{ Ref count dropped to zero }
DisposeAnsiString (S); { Remove...}
{$ifndef decrrefnotnil}
s:=nil;
{$endif}
end;
{$ifdef hascompilerproc}
@ -513,7 +515,7 @@ end;
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}
{$else}
Procedure UniqueString(Var S : AnsiString); [Public,Alias : 'FPC_ANSISTR_UNIQUE'];
Procedure UniqueString(Var S : AnsiString); [Public,Alias : 'FPC_ANSISTR_UNIQUE'];
{$endif}
{
Make sure reference count of S is 1,
@ -525,7 +527,7 @@ Var
begin
{$ifdef HASCOMPILERPROC}
pointer(result) := pointer(s);
{$endif}
{$endif}
If Pointer(S)=Nil then
exit;
if PAnsiRec(Pointer(S)-Firstoff)^.Ref<>1 then
@ -538,7 +540,7 @@ begin
pointer(S):=SNew;
{$ifdef HASCOMPILERPROC}
pointer(result):=SNew;
{$endif}
{$endif}
end;
end;
@ -876,7 +878,11 @@ end;
{
$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
Revision 1.44 2004/05/16 16:52:28 peter

View File

@ -162,10 +162,16 @@ begin
Temp:=PByte(TypeInfo);
case temp^ of
tkAstring :
fpc_AnsiStr_Decr_Ref(PPointer(Data)^);
begin
fpc_AnsiStr_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$ifdef HASWIDESTRING}
tkWstring :
fpc_WideStr_Decr_Ref(PPointer(Data)^);
begin
fpc_WideStr_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$endif HASWIDESTRING}
tkArray :
begin
@ -206,7 +212,10 @@ begin
end;
{$ifdef HASINTF}
tkInterface:
Intf_Decr_Ref(PPointer(Data)^);
begin
Intf_Decr_Ref(PPointer(Data)^);
PPointer(Data)^:=nil;
end;
{$endif HASINTF}
tkDynArray:
fpc_dynarray_decr_ref(PPointer(Data)^,TypeInfo);
@ -372,7 +381,11 @@ procedure fpc_finalize_array(data,typeinfo : pointer;count,size : longint); [Pub
{
$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
Revision 1.11 2004/03/27 23:22:38 florian

View File

@ -201,7 +201,9 @@ Begin
If declocked(l^) then
{ Ref count dropped to zero }
DisposeWideString (S); { Remove...}
{$ifndef decrrefnotnil}
s:=nil;
{$endif}
end;
{$ifdef hascompilerproc}
@ -1042,7 +1044,11 @@ end;
{
$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
Revision 1.38 2004/05/29 15:39:08 florian