]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove UnaryFunctor as well, use std::function instead
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 29 Jun 2016 10:44:40 +0000 (22:44 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 29 Jun 2016 10:44:40 +0000 (22:44 +1200)
src/base/MakeFunctor.h [deleted file]
src/base/Makefile.am
src/security/Session.h
src/security/cert_generators/file/certificate_db.cc
src/ssl/gadgets.h

diff --git a/src/base/MakeFunctor.h b/src/base/MakeFunctor.h
deleted file mode 100644 (file)
index 23eae57..0000000
+++ /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
-
index 1b309863ef230ef5feefc0687a09a519e556c622..7bad2b474b34e4df17d3a5289f05672f7245eb6a 100644 (file)
@@ -29,7 +29,6 @@ libbase_la_SOURCES = \
        Lock.h \
        LookupTable.h \
        LruMap.h \
-       MakeFunctor.h \
        Packable.h \
        PackableStream.h \
        RegexPattern.cc \
index 6394a9313f8181448dc251e7264c9d7117517dfd..ae2a8ba0fd771f66746a67dfa958c1d31120dcb8 100644 (file)
@@ -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 <memory>
@@ -35,12 +34,11 @@ typedef LockingPointer<SSL, Security::SSL_free_cpp, CRYPTO_LOCK_SSL> 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<struct gnutls_session_int, Security::gnutls_deinit_functor> SessionPointer;
+typedef std::unique_ptr<struct gnutls_session_int, std::function<decltype(gnutls_deinit)>> SessionPointer;
 
 #else
 // use void* so we can check against NULL
index 41f6fbd271f4840f5f4c8c6b18e03c25bcbaf241..b91512402da3f4a6e64c8c0c10b881db61dd03c3 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "squid.h"
-#include "base/MakeFunctor.h"
 #include "security/cert_generators/file/certificate_db.h"
 
 #include <cerrno>
@@ -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<char, xfree_functor> hex_bn(BN_bn2hex(serial.get()));
+        std::unique_ptr<char, std::function<decltype(xfree)>> 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<char, xfree_functor> subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0));
+        std::unique_ptr<char, std::function<decltype(xfree)>> 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<char, xfree_functor> subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0));
+        std::unique_ptr<char, std::function<decltype(xfree)>> subject(X509_NAME_oneline(X509_get_subject_name(cert.get()), nullptr, 0));
         row.setValue(cnlName, subject.get());
     }
 
index c1b0f2beead8fb5d75669ca679bbb4ba646b2553..15eed635d243beef877210e009eb039bff8a178f 100644 (file)
@@ -47,44 +47,33 @@ typedef std::unique_ptr<STACK_OF(X509), sk_X509_free_wrapper> X509_STACK_Pointer
 CtoCpp1(EVP_PKEY_free, EVP_PKEY *)
 typedef Security::LockingPointer<EVP_PKEY, EVP_PKEY_free_cpp, CRYPTO_LOCK_EVP_PKEY> EVP_PKEY_Pointer;
 
-UnaryFunctor(BN_free, BIGNUM *);
-typedef std::unique_ptr<BIGNUM, BN_free_functor> BIGNUM_Pointer;
+typedef std::unique_ptr<BIGNUM, std::function<decltype(BN_free)>> BIGNUM_Pointer;
 
-UnaryFunctor(BIO_free, BIO *);
-typedef std::unique_ptr<BIO, BIO_free_functor> BIO_Pointer;
+typedef std::unique_ptr<BIO, std::function<decltype(BIO_free)>> BIO_Pointer;
 
-UnaryFunctor(ASN1_INTEGER_free, ASN1_INTEGER *);
-typedef std::unique_ptr<ASN1_INTEGER, ASN1_INTEGER_free_functor> ASN1_INT_Pointer;
+typedef std::unique_ptr<ASN1_INTEGER, std::function<decltype(ASN1_INTEGER_free)>> ASN1_INT_Pointer;
 
-UnaryFunctor(ASN1_OCTET_STRING_free, ASN1_OCTET_STRING *);
-typedef std::unique_ptr<ASN1_OCTET_STRING, ASN1_OCTET_STRING_free_functor> ASN1_OCTET_STRING_Pointer;
+typedef std::unique_ptr<ASN1_OCTET_STRING, std::function<decltype(ASN1_OCTET_STRING_free)>> ASN1_OCTET_STRING_Pointer;
 
-UnaryFunctor(TXT_DB_free, TXT_DB *);
-typedef std::unique_ptr<TXT_DB, TXT_DB_free_functor> TXT_DB_Pointer;
+typedef std::unique_ptr<TXT_DB, std::function<decltype(TXT_DB_free)>> TXT_DB_Pointer;
 
-UnaryFunctor(X509_NAME_free, X509_NAME *);
-typedef std::unique_ptr<X509_NAME, X509_NAME_free_functor> X509_NAME_Pointer;
+typedef std::unique_ptr<X509_NAME, std::function<decltype(X509_NAME_free)>> X509_NAME_Pointer;
 
-UnaryFunctor(RSA_free, RSA *);
-typedef std::unique_ptr<RSA, RSA_free_functor> RSA_Pointer;
+typedef std::unique_ptr<RSA, std::function<decltype(RSA_free)>> RSA_Pointer;
 
-UnaryFunctor(X509_REQ_free, X509_REQ *);
-typedef std::unique_ptr<X509_REQ, X509_REQ_free_functor> X509_REQ_Pointer;
+typedef std::unique_ptr<X509_REQ, std::function<decltype(X509_REQ_free)>> X509_REQ_Pointer;
 
 sk_dtor_wrapper(sk_X509_NAME, STACK_OF(X509_NAME) *, X509_NAME_free);
 typedef std::unique_ptr<STACK_OF(X509_NAME), sk_X509_NAME_free_wrapper> X509_NAME_STACK_Pointer;
 
-UnaryFunctor(AUTHORITY_KEYID_free, AUTHORITY_KEYID *);
-typedef std::unique_ptr<AUTHORITY_KEYID, AUTHORITY_KEYID_free_functor> AUTHORITY_KEYID_Pointer;
+typedef std::unique_ptr<AUTHORITY_KEYID, std::function<decltype(AUTHORITY_KEYID_free)>> AUTHORITY_KEYID_Pointer;
 
 sk_dtor_wrapper(sk_GENERAL_NAME, STACK_OF(GENERAL_NAME) *, GENERAL_NAME_free);
 typedef std::unique_ptr<STACK_OF(GENERAL_NAME), sk_GENERAL_NAME_free_wrapper> GENERAL_NAME_STACK_Pointer;
 
-UnaryFunctor(GENERAL_NAME_free, GENERAL_NAME *);
-typedef std::unique_ptr<GENERAL_NAME, GENERAL_NAME_free_functor> GENERAL_NAME_Pointer;
+typedef std::unique_ptr<GENERAL_NAME, std::function<decltype(GENERAL_NAME_free)>> GENERAL_NAME_Pointer;
 
-UnaryFunctor(X509_EXTENSION_free, X509_EXTENSION *);
-typedef std::unique_ptr<X509_EXTENSION, X509_EXTENSION_free_functor> X509_EXTENSION_Pointer;
+typedef std::unique_ptr<X509_EXTENSION, std::function<decltype(X509_EXTENSION_free)>> X509_EXTENSION_Pointer;
 
 /**
  \ingroup SslCrtdSslAPI