瀏覽代碼

* Added DisposeAndNil (bug ID 28895)

git-svn-id: trunk@33377 -
michael 9 年之前
父節點
當前提交
92b8bf97c0
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 0
      rtl/objpas/sysutils/sysutilh.inc
  2. 10 1
      rtl/objpas/sysutils/sysutils.inc

+ 1 - 0
rtl/objpas/sysutils/sysutilh.inc

@@ -321,6 +321,7 @@ Type
   {$ENDIF}
   
   procedure FreeAndNil(var obj);
+  procedure DisposeAndNil(var p);
 
   { interface handling }
   {$i intfh.inc}

+ 10 - 1
rtl/objpas/sysutils/sysutils.inc

@@ -162,7 +162,16 @@ end;
         temp.free;
       end;
 
-
+    procedure DisposeAndNil(var p);
+    
+    var
+      temp:Pointer;
+    begin
+      temp := Pointer(p);
+      Pointer(P):=nil;
+      FreeMem(temp);
+    end;
+    
   { Interfaces support }
   {$i sysuintf.inc}