using System; using CeresSharp.Native; namespace CeresSharp.Native.SafeHandles; /// /// Safe handle for Ceres GradientCheckerOptions. /// internal sealed class GradientCheckerOptionsHandle : BaseSafeHandle { private GradientCheckerOptionsHandle() : base() { } private GradientCheckerOptionsHandle(IntPtr handle, bool ownsHandle) : base(handle, ownsHandle) { } public static GradientCheckerOptionsHandle Create() { var handle = CeresNative.ceres_wrapper_create_gradient_checker_options(); if (handle == IntPtr.Zero) { throw new Exceptions.CeresException(Exceptions.CeresErrorCode.OutOfMemory, "Failed to create gradient checker options"); } return new GradientCheckerOptionsHandle(handle, true); } protected override void ReleaseNativeHandle(IntPtr handle) { CeresNative.ceres_wrapper_free_gradient_checker_options(handle); } }