From: Amos Jeffries Date: Wed, 29 Jun 2016 10:44:40 +0000 (+1200) Subject: Remove UnaryFunctor as well, use std::function instead X-Git-Tag: SQUID_4_0_13~39^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=950c8451c904f84990e044072e0b734f3b6cafca;p=thirdparty%2Fsquid.git Remove UnaryFunctor as well, use std::function instead --- diff --git a/src/base/MakeFunctor.h b/src/base/MakeFunctor.h deleted file mode 100644 index 23eae57722..0000000000 --- a/src/base/MakeFunctor.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 1996-2016 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_BASE_MAKEFUNCTOR_H -#define SQUID_BASE_MAKEFUNCTOR_H - -// Macro to be used to define a C++ functor for a function with one argument. -// The functor is suffixed with the _functor extension -#define UnaryFunctor(function, argument_type) \ - struct function ## _functor { \ - void operator()(argument_type a) { function(a); } \ - } - -/// DeAllocator functor for pointers that need free(3) -UnaryFunctor(xfree, char *); - -#endif // SQUID_BASE_MAKEFUNCTOR_H - diff --git a/src/base/Makefile.am b/src/base/Makefile.am index 1b309863ef..7bad2b474b 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -29,7 +29,6 @@ libbase_la_SOURCES = \ Lock.h \ LookupTable.h \ LruMap.h \ - MakeFunctor.h \ Packable.h \ PackableStream.h \ RegexPattern.cc \ diff --git a/src/security/Session.h b/src/security/Session.h index 6394a9313f..ae2a8ba0fd 100644 --- a/src/security/Session.h +++ b/src/security/Session.h @@ -9,7 +9,6 @@ #ifndef SQUID_SRC_SECURITY_SESSION_H #define SQUID_SRC_SECURITY_SESSION_H -#include "base/MakeFunctor.h" #include "security/LockingPointer.h" #include @@ -35,12 +34,11 @@ typedef LockingPointer SessionPoin #elif USE_GNUTLS typedef gnutls_session_t SessionPtr; -UnaryFunctor(gnutls_deinit, gnutls_session_t); // TODO: Convert to Locking pointer. // Locks can be implemented attaching locks counter to gnutls_session_t // objects using the gnutls_session_set_ptr()/gnutls_session_get_ptr () // library functions -typedef std::unique_ptr SessionPointer; +typedef std::unique_ptr> SessionPointer; #else // use void* so we can check against NULL diff --git a/src/security/cert_generators/file/certificate_db.cc b/src/security/cert_generators/file/certificate_db.cc index 41f6fbd271..b91512402d 100644 --- a/src/security/cert_generators/file/certificate_db.cc +++ b/src/security/cert_generators/file/certificate_db.cc @@ -7,7 +7,6 @@ */ #include "squid.h" -#include "base/MakeFunctor.h" #include "security/cert_generators/file/certificate_db.h" #include @@ -293,7 +292,7 @@ bool Ssl::CertificateDb::addCertAndPrivateKey(Security::CertPointer & cert, Ssl: std::string serial_string; Ssl::BIGNUM_Pointer serial(ASN1_INTEGER_to_BN(ai, NULL)); { - std::unique_ptr hex_bn(BN_bn2hex(serial.get())); + std::unique_ptr> hex_bn(BN_bn2hex(serial.get())); serial_string = std::string(hex_bn.get()); } row.setValue(cnlSerial, serial_string.c_str()); @@ -306,7 +305,7 @@ bool Ssl::CertificateDb::addCertAndPrivateKey(Security::CertPointer & cert, Ssl: } { - std::unique_ptr subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0)); + std::unique_ptr> subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0)); Security::CertPointer findCert; Ssl::EVP_PKEY_Pointer findPkey; if (pure_find(useName.empty() ? subject.get() : useName, findCert, findPkey)) { @@ -349,7 +348,7 @@ bool Ssl::CertificateDb::addCertAndPrivateKey(Security::CertPointer & cert, Ssl: if (!useName.empty()) row.setValue(cnlName, useName.c_str()); else { - std::unique_ptr subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0)); + std::unique_ptr> subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0)); row.setValue(cnlName, subject.get()); } diff --git a/src/ssl/gadgets.h b/src/ssl/gadgets.h index c1b0f2beea..15eed635d2 100644 --- a/src/ssl/gadgets.h +++ b/src/ssl/gadgets.h @@ -47,44 +47,33 @@ typedef std::unique_ptr X509_STACK_Pointer CtoCpp1(EVP_PKEY_free, EVP_PKEY *) typedef Security::LockingPointer EVP_PKEY_Pointer; -UnaryFunctor(BN_free, BIGNUM *); -typedef std::unique_ptr BIGNUM_Pointer; +typedef std::unique_ptr> BIGNUM_Pointer; -UnaryFunctor(BIO_free, BIO *); -typedef std::unique_ptr BIO_Pointer; +typedef std::unique_ptr> BIO_Pointer; -UnaryFunctor(ASN1_INTEGER_free, ASN1_INTEGER *); -typedef std::unique_ptr ASN1_INT_Pointer; +typedef std::unique_ptr> ASN1_INT_Pointer; -UnaryFunctor(ASN1_OCTET_STRING_free, ASN1_OCTET_STRING *); -typedef std::unique_ptr ASN1_OCTET_STRING_Pointer; +typedef std::unique_ptr> ASN1_OCTET_STRING_Pointer; -UnaryFunctor(TXT_DB_free, TXT_DB *); -typedef std::unique_ptr TXT_DB_Pointer; +typedef std::unique_ptr> TXT_DB_Pointer; -UnaryFunctor(X509_NAME_free, X509_NAME *); -typedef std::unique_ptr X509_NAME_Pointer; +typedef std::unique_ptr> X509_NAME_Pointer; -UnaryFunctor(RSA_free, RSA *); -typedef std::unique_ptr RSA_Pointer; +typedef std::unique_ptr> RSA_Pointer; -UnaryFunctor(X509_REQ_free, X509_REQ *); -typedef std::unique_ptr X509_REQ_Pointer; +typedef std::unique_ptr> X509_REQ_Pointer; sk_dtor_wrapper(sk_X509_NAME, STACK_OF(X509_NAME) *, X509_NAME_free); typedef std::unique_ptr X509_NAME_STACK_Pointer; -UnaryFunctor(AUTHORITY_KEYID_free, AUTHORITY_KEYID *); -typedef std::unique_ptr AUTHORITY_KEYID_Pointer; +typedef std::unique_ptr> AUTHORITY_KEYID_Pointer; sk_dtor_wrapper(sk_GENERAL_NAME, STACK_OF(GENERAL_NAME) *, GENERAL_NAME_free); typedef std::unique_ptr GENERAL_NAME_STACK_Pointer; -UnaryFunctor(GENERAL_NAME_free, GENERAL_NAME *); -typedef std::unique_ptr GENERAL_NAME_Pointer; +typedef std::unique_ptr> GENERAL_NAME_Pointer; -UnaryFunctor(X509_EXTENSION_free, X509_EXTENSION *); -typedef std::unique_ptr X509_EXTENSION_Pointer; +typedef std::unique_ptr> X509_EXTENSION_Pointer; /** \ingroup SslCrtdSslAPI