19 lines
585 B
C#
19 lines
585 B
C#
|
|
using Microsoft.Win32.SafeHandles;
|
||
|
|
|
||
|
|
// Standard SafeHandle pattern for vc_client* — guarantees vc_client_destroy runs even on an
|
||
|
|
// unhandled exception or a finalizer pass, which a bare `nint` field would not.
|
||
|
|
namespace VoiceCat.Interop;
|
||
|
|
|
||
|
|
internal sealed class VoiceCatClientHandle : SafeHandleZeroOrMinusOneIsInvalid
|
||
|
|
{
|
||
|
|
public VoiceCatClientHandle() : base(ownsHandle: true) { }
|
||
|
|
|
||
|
|
public new void SetHandle(nint handle) => base.SetHandle(handle);
|
||
|
|
|
||
|
|
protected override bool ReleaseHandle()
|
||
|
|
{
|
||
|
|
NativeMethods.vc_client_destroy(handle);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|