File tree 1 file changed +6
-4
lines changed
LibGit2Sharp/Core/Handles
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 18
18
//#define LEAKS_TRACKING
19
19
20
20
using System ;
21
- using Microsoft . Win32 . SafeHandles ;
21
+ using System . Runtime . InteropServices ;
22
22
23
23
#if LEAKS_IDENTIFYING
24
24
namespace LibGit2Sharp . Core
@@ -83,7 +83,7 @@ namespace LibGit2Sharp.Core.Handles
83
83
using System . Globalization ;
84
84
#endif
85
85
86
- internal unsafe abstract class Libgit2Object : SafeHandleZeroOrMinusOneIsInvalid
86
+ internal unsafe abstract class Libgit2Object : SafeHandle
87
87
{
88
88
#if LEAKS_TRACKING
89
89
private readonly string trace ;
@@ -96,7 +96,7 @@ internal unsafe Libgit2Object(void* ptr, bool owned)
96
96
}
97
97
98
98
internal unsafe Libgit2Object ( IntPtr ptr , bool owned )
99
- : base ( owned )
99
+ : base ( IntPtr . Zero , owned )
100
100
{
101
101
SetHandle ( ptr ) ;
102
102
@@ -108,12 +108,14 @@ internal unsafe Libgit2Object(IntPtr ptr, bool owned)
108
108
#endif
109
109
}
110
110
111
+ public override bool IsInvalid => handle == IntPtr . Zero ;
112
+
111
113
internal IntPtr AsIntPtr ( ) => DangerousGetHandle ( ) ;
112
114
113
115
protected override void Dispose ( bool disposing )
114
116
{
115
117
#if LEAKS_IDENTIFYING
116
- bool leaked = ! disposing && DangerousGetHandle ( ) != IntPtr . Zero ;
118
+ bool leaked = ! disposing && ! IsInvalid ;
117
119
118
120
if ( leaked )
119
121
{
You can’t perform that action at this time.
0 commit comments