From: Christos Tsantilas Date: Mon, 6 Dec 2010 14:12:56 +0000 (+0200) Subject: The *_free SSL API functions can not be used with TidyPointer in some OSes/compilers X-Git-Tag: take1~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14851ec224d59af3084f21c99aa0c305931038aa;p=thirdparty%2Fsquid.git The *_free SSL API functions can not be used with TidyPointer in some OSes/compilers The *_free SSL functions are declared as extern "C" and can not be used as DeAllocator argument of the TidyPointer class with some compilers and OSes. To solve this problem: - Define the CtoCpp1 macro to allow easy implementation of the C++ equivalent function of an extern C function. Currently defined in gadgets.h file, if required in the future can be moved to TidyPointer.h file - Use the CtoCpp macro to define the X509_free_cpp - Remove the Ssl::BIO_free_wrapper function does not needed any more --- diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc index 8926dd072d..057d3c766c 100644 --- a/src/ssl/gadgets.cc +++ b/src/ssl/gadgets.cc @@ -41,11 +41,6 @@ static bool makeRequest(Ssl::X509_REQ_Pointer & request, Ssl::EVP_PKEY_Pointer c return true; } -void Ssl::BIO_free_wrapper(BIO * bio) -{ - BIO_free(bio); -} - EVP_PKEY * Ssl::createSslPrivateKey() { Ssl::EVP_PKEY_Pointer pkey(EVP_PKEY_new()); diff --git a/src/ssl/gadgets.h b/src/ssl/gadgets.h index 12f8f6d71f..b2fb4f1a99 100644 --- a/src/ssl/gadgets.h +++ b/src/ssl/gadgets.h @@ -25,27 +25,49 @@ namespace Ssl because they are used by ssl_crtd. */ -/** - \ingroup SslCrtdSslAPI - * Function for BIO delete for Deleter template. -*/ -void BIO_free_wrapper(BIO * bio); +// Macro to be used to define the C++ equivalent function of an extern "C" +// function. The C++ function suffixed with the _cpp extension +#define CtoCpp1(function, argument) \ + extern "C++" inline void function ## _cpp(argument a) { \ + function(a); \ + } /** \ingroup SslCrtdSslAPI * TidyPointer typedefs for common SSL objects */ -typedef TidyPointer X509_Pointer; -typedef TidyPointer EVP_PKEY_Pointer; -typedef TidyPointer BIGNUM_Pointer; -typedef TidyPointer BIO_Pointer; -typedef TidyPointer ASN1_INT_Pointer; -typedef TidyPointer TXT_DB_Pointer; -typedef TidyPointer X509_NAME_Pointer; -typedef TidyPointer RSA_Pointer; -typedef TidyPointer X509_REQ_Pointer; -typedef TidyPointer SSL_CTX_Pointer; -typedef TidyPointer SSL_Pointer; +CtoCpp1(X509_free, X509 *) +typedef TidyPointer X509_Pointer; + +CtoCpp1(EVP_PKEY_free, EVP_PKEY *) +typedef TidyPointer EVP_PKEY_Pointer; + +CtoCpp1(BN_free, BIGNUM *) +typedef TidyPointer BIGNUM_Pointer; + +CtoCpp1(BIO_free, BIO *) +typedef TidyPointer BIO_Pointer; + +CtoCpp1(ASN1_INTEGER_free, ASN1_INTEGER *) +typedef TidyPointer ASN1_INT_Pointer; + +CtoCpp1(TXT_DB_free, TXT_DB *) +typedef TidyPointer TXT_DB_Pointer; + +CtoCpp1(X509_NAME_free, X509_NAME *) +typedef TidyPointer X509_NAME_Pointer; + +CtoCpp1(RSA_free, RSA *) +typedef TidyPointer RSA_Pointer; + +CtoCpp1(X509_REQ_free, X509_REQ *) +typedef TidyPointer X509_REQ_Pointer; + +CtoCpp1(SSL_CTX_free, SSL_CTX *) +typedef TidyPointer SSL_CTX_Pointer; + +CtoCpp1(SSL_free, SSL *) +typedef TidyPointer SSL_Pointer; /**