void X509_free(X509 *a)
	{
	int i;

	if (a == NULL) return;

	i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_X509);
#ifdef REF_PRINT
	REF_PRINT("X509",a);
#endif
	if (i > 0) return;
#ifdef REF_CHECK
	if (i < 0)
		{
		fprintf(stderr,"X509_free, bad reference count\n");
		abort();
		}
#endif

	CRYPTO_free_ex_data(x509_meth,a,&a->ex_data);
	X509_CINF_free(a->cert_info);
	X509_ALGOR_free(a->sig_alg);
	M_ASN1_BIT_STRING_free(a->signature);
	X509_CERT_AUX_free(a->aux);
	ASN1_OCTET_STRING_free(a->skid);
	AUTHORITY_KEYID_free(a->akid);

	if (a->name != NULL) OPENSSL_free(a->name);
	OPENSSL_free(a);
	}