﻿using System;
using System.Collections.Generic;
using System.Text;

using static crtdbg;

namespace xpInterop
{
    public class VCDebugClientPtr :
        _SafeHandleZeroOrMinusOneIsInvalid
    {
        public VCDebugClientPtr(IntPtr ptr) :
            base(true)
        {
            this.SetHandle(ptr);
        }

        public static implicit operator IntPtr(VCDebugClientPtr ptr) =>
            ptr.handle;

        public static implicit operator VCDebugClientPtr(IntPtr ptr) =>
            new VCDebugClientPtr(ptr);

        protected override bool ReleaseHandle()
        {
            _free_dbg(this.handle, _CLIENT_BLOCK);
            this.SetHandleAsInvalid();
            return true;
        }
    }
}
