File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
LibGit2Sharp/Core/Handles Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1818//#define LEAKS_TRACKING
1919
2020using System ;
21- using Microsoft . Win32 . SafeHandles ;
21+ using System . Runtime . InteropServices ;
2222
2323#if LEAKS_IDENTIFYING
2424namespace LibGit2Sharp . Core
@@ -83,7 +83,7 @@ namespace LibGit2Sharp.Core.Handles
8383 using System . Globalization ;
8484#endif
8585
86- internal unsafe abstract class Libgit2Object : SafeHandleZeroOrMinusOneIsInvalid
86+ internal unsafe abstract class Libgit2Object : SafeHandle
8787 {
8888#if LEAKS_TRACKING
8989 private readonly string trace ;
@@ -96,7 +96,7 @@ internal unsafe Libgit2Object(void* ptr, bool owned)
9696 }
9797
9898 internal unsafe Libgit2Object ( IntPtr ptr , bool owned )
99- : base ( owned )
99+ : base ( IntPtr . Zero , owned )
100100 {
101101 SetHandle ( ptr ) ;
102102
@@ -108,12 +108,14 @@ internal unsafe Libgit2Object(IntPtr ptr, bool owned)
108108#endif
109109 }
110110
111+ public override bool IsInvalid => handle == IntPtr . Zero ;
112+
111113 internal IntPtr AsIntPtr ( ) => DangerousGetHandle ( ) ;
112114
113115 protected override void Dispose ( bool disposing )
114116 {
115117#if LEAKS_IDENTIFYING
116- bool leaked = ! disposing && DangerousGetHandle ( ) != IntPtr . Zero ;
118+ bool leaked = ! disposing && ! IsInvalid ;
117119
118120 if ( leaked )
119121 {
You can’t perform that action at this time.
0 commit comments