* fixed memory leak with the as operator, fixes #7174

git-svn-id: trunk@4355 -
This commit is contained in:
florian 2006-08-05 21:53:38 +00:00
parent 3e1c0cc8a5
commit 849878b472
2 changed files with 6 additions and 7 deletions

View File

@ -251,8 +251,8 @@ function fpc_do_as(aclass : tclass;aobject : tobject): tobject; compilerproc;
procedure fpc_intf_decr_ref(var i: pointer); compilerproc; procedure fpc_intf_decr_ref(var i: pointer); compilerproc;
procedure fpc_intf_incr_ref(i: pointer); compilerproc; procedure fpc_intf_incr_ref(i: pointer); compilerproc;
procedure fpc_intf_assign(var D: pointer; const S: pointer); compilerproc; procedure fpc_intf_assign(var D: pointer; const S: pointer); compilerproc;
function fpc_intf_as(const S: pointer; const iid: TGUID): pointer; compilerproc; function fpc_intf_as(const S: pointer; const iid: TGUID): IInterface; compilerproc;
function fpc_class_as_intf(const S: pointer; const iid: TGUID): pointer; compilerproc; function fpc_class_as_intf(const S: pointer; const iid: TGUID): IInterface; compilerproc;
Function fpc_PushExceptAddr (Ft: Longint;_buf,_newaddr : pointer): PJmp_buf ; compilerproc; Function fpc_PushExceptAddr (Ft: Longint;_buf,_newaddr : pointer): PJmp_buf ; compilerproc;
Procedure fpc_PushExceptObj (Obj : TObject; AnAddr,AFrame : Pointer); compilerproc; Procedure fpc_PushExceptObj (Obj : TObject; AnAddr,AFrame : Pointer); compilerproc;

View File

@ -63,8 +63,7 @@
D:=S; D:=S;
end; end;
function fpc_intf_as(const S: pointer; const iid: TGUID): pointer;[public,alias: 'FPC_INTF_AS']; compilerproc; function fpc_intf_as(const S: pointer; const iid: TGUID): IInterface;[public,alias: 'FPC_INTF_AS']; compilerproc;
var var
tmpi: pointer; // _AddRef before _Release tmpi: pointer; // _AddRef before _Release
begin begin
@ -72,14 +71,14 @@
begin begin
if IUnknown(S).QueryInterface(iid,tmpi)<>S_OK then if IUnknown(S).QueryInterface(iid,tmpi)<>S_OK then
handleerror(219); handleerror(219);
fpc_intf_as:=tmpi; pointer(fpc_intf_as):=tmpi;
end end
else else
fpc_intf_as:=nil; fpc_intf_as:=nil;
end; end;
function fpc_class_as_intf(const S: pointer; const iid: TGUID): pointer;[public,alias: 'FPC_CLASS_AS_INTF']; compilerproc; function fpc_class_as_intf(const S: pointer; const iid: TGUID): IInterface;[public,alias: 'FPC_CLASS_AS_INTF']; compilerproc;
var var
tmpi: pointer; // _AddRef before _Release tmpi: pointer; // _AddRef before _Release
@ -88,7 +87,7 @@
begin begin
if not TObject(S).GetInterface(iid,tmpi) then if not TObject(S).GetInterface(iid,tmpi) then
handleerror(219); handleerror(219);
fpc_class_as_intf:=tmpi; pointer(fpc_class_as_intf):=tmpi;
end end
else else
fpc_class_as_intf:=nil; fpc_class_as_intf:=nil;