BB2DomainInfo bbd;
if(safeGetBBDomainInfo(id, &bbd)) {
d_transaction_tmpname=bbd.d_filename+"."+itoa(random());
- d_of=new ofstream(d_transaction_tmpname.c_str());
+ d_of=std::unique_ptr<ofstream>(new ofstream(d_transaction_tmpname.c_str()));
if(!*d_of) {
unlink(d_transaction_tmpname.c_str());
- delete d_of;
- d_of=0;
+ d_of.reset();
throw DBException("Unable to open temporary zonefile '"+d_transaction_tmpname+"': "+stringerror());
}
{
if(d_transaction_id < 0)
return false;
- delete d_of;
- d_of=0;
+ d_of.reset();
BB2DomainInfo bbd;
if(safeGetBBDomainInfo(d_transaction_id, &bbd)) {
// 0 = invalid transact
// >0 = actual transaction
if(d_transaction_id > 0) {
- delete d_of;
- d_of=0;
unlink(d_transaction_tmpname.c_str());
+ d_of.reset();
d_transaction_id=0;
}
stripDomainSuffix(&content, name);
// fallthrough
default:
- *d_of<<qname<<"\t"<<rr.ttl<<"\t"<<rr.qtype.getName()<<"\t"<<content<<endl;
+ if (d_of && *d_of) {
+ *d_of<<qname<<"\t"<<rr.ttl<<"\t"<<rr.qtype.getName()<<"\t"<<content<<endl;
+ }
}
return true;
}
string d_transaction_tmpname;
string d_logprefix;
set<string> alsoNotify; //!< this is used to store the also-notify list of interested peers.
- ofstream *d_of;
+ std::unique_ptr<ofstream> d_of;
handle d_handle;
static string s_binddirectory; //!< this is used to store the 'directory' setting of the bind configuration
static int s_first; //!< this is raised on construction to prevent multiple instances of us being generated