DSO *DSO_new_method(DSO_METHOD *meth)
	{
	DSO *ret;

	if(default_DSO_meth == NULL)
		/* We default to DSO_METH_openssl() which in turn defaults
		 * to stealing the "best available" method. Will fallback
		 * to DSO_METH_null() in the worst case. */
		default_DSO_meth = DSO_METHOD_openssl();
	ret = (DSO *)OPENSSL_malloc(sizeof(DSO));
	if(ret == NULL)
		{
		DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
		return(NULL);
		}
	memset(ret, 0, sizeof(DSO));
	ret->meth_data = sk_new_null();
	if((ret->meth_data = sk_new_null()) == NULL)
		{
		/* sk_new doesn't generate any errors so we do */
		DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE);
		OPENSSL_free(ret);
		return(NULL);
		}
	if(meth == NULL)
		ret->meth = default_DSO_meth;
	else
		ret->meth = meth;
	ret->references = 1;
	if((ret->meth->init != NULL) && !ret->meth->init(ret))
		{
		OPENSSL_free(ret);
		ret=NULL;
		}
	return(ret);
	}