]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
use make_unique instead of new 10870/head
authorRosen Penev <rosenp@gmail.com>
Wed, 20 Oct 2021 02:34:16 +0000 (19:34 -0700)
committerRosen Penev <rosenp@gmail.com>
Wed, 20 Oct 2021 06:47:32 +0000 (23:47 -0700)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
46 files changed:
modules/bindbackend/bindbackend2.cc
modules/geoipbackend/geoipinterface-dat.cc
modules/geoipbackend/geoipinterface-mmdb.cc
modules/gmysqlbackend/smysql.cc
modules/godbcbackend/sodbc.cc
modules/gpgsqlbackend/spgsql.cc
modules/pipebackend/pipebackend.cc
modules/remotebackend/httpconnector.cc
modules/remotebackend/remotebackend.cc
modules/tinydnsbackend/tinydnsbackend.cc
pdns/comfun.cc
pdns/common_startup.cc
pdns/dbdnsseckeeper.cc
pdns/dnsdist-lua.cc
pdns/dnsdist-rings.hh
pdns/dnsdist.cc
pdns/dnsdistdist/dnsdist-kvs.cc
pdns/dnsdistdist/doh.cc
pdns/dnsdistdist/test-dnsdistkvs_cc.cc
pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc
pdns/dnsrecords.hh
pdns/dnsscope.cc
pdns/dnstcpbench.cc
pdns/dnswasher.cc
pdns/ixfrdist-web.cc
pdns/lua-base4.cc
pdns/lua-record.cc
pdns/lua-recursor4.cc
pdns/nsec3dig.cc
pdns/packethandler.cc
pdns/pdns_recursor.cc
pdns/pkcs11signers.cc
pdns/receiver.cc
pdns/recursordist/stable-bloom.hh
pdns/recursordist/test-rec-zonetocache.cc
pdns/recursordist/test-syncres_cc.cc
pdns/recursordist/test-syncres_cc4.cc
pdns/resolver.cc
pdns/saxfr.cc
pdns/sodiumsigners.cc
pdns/ssqlite3.cc
pdns/sstuff.hh
pdns/syncres.hh
pdns/tcpiohandler.cc
pdns/toysdig.cc
pdns/ws-auth.cc

index 1443681a39b7494f56a58bef0bdd78d7cc7ace64..216b1b9cb3e227dfc732839e081765e56d38235b 100644 (file)
@@ -224,7 +224,7 @@ bool Bind2Backend::startTransaction(const DNSName& qname, int id)
       return false;
     }
 
-    d_of = std::unique_ptr<ofstream>(new ofstream(d_transaction_tmpname.c_str()));
+    d_of = std::make_unique<ofstream>(d_transaction_tmpname);
     if (!*d_of) {
       unlink(d_transaction_tmpname.c_str());
       close(fd);
index 5a5a05dac4fb309b34ed3295ff9c282930fa3bc1..75b11ccc58f8f843933941bc77e878a323bd86e6 100644 (file)
@@ -476,7 +476,7 @@ unique_ptr<GeoIPInterface> GeoIPInterface::makeDATInterface(const string& fname,
   const auto& opt = opts.find("mode");
   if (opt != opts.end())
     mode = opt->second;
-  return unique_ptr<GeoIPInterface>(new GeoIPInterfaceDAT(fname, mode));
+  return std::make_unique<GeoIPInterfaceDAT>(fname, mode);
 }
 
 #else
index b8a11ef806a9a8e6c2484ccfddfd6cb5683cc95b..969d5abc5293b4987cfed9d3b7bf1cbcc6eca885 100644 (file)
@@ -283,7 +283,7 @@ unique_ptr<GeoIPInterface> GeoIPInterface::makeMMDBInterface(const string& fname
   const auto& opt_lang = opts.find("language");
   if (opt_lang != opts.end())
     language = opt_lang->second;
-  return unique_ptr<GeoIPInterface>(new GeoIPInterfaceMMDB(fname, mode, language));
+  return std::make_unique<GeoIPInterfaceMMDB>(fname, mode, language);
 }
 
 #else
index b3ce048f19d86995e2e28ef2538a2887c8c743de..8b3c80bbc55623f92e413f6cd22a09e09e6593bd 100644 (file)
@@ -552,7 +552,7 @@ SSqlException SMySQL::sPerrorException(const string& reason)
 
 std::unique_ptr<SSqlStatement> SMySQL::prepare(const string& query, int nparams)
 {
-  return std::unique_ptr<SSqlStatement>(new SMySQLStatement(query, s_dolog, nparams, &d_db));
+  return std::make_unique<SMySQLStatement>(query, s_dolog, nparams, &d_db);
 }
 
 void SMySQL::execute(const string& query)
index 2985557a770fa0c5a634623b0ddc449092e6b3d0..a1a7ad0255bf8f6955683deb2e5e48a1bd012ff4 100644 (file)
@@ -479,7 +479,7 @@ SSqlException SODBC::sPerrorException(const std::string& reason)
 
 std::unique_ptr<SSqlStatement> SODBC::prepare(const string& query, int nparams)
 {
-  return std::unique_ptr<SSqlStatement>(new SODBCStatement(query, m_log, nparams, m_connection));
+  return std::make_unique<SODBCStatement>(query, m_log, nparams, m_connection);
 }
 
 void SODBC::startTransaction()
index c40347fd6768fc4012e8480a982cec3ddc790a2c..996d72dbc7aa4581eafecd5c4cacfdecc2c4c70a 100644 (file)
@@ -375,7 +375,7 @@ void SPgSQL::execute(const string& query)
 std::unique_ptr<SSqlStatement> SPgSQL::prepare(const string& query, int nparams)
 {
   d_nstatements++;
-  return std::unique_ptr<SSqlStatement>(new SPgSQLStatement(query, s_dolog, nparams, this, d_nstatements));
+  return std::make_unique<SPgSQLStatement>(query, s_dolog, nparams, this, d_nstatements);
 }
 
 void SPgSQL::startTransaction()
index b540a4c308e05075736e4869c847e809e157aeca..5773adcf0bccbfbbffc6f24914c3dd7436490ab3 100644 (file)
@@ -66,10 +66,10 @@ void CoWrapper::launch()
     throw ArgException("pipe-command is not specified");
 
   if (isUnixSocket(d_command)) {
-    d_cp = std::unique_ptr<CoRemote>(new UnixRemote(d_command, d_timeout));
+    d_cp = std::make_unique<UnixRemote>(d_command, d_timeout);
   }
   else {
-    auto coprocess = std::unique_ptr<CoProcess>(new CoProcess(d_command, d_timeout));
+    auto coprocess = std::make_unique<CoProcess>(d_command, d_timeout);
     coprocess->launch();
     d_cp = std::move(coprocess);
   }
@@ -130,11 +130,11 @@ void PipeBackend::launch()
 
   try {
     if (!getArg("regex").empty()) {
-      d_regex = std::unique_ptr<Regex>(new Regex(getArg("regex")));
+      d_regex = std::make_unique<Regex>(getArg("regex"));
     }
     d_regexstr = getArg("regex");
     d_abiVersion = getArgAsNum("abi-version");
-    d_coproc = unique_ptr<CoWrapper>(new CoWrapper(getArg("command"), getArgAsNum("timeout"), getArgAsNum("abi-version")));
+    d_coproc = std::make_unique<CoWrapper>(getArg("command"), getArgAsNum("timeout"), getArgAsNum("abi-version"));
   }
 
   catch (const ArgException& A) {
index 99c0676e0eddbf9f2b11e2551e9d75fb684cac5c..2c21d85c095fadf38248cf665dd639ea36e09dc6 100644 (file)
@@ -385,7 +385,7 @@ int HTTPConnector::send_message(const Json& input)
 
     while (gAddrPtr) {
       try {
-        d_socket = std::unique_ptr<Socket>(new Socket(gAddrPtr->ai_family, gAddrPtr->ai_socktype, gAddrPtr->ai_protocol));
+        d_socket = std::make_unique<Socket>(gAddrPtr->ai_family, gAddrPtr->ai_socktype, gAddrPtr->ai_protocol);
         d_addr.setSockaddr(gAddrPtr->ai_addr, gAddrPtr->ai_addrlen);
         d_socket->connect(d_addr);
         d_socket->setNonBlocking();
index 764deee33d3780eecf6f62f26ceb54557be41f63..380d956442de3440fe63523461c1f04e1199b1df 100644 (file)
@@ -165,20 +165,20 @@ int RemoteBackend::build()
 
   // connectors know what they are doing
   if (type == "unix") {
-    this->connector = std::unique_ptr<Connector>(new UnixsocketConnector(options));
+    this->connector = std::make_unique<UnixsocketConnector>(options);
   }
   else if (type == "http") {
-    this->connector = std::unique_ptr<Connector>(new HTTPConnector(options));
+    this->connector = std::make_unique<HTTPConnector>(options);
   }
   else if (type == "zeromq") {
 #ifdef REMOTEBACKEND_ZEROMQ
-    this->connector = std::unique_ptr<Connector>(new ZeroMQConnector(options));
+    this->connector = std::make_unique<ZeroMQConnector>(options);
 #else
     throw PDNSException("Invalid connection string: zeromq connector support not enabled. Recompile with --enable-remotebackend-zeromq");
 #endif
   }
   else if (type == "pipe") {
-    this->connector = std::unique_ptr<Connector>(new PipeConnector(options));
+    this->connector = std::make_unique<PipeConnector>(options);
   }
   else {
     throw PDNSException("Invalid connection string: unknown connector");
index aa6cf959d827d059914f4671f1ed71cf7347de86..9292d3803cf29f44b2688ca2abfa29bf7bdbc0e7 100644 (file)
@@ -58,7 +58,7 @@ vector<string> TinyDNSBackend::getLocations()
   for (int i = 4; i >= 0; i--) {
     string searchkey(key, i + 2);
     try {
-      auto reader = std::unique_ptr<CDB>(new CDB(getArg("dbfile")));
+      auto reader = std::make_unique<CDB>(getArg("dbfile"));
       ret = reader->findall(searchkey);
     }
     catch (const std::exception& e) {
@@ -158,7 +158,7 @@ void TinyDNSBackend::getAllDomains(vector<DomainInfo>* domains, bool getSerial,
   d_dnspacket = NULL;
 
   try {
-    d_cdbReader = std::unique_ptr<CDB>(new CDB(getArg("dbfile")));
+    d_cdbReader = std::make_unique<CDB>(getArg("dbfile"));
   }
   catch (const std::exception& e) {
     g_log << Logger::Error << e.what() << endl;
@@ -201,7 +201,7 @@ bool TinyDNSBackend::list(const DNSName& target, int domain_id, bool include_dis
   d_isGetDomains = false;
   string key = target.toDNSStringLC();
   try {
-    d_cdbReader = std::unique_ptr<CDB>(new CDB(getArg("dbfile")));
+    d_cdbReader = std::make_unique<CDB>(getArg("dbfile"));
   }
   catch (const std::exception& e) {
     g_log << Logger::Error << e.what() << endl;
@@ -231,7 +231,7 @@ void TinyDNSBackend::lookup(const QType& qtype, const DNSName& qdomain, int zone
   d_qtype = qtype;
 
   try {
-    d_cdbReader = std::unique_ptr<CDB>(new CDB(getArg("dbfile")));
+    d_cdbReader = std::make_unique<CDB>(getArg("dbfile"));
   }
   catch (const std::exception& e) {
     g_log << Logger::Error << e.what() << endl;
index eaabb9e09b62df2166315a4280a520449af171ca..01a1fff2cc3fa6fbb94dd571904c533f972a5e64 100644 (file)
@@ -429,7 +429,7 @@ try
   }
   else if(mode=="scan-ns") {
     ifstream ns(string(argv[2])+".nameservers");
-    g_powerdns = std::unique_ptr<ofstream>(new ofstream(string(argv[2])+".powerdns"));
+    g_powerdns = std::make_unique<std::ofstream>(string(argv[2]) + ".powerdns");
     string line;
     int count=0;
     vector<string> parts;
index c80607b5418033afbdacde9accab614ebd120c90..261de435b1bfb37d1576f7238a5df394d5267aa8 100644 (file)
@@ -647,7 +647,7 @@ void mainthread()
   Utility::dropUserPrivs(newuid);
 
   if(::arg().mustDo("resolver")){
-    DP=std::unique_ptr<DNSProxy>(new DNSProxy(::arg()["resolver"]));
+    DP = std::make_unique<DNSProxy>(::arg()["resolver"]);
     DP->go();
   }
 
index 385e30208900f2bac0816570cf6cd445082ca821..44dce8f7f313ba41916c72b767251b6855a9d536 100644 (file)
@@ -741,7 +741,7 @@ bool DNSSECKeeper::rectifyZone(const DNSName& zone, string& error, string& info,
     }
     // We don't have a *full* Ueberbackend, just a key-only one.
     // Let's create one and use it
-    b = std::unique_ptr<UeberBackend>(new UeberBackend());
+    b = std::make_unique<UeberBackend>();
     B = b.get();
   }
 
index 8671f54ca0f91f8f7bcda8b3acf74ae3ffce4a3e..0e2a29e1d5412f84074acfcb1d5ccdc4bc85dbae 100644 (file)
@@ -700,8 +700,8 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         }
 
         // only works pre-startup, so no sync necessary
-        g_frontends.push_back(std::unique_ptr<ClientState>(new ClientState(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus)));
-        auto tcpCS = std::unique_ptr<ClientState>(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        g_frontends.push_back(std::make_unique<ClientState>(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        auto tcpCS = std::make_unique<ClientState>(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus);
         if (tcpListenQueueSize > 0) {
           tcpCS->tcpListenQueueSize = tcpListenQueueSize;
         }
@@ -740,8 +740,8 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       try {
        ComboAddress loc(addr, 53);
         // only works pre-startup, so no sync necessary
-        g_frontends.push_back(std::unique_ptr<ClientState>(new ClientState(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus)));
-        auto tcpCS = std::unique_ptr<ClientState>(new ClientState(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        g_frontends.push_back(std::make_unique<ClientState>(loc, false, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        auto tcpCS = std::make_unique<ClientState>(loc, true, reusePort, tcpFastOpenQueueSize, interface, cpus);
         if (tcpListenQueueSize > 0) {
           tcpCS->tcpListenQueueSize = tcpListenQueueSize;
         }
@@ -1517,13 +1517,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
         auto ctx = std::make_shared<DNSCryptContext>(providerName, certKeys);
 
         /* UDP */
-        auto cs = std::unique_ptr<ClientState>(new ClientState(ComboAddress(addr, 443), false, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        auto cs = std::make_unique<ClientState>(ComboAddress(addr, 443), false, reusePort, tcpFastOpenQueueSize, interface, cpus);
         cs->dnscryptCtx = ctx;
         g_dnsCryptLocals.push_back(ctx);
         g_frontends.push_back(std::move(cs));
 
         /* TCP */
-        cs = std::unique_ptr<ClientState>(new ClientState(ComboAddress(addr, 443), true, reusePort, tcpFastOpenQueueSize, interface, cpus));
+        cs = std::make_unique<ClientState>(ComboAddress(addr, 443), true, reusePort, tcpFastOpenQueueSize, interface, cpus);
         cs->dnscryptCtx = ctx;
         if (tcpListenQueueSize > 0) {
           cs->tcpListenQueueSize = tcpListenQueueSize;
@@ -2335,7 +2335,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       parseTLSConfig(frontend->d_tlsConfig, "addDOHLocal", vars);
     }
     g_dohlocals.push_back(frontend);
-    auto cs = std::unique_ptr<ClientState>(new ClientState(frontend->d_local, true, reusePort, tcpFastOpenQueueSize, interface, cpus));
+    auto cs = std::make_unique<ClientState>(frontend->d_local, true, reusePort, tcpFastOpenQueueSize, interface, cpus);
     cs->dohFrontend = frontend;
     if (tcpListenQueueSize > 0) {
       cs->tcpListenQueueSize = tcpListenQueueSize;
@@ -2527,7 +2527,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
 #endif
           }
           // only works pre-startup, so no sync necessary
-          auto cs = std::unique_ptr<ClientState>(new ClientState(frontend->d_addr, true, reusePort, tcpFastOpenQueueSize, interface, cpus));
+          auto cs = std::make_unique<ClientState>(frontend->d_addr, true, reusePort, tcpFastOpenQueueSize, interface, cpus);
           cs->tlsFrontend = frontend;
           if (tcpListenQueueSize > 0) {
             cs->tcpListenQueueSize = tcpListenQueueSize;
index adff0b6ac9459e7bd13b9de2669ebd0ca3d5c760..0ee4f22be90ca7a3f7ab85da8816d3b4623b2c77 100644 (file)
@@ -84,7 +84,7 @@ struct Rings {
 
     /* resize all the rings */
     for (auto& shard : d_shards) {
-      shard = std::unique_ptr<Shard>(new Shard());
+      shard = std::make_unique<Shard>();
       shard->queryRing.lock()->set_capacity(newCapacity / numberOfShards);
       shard->respRing.lock()->set_capacity(newCapacity / numberOfShards);
     }
index 94286c507d93d49222eaaf426c1c8f054fe2bfbe..a82247f4c254410594a5018b0fa2f3f4fc8c5801 100644 (file)
@@ -1594,9 +1594,9 @@ static void MultipleMessagesUDPClientThread(ClientState* cs, LocalHolders& holde
   };
   const size_t vectSize = g_udpVectorSize;
 
-  auto recvData = std::unique_ptr<MMReceiver[]>(new MMReceiver[vectSize]);
-  auto msgVec = std::unique_ptr<struct mmsghdr[]>(new struct mmsghdr[vectSize]);
-  auto outMsgVec = std::unique_ptr<struct mmsghdr[]>(new struct mmsghdr[vectSize]);
+  auto recvData = std::make_unique<MMReceiver[]>(vectSize);
+  auto msgVec = std::make_unique<struct mmsghdr[]>(vectSize);
+  auto outMsgVec = std::make_unique<struct mmsghdr[]>(vectSize);
 
   /* the actual buffer is larger because:
      - we may have to add EDNS and/or ECS
index ead0e1096553fad8e163e306f4543309fcbe2eed..c2b6272ac4a058b8837ced825e8108d46854963c 100644 (file)
@@ -190,7 +190,7 @@ CDBKVStore::~CDBKVStore() {
 
 bool CDBKVStore::reload(const struct stat& st)
 {
-  auto newCDB = std::unique_ptr<CDB>(new CDB(d_fname));
+  auto newCDB = std::make_unique<CDB>(d_fname);
   {
     *(d_cdb.write_lock()) = std::move(newCDB);
   }
index 0b46a1a89bf6af24a7150bd9d302fa7d17225c19..c1d83c2543ad3f73180324241dfdad846f486c17 100644 (file)
@@ -823,7 +823,7 @@ static void doh_dispatch_query(DOHServerConfig* dsc, h2o_handler_t* self, h2o_re
     uint16_t qtype;
     DNSName qname(reinterpret_cast<const char*>(query.data()), query.size(), sizeof(dnsheader), false, &qtype);
 
-    auto du = std::unique_ptr<DOHUnit>(new DOHUnit);
+    auto du = std::make_unique<DOHUnit>();
     du->dsc = dsc;
     du->req = req;
     du->ids.origDest = local;
@@ -1440,7 +1440,7 @@ static void setupTLSContext(DOHAcceptContext& acceptCtx,
   auto ctx = libssl_init_server_context(tlsConfig, acceptCtx.d_ocspResponses);
 
   if (tlsConfig.d_enableTickets && tlsConfig.d_numberOfTicketsKeys > 0) {
-    acceptCtx.d_ticketKeys = std::unique_ptr<OpenSSLTLSTicketKeysRing>(new OpenSSLTLSTicketKeysRing(tlsConfig.d_numberOfTicketsKeys));
+    acceptCtx.d_ticketKeys = std::make_unique<OpenSSLTLSTicketKeysRing>(tlsConfig.d_numberOfTicketsKeys);
     SSL_CTX_set_tlsext_ticket_key_cb(ctx.get(), &ticket_key_callback);
     libssl_set_ticket_key_callback_data(ctx.get(), &acceptCtx);
   }
index bc013bd0892e7cc7e4df6775c2cb41006c28cf1e..cc21b1f3b28fc15bf1cb52b03ff00ae626267480 100644 (file)
@@ -354,11 +354,11 @@ BOOST_AUTO_TEST_CASE(test_LMDB) {
     transaction->commit();
   }
 
-  auto lmdb = std::unique_ptr<KeyValueStore>(new LMDBKVStore(dbPath, "db-name"));
+  std::unique_ptr<KeyValueStore> lmdb = std::make_unique<LMDBKVStore>(dbPath, "db-name");
   doKVSChecks(lmdb, lc, rem, dq, plaintextDomain);
   lmdb.reset();
 
-  lmdb = std::unique_ptr<KeyValueStore>(new LMDBKVStore(dbPath, "range-db-name"));
+  lmdb = std::make_unique<LMDBKVStore>(dbPath, "range-db-name");
   doKVSRangeChecks(lmdb);
   /*
   std::string value;
@@ -414,7 +414,7 @@ BOOST_AUTO_TEST_CASE(test_CDB) {
     writer.close();
   }
 
-  auto cdb = std::unique_ptr<KeyValueStore>(new CDBKVStore(db, 0));
+  std::unique_ptr<KeyValueStore> cdb = std::make_unique<CDBKVStore>(db, 0);
   doKVSChecks(cdb, lc, rem, dq, plaintextDomain);
 
   /*
index e26e0a9075898cac80bf0ceb3b573ff80501321f..969fc7c98f46a9a3ebe202320865d2a45f3062dc 100644 (file)
@@ -664,7 +664,7 @@ struct TestFixture
   {
     s_steps.clear();
     s_responses.clear();
-    s_mplexer = std::unique_ptr<FDMultiplexer>(new MockupFDMultiplexer());
+    s_mplexer = std::make_unique<MockupFDMultiplexer>();
   }
   ~TestFixture()
   {
index 3a2f6d1fba7802262bc0eb417cf43e4cfc87475a..7f0a057437a20c644e0fc3f6c687839e6b6c706c 100644 (file)
@@ -595,7 +595,7 @@ public:
   NSECBitmap(const NSECBitmap& rhs): d_set(rhs.d_set)
   {
     if (rhs.d_bitset) {
-      d_bitset = std::unique_ptr<std::bitset<nbTypes>>(new std::bitset<nbTypes>(*(rhs.d_bitset)));
+      d_bitset = std::make_unique<std::bitset<nbTypes>>(*(rhs.d_bitset));
     }
   }
   NSECBitmap& operator=(const NSECBitmap& rhs)
@@ -603,7 +603,7 @@ public:
     d_set = rhs.d_set;
 
     if (rhs.d_bitset) {
-      d_bitset = std::unique_ptr<std::bitset<nbTypes>>(new std::bitset<nbTypes>(*(rhs.d_bitset)));
+      d_bitset = std::make_unique<std::bitset<nbTypes>>(*(rhs.d_bitset));
     }
 
     return *this;
@@ -652,7 +652,7 @@ private:
 
   void migrateToBitSet()
   {
-    d_bitset = std::unique_ptr<std::bitset<nbTypes>>(new std::bitset<nbTypes>());
+    d_bitset = std::make_unique<std::bitset<nbTypes>>();
     for (const auto& type : d_set) {
       d_bitset->set(type);
     }
index 061e04a68c6aa9bcfa11a83d06cf84da1ba87673..dd6e2ca2cbd4ae8481e46d3eb8ef353062313bd2 100644 (file)
@@ -224,8 +224,8 @@ try
     PcapPacketReader pr(files[fno]);
     std::unique_ptr<PcapPacketWriter> pw=nullptr;
     if(!g_vm["write-failures"].as<string>().empty())
-      pw=std::unique_ptr<PcapPacketWriter>(new PcapPacketWriter(g_vm["write-failures"].as<string>(), pr));
+      pw = std::make_unique<PcapPacketWriter>(g_vm["write-failures"].as<string>(), pr);
+
     EDNSOpts edo;
     while(pr.getUDPPacket()) {
 
index aa461ac18d96b27cc7cd54ce5f73a7b47a8cc104..51f1e8b3cefd2f2854dbe059b01f582f898f4659 100644 (file)
@@ -134,7 +134,7 @@ try
     throw PDNSException("tcp read failed");
   
   len=ntohs(len);
-  std::unique_ptr<char[]> creply(new char[len]);
+  auto creply = std::make_unique<char[]>(len);
   int n=0;
   int numread;
   while(n<len) {
index 62142228616dee05f5ba7e76585af6aec9580544..c9d09d7a4ca16a969141a8cbbfc402cd0be26c61 100644 (file)
@@ -73,7 +73,7 @@ public:
 
   static std::unique_ptr<IPObfuscator> make()
   {
-    return std::unique_ptr<IPObfuscator>(new IPSeqObfuscator());
+    return std::make_unique<IPSeqObfuscator>();
   }
 
   uint32_t obf4(uint32_t orig) override
@@ -133,7 +133,7 @@ public:
   {}
   static std::unique_ptr<IPObfuscator> make(std::string key, bool decrypt)
   {
-    return std::unique_ptr<IPObfuscator>(new IPCipherObfuscator(key, decrypt));
+    return std::make_unique<IPCipherObfuscator>(key, decrypt);
   }
 
   uint32_t obf4(uint32_t orig) override
index 91596a62d52c69001961658adf5905b6ff82de35..efbde189b568ab1dae444c3c61f24de57fb11fb9 100644 (file)
@@ -25,8 +25,8 @@
 #include "iputils.hh"
 #include "ixfrdist-stats.hh"
 
-IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl, const string &loglevel) :
-  d_ws(std::unique_ptr<WebServer>(new WebServer(listenAddress.toString(), listenAddress.getPort())))
+IXFRDistWebServer::IXFRDistWebServer(const ComboAddress& listenAddress, const NetmaskGroup& acl, const string& loglevel) :
+  d_ws(std::make_unique<WebServer>(listenAddress.toString(), listenAddress.getPort()))
 {
   d_ws->setACL(acl);
   d_ws->setLogLevel(loglevel);
index efbf71257a27edb4fb6db6e306c4728ae358326f..8c8d46fc9402b27e3e7d98547e96bbe0810c6e69 100644 (file)
@@ -37,7 +37,7 @@ void BaseLua4::loadString(const std::string &script) {
 void BaseLua4::getFeatures(Features &) { }
 
 void BaseLua4::prepareContext() {
-  d_lw = std::unique_ptr<LuaContext>(new LuaContext);
+  d_lw = std::make_unique<LuaContext>();
 
   // lua features available
   Features features;
index 2c75a15979dc47afa56f32ec3cc550ee849e98bb..dfa118a6fbafaa82b116f44dc835c13dc597bc2a 100644 (file)
@@ -229,7 +229,7 @@ private:
 bool IsUpOracle::isUp(const CheckDesc& cd)
 {
   if (!d_checkerThread) {
-    d_checkerThread = std::unique_ptr<std::thread>(new std::thread(&IsUpOracle::checkThread, this));
+    d_checkerThread = std::make_unique<std::thread>([this] { return checkThread(); });
   }
   time_t now = time(nullptr);
   {
@@ -248,7 +248,7 @@ bool IsUpOracle::isUp(const CheckDesc& cd)
     auto statuses = d_statuses.write_lock();
     // Make sure we don't insert new entry twice now we have the lock
     if (statuses->find(cd) == statuses->end()) {
-      (*statuses)[cd] = std::unique_ptr<CheckState>(new CheckState{now});
+      (*statuses)[cd] = std::make_unique<CheckState>(now);
     }
   }
   return false;
@@ -972,7 +972,7 @@ std::vector<shared_ptr<DNSRecordContent>> luaSynth(const std::string& code, cons
 
   LuaContext& lua = *s_LUA->getLua();
 
-  s_lua_record_ctx = std::unique_ptr<lua_record_ctx_t>(new lua_record_ctx_t());
+  s_lua_record_ctx = std::make_unique<lua_record_ctx_t>();
   s_lua_record_ctx->qname = query;
   s_lua_record_ctx->zone = zone;
   s_lua_record_ctx->zoneid = zoneid;
index b77d98418a2303e04499d711c73f123202bedbff..841eb55585077dff06c36131873dfe456d4a3829 100644 (file)
@@ -728,7 +728,7 @@ RecursorLua4::~RecursorLua4() {}
 const char* pdns_ffi_param_get_qname(pdns_ffi_param_t* ref)
 {
   if (!ref->qnameStr) {
-    ref->qnameStr = std::unique_ptr<std::string>(new std::string(ref->params.qname.toStringNoDot()));
+    ref->qnameStr = std::make_unique<std::string>(ref->params.qname.toStringNoDot());
   }
 
   return ref->qnameStr->c_str();
@@ -749,7 +749,7 @@ uint16_t pdns_ffi_param_get_qtype(const pdns_ffi_param_t* ref)
 const char* pdns_ffi_param_get_remote(pdns_ffi_param_t* ref)
 {
   if (!ref->remoteStr) {
-    ref->remoteStr = std::unique_ptr<std::string>(new std::string(ref->params.remote.toString()));
+    ref->remoteStr = std::make_unique<std::string>(ref->params.remote.toString());
   }
 
   return ref->remoteStr->c_str();
@@ -780,7 +780,7 @@ uint16_t pdns_ffi_param_get_remote_port(const pdns_ffi_param_t* ref)
 const char* pdns_ffi_param_get_local(pdns_ffi_param_t* ref)
 {
   if (!ref->localStr) {
-    ref->localStr = std::unique_ptr<std::string>(new std::string(ref->params.local.toString()));
+    ref->localStr = std::make_unique<std::string>(ref->params.local.toString());
   }
 
   return ref->localStr->c_str();
@@ -803,7 +803,7 @@ const char* pdns_ffi_param_get_edns_cs(pdns_ffi_param_t* ref)
   }
 
   if (!ref->ednssubnetStr) {
-    ref->ednssubnetStr = std::unique_ptr<std::string>(new std::string(ref->params.ednssubnet.toStringNoMask()));
+    ref->ednssubnetStr = std::make_unique<std::string>(ref->params.ednssubnet.toStringNoMask());
   }
 
   return ref->ednssubnetStr->c_str();
index 1caf49ff5193cf1e4ac92a9dac66bf15c4e3a961..13dcdf057194d9025c1df5826f7af0e2ac2ddd8f 100644 (file)
@@ -142,7 +142,7 @@ try
     throw PDNSException("tcp read failed");
 
   len=ntohs(len);
-  std::unique_ptr<char[]> creply(new char[len]);
+  auto creply = std::make_unique<char[]>(len);
   int n=0;
   int numread;
   while(n<len) {
index 25fb63a31c59bbb37cd7d7b02d496c44160732a3..d59f7881dd65a4e7f4ea6063169099a5a140c6eb 100644 (file)
@@ -76,7 +76,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
   }
   else
   {
-    d_pdl = std::unique_ptr<AuthLua4>(new AuthLua4());
+    d_pdl = std::make_unique<AuthLua4>();
     d_pdl->loadFile(fname);
   }
   fname = ::arg()["lua-dnsupdate-policy-script"];
@@ -86,7 +86,7 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
   }
   else
   {
-    d_update_policy_lua = std::unique_ptr<AuthLua4>(new AuthLua4());
+    d_update_policy_lua = std::make_unique<AuthLua4>();
     d_update_policy_lua->loadFile(fname);
   }
 }
index 2070bd054a8ed0bb43f828e1e1fb950825f37fe2..39ba53896eb8c1483a1ece0be65d952e20bfcd1d 100644 (file)
@@ -2733,7 +2733,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
       conn->state = TCPConnection::BYTE0;
       std::unique_ptr<DNSComboWriter> dc;
       try {
-        dc=std::unique_ptr<DNSComboWriter>(new DNSComboWriter(conn->data, g_now));
+        dc = std::make_unique<DNSComboWriter>(conn->data, g_now);
       }
       catch(const MOADNSException &mde) {
         g_stats.clientParseError++;
@@ -3220,7 +3220,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
     return 0;
   }
 
-  auto dc = std::unique_ptr<DNSComboWriter>(new DNSComboWriter(question, g_now, std::move(policyTags), std::move(data), std::move(records)));
+  auto dc = std::make_unique<DNSComboWriter>(question, g_now, std::move(policyTags), std::move(data), std::move(records));
   dc->setSocket(fd);
   dc->d_tag=ctag;
   dc->d_qhash=qhash;
@@ -5525,8 +5525,8 @@ try
   SyncRes tmp(g_now); // make sure it allocates tsstorage before we do anything, like primeHints or so..
   SyncRes::setDomainMap(g_initialDomainMap);
   t_allowFrom = g_initialAllowFrom;
-  t_udpclientsocks = std::unique_ptr<UDPClientSocks>(new UDPClientSocks());
-  t_tcpClientCounts = std::unique_ptr<tcpClientCounts_t>(new tcpClientCounts_t());
+  t_udpclientsocks = std::make_unique<UDPClientSocks>();
+  t_tcpClientCounts = std::make_unique<tcpClientCounts_t>();
 
   if (threadInfo.isHandler) {
     if (!primeHints()) {
@@ -5538,8 +5538,7 @@ try
     g_log<<Logger::Warning<<"Done priming cache with root hints"<<endl;
   }
 
-  t_packetCache = std::unique_ptr<RecursorPacketCache>(new RecursorPacketCache());
-
+  t_packetCache = std::make_unique<RecursorPacketCache>();
 
 #ifdef NOD_ENABLED
   if (threadInfo.isWorker)
@@ -5563,25 +5562,25 @@ try
 
   unsigned int ringsize=::arg().asNum("stats-ringbuffer-entries") / g_numWorkerThreads;
   if(ringsize) {
-    t_remotes = std::unique_ptr<addrringbuf_t>(new addrringbuf_t());
+    t_remotes = std::make_unique<addrringbuf_t>();
     if(g_weDistributeQueries)
       t_remotes->set_capacity(::arg().asNum("stats-ringbuffer-entries") / g_numDistributorThreads);
     else
       t_remotes->set_capacity(ringsize);
-    t_servfailremotes = std::unique_ptr<addrringbuf_t>(new addrringbuf_t());
+    t_servfailremotes = std::make_unique<addrringbuf_t>();
     t_servfailremotes->set_capacity(ringsize);
-    t_bogusremotes = std::unique_ptr<addrringbuf_t>(new addrringbuf_t());
+    t_bogusremotes = std::make_unique<addrringbuf_t>();
     t_bogusremotes->set_capacity(ringsize);
-    t_largeanswerremotes = std::unique_ptr<addrringbuf_t>(new addrringbuf_t());
+    t_largeanswerremotes = std::make_unique<addrringbuf_t>();
     t_largeanswerremotes->set_capacity(ringsize);
-    t_timeouts = std::unique_ptr<addrringbuf_t>(new addrringbuf_t());
+    t_timeouts = std::make_unique<addrringbuf_t>();
     t_timeouts->set_capacity(ringsize);
 
-    t_queryring = std::unique_ptr<boost::circular_buffer<pair<DNSName, uint16_t> > >(new boost::circular_buffer<pair<DNSName, uint16_t> >());
+    t_queryring = std::make_unique<boost::circular_buffer<pair<DNSName, uint16_t>>>();
     t_queryring->set_capacity(ringsize);
-    t_servfailqueryring = std::unique_ptr<boost::circular_buffer<pair<DNSName, uint16_t> > >(new boost::circular_buffer<pair<DNSName, uint16_t> >());
+    t_servfailqueryring = std::make_unique<boost::circular_buffer<pair<DNSName, uint16_t>>>();
     t_servfailqueryring->set_capacity(ringsize);
-    t_bogusqueryring = std::unique_ptr<boost::circular_buffer<pair<DNSName, uint16_t> > >(new boost::circular_buffer<pair<DNSName, uint16_t> >());
+    t_bogusqueryring = std::make_unique<boost::circular_buffer<pair<DNSName, uint16_t>>>();
     t_bogusqueryring->set_capacity(ringsize);
   }
   MT = std::make_unique<MT_t>(::arg().asNum("stack-size"));
@@ -6121,8 +6120,8 @@ int main(int argc, char **argv)
       cout<<::arg().helpstring(::arg()["help"])<<endl;
       exit(0);
     }
-    g_recCache = std::unique_ptr<MemRecursorCache>(new MemRecursorCache(::arg().asNum("record-cache-shards")));
-    g_negCache = std::unique_ptr<NegCache>(new NegCache(::arg().asNum("record-cache-shards")));
+    g_recCache = std::make_unique<MemRecursorCache>(::arg().asNum("record-cache-shards"));
+    g_negCache = std::make_unique<NegCache>(::arg().asNum("record-cache-shards"));
 
     g_quiet=::arg().mustDo("quiet");
     Logger::Urgency logUrgency = (Logger::Urgency)::arg().asNum("loglevel");
index 4d79d3a2f15cbad191d2137c44a60b7b8805de6f..3024fc435a726c76319a1935009600d9ca684316 100644 (file)
@@ -151,7 +151,7 @@ public:
 // this bit is used for getting attribute from object
 // we provide a pointer for GetAttributeValue to write to
   CK_BYTE_PTR allocate(CK_ULONG amount) {
-    buffer = std::unique_ptr<unsigned char[]>(new unsigned char[amount]);
+    buffer = std::make_unique<unsigned char[]>(amount);
     buflen = amount;
     return buffer.get();
   }
@@ -249,7 +249,7 @@ class Pkcs11Slot {
     bool Login(const std::string& pin) {
       if (d_logged_in) return true;
 
-      std::unique_ptr<unsigned char[]> uPin(new unsigned char[pin.size()]);
+      auto uPin = std::make_unique<unsigned char[]>(pin.size());
       memcpy(uPin.get(), pin.c_str(), pin.size());
       d_err = d_functions->C_Login(this->d_session, CKU_USER, uPin.get(), pin.size());
       memset(uPin.get(), 0, pin.size());
@@ -415,8 +415,8 @@ class Pkcs11Token {
       auto slot = d_slot->lock();
 
       size_t k;
-      std::unique_ptr<CK_ATTRIBUTE[]> pubAttr(new CK_ATTRIBUTE[pubAttributes.size()]);
-      std::unique_ptr<CK_ATTRIBUTE[]> privAttr(new CK_ATTRIBUTE[privAttributes.size()]);
+      auto pubAttr = std::make_unique<CK_ATTRIBUTE[]>(pubAttributes.size());
+      auto privAttr = std::make_unique<CK_ATTRIBUTE[]>(pubAttributes.size());
 
       k = 0;
       for(P11KitAttribute& attribute :  pubAttributes) {
@@ -530,8 +530,8 @@ class Pkcs11Token {
       size_t k;
       unsigned long count;
 
-      std::unique_ptr<CK_OBJECT_HANDLE[]> handles(new CK_OBJECT_HANDLE[maxobjects]);
-      std::unique_ptr<CK_ATTRIBUTE[]> attr(new CK_ATTRIBUTE[attributes.size()]);
+      auto handles = std::make_unique<CK_OBJECT_HANDLE[]>(maxobjects);
+      auto attr = std::make_unique<CK_ATTRIBUTE[]>(attributes.size());
 
       k = 0;
       for(const P11KitAttribute& attribute :  attributes) {
@@ -568,7 +568,7 @@ class Pkcs11Token {
     int GetAttributeValue2(Pkcs11Slot& slot, const CK_OBJECT_HANDLE& object, std::vector<P11KitAttribute>& attributes)
     {
       size_t k;
-      std::unique_ptr<CK_ATTRIBUTE[]> attr(new CK_ATTRIBUTE[attributes.size()]);
+      auto attr = std::make_unique<CK_ATTRIBUTE[]>(attributes.size());
 
       k = 0;
       for(P11KitAttribute &attribute :  attributes) {
index d818ad5d6f9adccccbd78e4bb852cce34926b1fc..e5e67854d31e200bb29132ae23053f6034377c36 100644 (file)
@@ -583,8 +583,8 @@ int main(int argc, char **argv)
       if(::arg().mustDo("control-console"))
         dl=make_unique<DynListener>();
       else
-        dl=std::unique_ptr<DynListener>(new DynListener(s_programname));
-      
+        dl = std::make_unique<DynListener>(s_programname);
+
       writePid();
     }
     DynListener::registerFunc("SHOW",&DLShowHandler, "show a specific statistic or * to get a list", "<statistic>");
index ee5c7b4375848d03e45bad226266f111ce6abc29..3fc14cce8986effc9eda984bcf9bf0877cae6a4d 100644 (file)
@@ -126,7 +126,7 @@ public:
     if (bitstr_len > 2 * 64 * 1024 * 1024U) { // twice the current size
       throw std::runtime_error("SBF: read failed (bitstr_len too big)");
     }
-    unique_ptr<char[]> bitcstr = make_unique<char[]>(bitstr_len);
+    auto bitcstr = std::make_unique<char[]>(bitstr_len);
     is.read(bitcstr.get(), bitstr_len);
     if (is.fail()) {
       throw std::runtime_error("SBF: read failed (file too short?)");
index d771674ada4df943e5c93bdad34667036207ac92..3dde7d1237a662b7b11219621db08a397f8fba37 100644 (file)
@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(test_zonetocache)
   config.d_refreshPeriod = 0;
 
   // Start with a new, empty cache
-  g_recCache = std::unique_ptr<MemRecursorCache>(new MemRecursorCache());
+  g_recCache = std::make_unique<MemRecursorCache>();
   BOOST_CHECK_EQUAL(g_recCache->size(), 0U);
   RecZoneToCache::ZoneToCache(config, 0);
   unlink(temp);
index a18e206d99c73f4e9f98e8dbcfdf9918e6222aa8..8836275b18b8d180a9f099d27c033f60cf0fc3a1 100644 (file)
@@ -14,8 +14,8 @@ GlobalStateHolder<SuffixMatchNode> g_xdnssec;
 GlobalStateHolder<SuffixMatchNode> g_dontThrottleNames;
 GlobalStateHolder<NetmaskGroup> g_dontThrottleNetmasks;
 GlobalStateHolder<SuffixMatchNode> g_DoTToAuthNames;
-std::unique_ptr<MemRecursorCache> g_recCache{nullptr};
-std::unique_ptr<NegCache> g_negCache{nullptr};
+std::unique_ptr<MemRecursorCache> g_recCache;
+std::unique_ptr<NegCache> g_negCache;
 unsigned int g_numThreads = 1;
 bool g_lowercaseOutgoing = false;
 
@@ -82,9 +82,9 @@ bool primeHints(time_t now)
 {
   vector<DNSRecord> nsset;
   if (!g_recCache)
-    g_recCache = std::unique_ptr<MemRecursorCache>(new MemRecursorCache());
+    g_recCache = std::make_unique<MemRecursorCache>();
   if (!g_negCache)
-    g_negCache = std::unique_ptr<NegCache>(new NegCache());
+    g_negCache = std::make_unique<NegCache>();
 
   DNSRecord arr, aaaarr, nsrr;
   nsrr.d_name = g_rootdnsname;
@@ -142,8 +142,8 @@ void initSR(bool debug)
     g_log.toConsole(Logger::Error);
   }
 
-  g_recCache = std::unique_ptr<MemRecursorCache>(new MemRecursorCache());
-  g_negCache = std::unique_ptr<NegCache>(new NegCache());
+  g_recCache = std::make_unique<MemRecursorCache>();
+  g_negCache = std::make_unique<NegCache>();
 
   SyncRes::s_maxqperq = 50;
   SyncRes::s_maxnsaddressqperq = 10;
@@ -227,7 +227,7 @@ void initSR(std::unique_ptr<SyncRes>& sr, bool dnssec, bool debug, time_t fakeNo
 
   initSR(debug);
 
-  sr = std::unique_ptr<SyncRes>(new SyncRes(now));
+  sr = std::make_unique<SyncRes>(now);
   sr->setDoEDNS0(true);
   if (dnssec) {
     sr->setDoDNSSEC(dnssec);
index e18b41f39ea5804f3dd000ba4a969030be1cbd43..23358d9bc8e7a774474d9957a8eea33f2339bc64 100644 (file)
@@ -927,8 +927,8 @@ BOOST_AUTO_TEST_CASE(test_dnssec_bogus_dnskey_doesnt_match_ds)
 
   /* === first without validation, then with (just-in-time validation) === */
   /* clear the caches */
-  g_recCache = std::unique_ptr<MemRecursorCache>(new MemRecursorCache());
-  g_negCache = std::unique_ptr<NegCache>(new NegCache());
+  g_recCache = std::make_unique<MemRecursorCache>();
+  g_negCache = std::make_unique<NegCache>();
   sr->setDNSSECValidationRequested(false);
   primeHints();
 
index 5cde2e88f344809f0be7f26be5f36dabeab4dfdc..6377008645d0293c0172b3d6b1c3be8b1092cc0f 100644 (file)
@@ -228,7 +228,7 @@ namespace pdns {
 
 bool Resolver::tryGetSOASerial(DNSName *domain, ComboAddress* remote, uint32_t *theirSerial, uint32_t *theirInception, uint32_t *theirExpire, uint16_t* id)
 {
-  auto fds = std::unique_ptr<struct pollfd[]>(new struct pollfd[locals.size()]);
+  auto fds = std::make_unique<struct pollfd[]>(locals.size());
   size_t i = 0, k;
   int sock;
 
index 20e677a9efb18d75dfb627799ab26285db422129..ef0761e5edd15012099ac62f223722483bd93048 100644 (file)
@@ -112,7 +112,7 @@ try
       throw PDNSException("tcp read failed");
 
     len=ntohs(len);
-    std::unique_ptr<char[]> creply(new char[len]);
+    auto creply = std::make_unique<char[]>(len);
     int n=0;
     int numread;
     while(n<len) {
index 8c015da1e8b0ba613ad7e19996c93e9125a417fd..90ed36fb122dc7675de548d6ead2f07bbca34964 100644 (file)
@@ -79,7 +79,7 @@ void SodiumED25519DNSCryptoKeyEngine::fromISCMap(DNSKEYRecordContent& drc, std::
   if (privateKey.length() != crypto_sign_ed25519_SEEDBYTES)
     throw runtime_error("Seed size mismatch in ISCMap, SodiumED25519 class");
 
-  std::unique_ptr<unsigned char[]> seed(new unsigned char[crypto_sign_ed25519_SEEDBYTES]);
+  auto seed = std::make_unique<unsigned char[]>(crypto_sign_ed25519_SEEDBYTES);
 
   memcpy(seed.get(), privateKey.c_str(), crypto_sign_ed25519_SEEDBYTES);
   crypto_sign_ed25519_seed_keypair(d_pubkey, d_seckey, seed.get());
@@ -106,7 +106,7 @@ void SodiumED25519DNSCryptoKeyEngine::fromPublicKeyString(const std::string& inp
 std::string SodiumED25519DNSCryptoKeyEngine::sign(const std::string& msg) const
 {
   unsigned long long smlen = msg.length() + crypto_sign_ed25519_BYTES;
-  std::unique_ptr<unsigned char[]> sm(new unsigned char[smlen]);
+  auto sm = std::make_unique<unsigned char[]>(smlen);
 
   crypto_sign_ed25519(sm.get(), &smlen, (const unsigned char*)msg.c_str(), msg.length(), d_seckey);
 
@@ -119,12 +119,12 @@ bool SodiumED25519DNSCryptoKeyEngine::verify(const std::string& msg, const std::
     return false;
 
   unsigned long long smlen = msg.length() + crypto_sign_ed25519_BYTES;
-  std::unique_ptr<unsigned char[]> sm(new unsigned char[smlen]);
+  auto sm = std::make_unique<unsigned char[]>(smlen);
 
   memcpy(sm.get(), signature.c_str(), crypto_sign_ed25519_BYTES);
   memcpy(sm.get() + crypto_sign_ed25519_BYTES, msg.c_str(), msg.length());
 
-  std::unique_ptr<unsigned char[]> m(new unsigned char[smlen]);
+  auto m = std::make_unique<unsigned char[]>(smlen);
 
   return crypto_sign_ed25519_open(m.get(), &smlen, sm.get(), smlen, d_pubkey) == 0;
 }
index 8602f162ff513bb02bf760104c63bd70f08b7888..c2c96ebea7b8bc23700726e832c099c21cf28d3c 100644 (file)
@@ -229,7 +229,7 @@ SSQLite3::~SSQLite3()
 }
 
 std::unique_ptr<SSqlStatement> SSQLite3::prepare(const string& query, int nparams __attribute__((unused))) {
-  return std::unique_ptr<SSqlStatement>(new SSQLite3Statement(this, m_dolog, query));
+  return std::make_unique<SSQLite3Statement>(this, m_dolog, query);
 }
 
 void SSQLite3::execute(const string& query) {
index 50a669bf86882d312e90ac03141eb1c28030f19a..5b14e234e60cd768bb814ccb2da375ea67d4fc5e 100644 (file)
@@ -99,7 +99,7 @@ public:
       throw NetworkError("Accepting a connection: "+stringerror());
     }
 
-    return std::unique_ptr<Socket>(new Socket(s));
+    return std::make_unique<Socket>(s);
   }
 
   //! Get remote address
index d5b84f37ddb396a7db339b947d775d8a960fde4d..495dd5d33727519719a6de395e3cdced37e4d163 100644 (file)
@@ -428,14 +428,14 @@ public:
   static void addDontQuery(const std::string& mask)
   {
     if (!s_dontQuery)
-      s_dontQuery = std::unique_ptr<NetmaskGroup>(new NetmaskGroup());
+      s_dontQuery = std::make_unique<NetmaskGroup>();
 
     s_dontQuery->addMask(mask);
   }
   static void addDontQuery(const Netmask& mask)
   {
     if (!s_dontQuery)
-      s_dontQuery = std::unique_ptr<NetmaskGroup>(new NetmaskGroup());
+      s_dontQuery = std::make_unique<NetmaskGroup>();
 
     s_dontQuery->addMask(mask);
   }
@@ -906,8 +906,8 @@ private:
   ostringstream d_trace;
   shared_ptr<RecursorLua4> d_pdl;
   boost::optional<Netmask> d_outgoingECSNetwork;
-  std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>> d_outgoingProtobufServers{nullptr};
-  std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> d_frameStreamServers{nullptr};
+  std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>> d_outgoingProtobufServers;
+  std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> d_frameStreamServers;
   boost::optional<const boost::uuids::uuid&> d_initialRequestId;
   asyncresolve_t d_asyncResolve{nullptr};
   struct timeval d_now;
index 85409655d4d180c534cf8e7290772348737c9988..05d7dbeac6e93c7ead6c210185ce9c55bb666fd0 100644 (file)
@@ -478,7 +478,7 @@ public:
 
   void addNewTicket(SSL_SESSION* session)
   {
-    d_tlsSessions.push_back(std::unique_ptr<TLSSession>(new OpenSSLSession(std::unique_ptr<SSL_SESSION, void(*)(SSL_SESSION*)>(session, SSL_SESSION_free))));
+    d_tlsSessions.push_back(std::make_unique<OpenSSLSession>(std::unique_ptr<SSL_SESSION, void (*)(SSL_SESSION*)>(session, SSL_SESSION_free)));
   }
 
   static int s_tlsConnIndex;
@@ -1019,7 +1019,7 @@ public:
     if (ret != GNUTLS_E_SUCCESS || sess.size <= 4) {
       throw std::runtime_error("Error getting GnuTLSSession: " + std::string(gnutls_strerror(ret)));
     }
-    conn->d_tlsSessions.push_back(std::unique_ptr<TLSSession>(new GnuTLSSession(sess)));
+    conn->d_tlsSessions.push_back(std::make_unique<GnuTLSSession>(sess));
     return 0;
   }
 
index 7247531e66a3c21608bc4944dd195fc6259ec0d1..80a63291c28c9b41428fb69942f8a1a52ce01c7e 100644 (file)
@@ -56,7 +56,7 @@ public:
       throw PDNSException("EOF on TCP read");
 
     len=ntohs(len);
-    std::unique_ptr<char[]> creply(new char[len]);
+    auto creply = std::make_unique<char[]>(len);
     int n=0;
     int numread;
     while(n<len) {
index 603e6ae0850cbbac1a37d36509ef87b0d9ce4140..d1d06b037a20930713802e358f6a9f29b52374b8 100644 (file)
@@ -66,7 +66,7 @@ AuthWebServer::AuthWebServer() :
   d_min1(0)
 {
   if (arg().mustDo("webserver") || arg().mustDo("api")) {
-    d_ws = unique_ptr<WebServer>(new WebServer(arg()["webserver-address"], arg().asNum("webserver-port")));
+    d_ws = std::make_unique<WebServer>(arg()["webserver-address"], arg().asNum("webserver-port"));
     d_ws->setApiKey(arg()["api-key"], arg().mustDo("webserver-hash-plaintext-credentials"));
     d_ws->setPassword(arg()["webserver-password"], arg().mustDo("webserver-hash-plaintext-credentials"));
     d_ws->setLogLevel(arg()["webserver-loglevel"]);