/// <summary>Retrieves an authorization baton allocated in the specified pool; containing the current authorization settings</summary>
        internal unsafe svn_auth_baton_t GetAuthorizationBaton(ref int cookie)
        {
            if (_currentBaton != null && _cookie == cookie)
            {
                return(_currentBaton);
            }

            using var tmpPool = new AprPool(_parentPool);

            apr_hash_t creds = null;

            if (_currentBaton != null)
            {
                creds = clone_credentials(get_cache(_currentBaton), null, tmpPool);
            }

            _authPool.Clear();

            var authArray = new AprArray <ISvnAuthWrapper, SvnAuthProviderMarshaller>(_handlers, _authPool);

            svn_auth_baton_t.__Internal *rsltPtr = null;

            svn_auth.svn_auth_open((void **)&rsltPtr, authArray.Handle, _authPool.Handle);

            var rslt = svn_auth_baton_t.__CreateInstance(new IntPtr(rsltPtr));

            if (creds != null)
            {
                clone_credentials(creds, get_cache(rslt), _authPool);
            }

            if (_clientContext._configPath != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_CONFIG_DIR),
                    new IntPtr(_authPool.AllocDirent(_clientContext._configPath)));
            }

            if (_forcedUser != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_DEFAULT_USERNAME),
                    new IntPtr(_authPool.AllocString(_forcedUser)));
            }

            if (_forcedPassword != null)
            {
                svn_auth.svn_auth_set_parameter(
                    rslt,
                    tmpPool.AllocString(Constants.SVN_AUTH_PARAM_DEFAULT_PASSWORD),
                    new IntPtr(_authPool.AllocString(_forcedPassword)));
            }

            _currentBaton = rslt;

            cookie = _cookie;
            return(rslt);
        }
 public void Clear()
 {
     mPool.Clear();
 }