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