initial commit
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Win32.SafeHandles;
|
||||
|
||||
internal sealed class SafeAllocHHandle : SafeBuffer
|
||||
{
|
||||
internal static SafeAllocHHandle InvalidHandle => new SafeAllocHHandle(IntPtr.Zero);
|
||||
|
||||
public SafeAllocHHandle()
|
||||
: base(ownsHandle: true)
|
||||
{
|
||||
}
|
||||
|
||||
internal SafeAllocHHandle(IntPtr handle)
|
||||
: base(ownsHandle: true)
|
||||
{
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
if (handle != IntPtr.Zero)
|
||||
{
|
||||
Marshal.FreeHGlobal(handle);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user