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);
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
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
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)
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()
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()
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);
}
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) {
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();
// 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");
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) {
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;
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;
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;
}
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;
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();
}
}
// 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();
}
}
// 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;
}
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;
}
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;
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;
#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;
/* 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);
}
};
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
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);
}
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;
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);
}
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;
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);
/*
{
s_steps.clear();
s_responses.clear();
- s_mplexer = std::unique_ptr<FDMultiplexer>(new MockupFDMultiplexer());
+ s_mplexer = std::make_unique<MockupFDMultiplexer>();
}
~TestFixture()
{
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)
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;
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);
}
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()) {
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) {
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
{}
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
#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);
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;
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);
{
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;
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;
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();
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();
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();
}
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();
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) {
}
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"];
}
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);
}
}
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++;
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;
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()) {
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)
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"));
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");
// 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();
}
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());
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) {
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) {
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) {
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>");
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?)");
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);
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;
{
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;
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;
initSR(debug);
- sr = std::unique_ptr<SyncRes>(new SyncRes(now));
+ sr = std::make_unique<SyncRes>(now);
sr->setDoEDNS0(true);
if (dnssec) {
sr->setDoDNSSEC(dnssec);
/* === 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();
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;
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) {
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());
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);
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;
}
}
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) {
throw NetworkError("Accepting a connection: "+stringerror());
}
- return std::unique_ptr<Socket>(new Socket(s));
+ return std::make_unique<Socket>(s);
}
//! Get remote address
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);
}
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;
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;
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;
}
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) {
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"]);