Convert most 0/NULL pointers to nullptr

Courtesy of llvm cpp11-migrate 3.3
pull/119/head
Nils Maier 2013-08-20 18:57:17 +02:00
parent 9da17424c6
commit d8f44ef4f6
87 changed files with 253 additions and 253 deletions

View File

@ -45,11 +45,11 @@ AbstractBtMessage::AbstractBtMessage(uint8_t id, const char* name)
uploading_(false),
cuid_(0),
name_(name),
pieceStorage_(0),
dispatcher_(0),
messageFactory_(0),
requestFactory_(0),
peerConnection_(0),
pieceStorage_(nullptr),
dispatcher_(nullptr),
messageFactory_(nullptr),
requestFactory_(nullptr),
peerConnection_(nullptr),
metadataGetMode_(false)
{}

View File

@ -64,7 +64,7 @@ AbstractDiskWriter::AbstractDiskWriter(const std::string& filename)
#endif // !__MINGW32__
readOnly_(false),
enableMmap_(false),
mapaddr_(0),
mapaddr_(nullptr),
maplen_(0)
{}
@ -155,7 +155,7 @@ void AbstractDiskWriter::closeFile()
} else {
A2_LOG_INFO(fmt("Unmapping file %s succeeded", filename_.c_str()));
}
mapaddr_ = 0;
mapaddr_ = nullptr;
maplen_ = 0;
}
#endif // HAVE_MMAP || defined __MINGW32__
@ -356,7 +356,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
A2_LOG_ERROR(fmt("Unmapping file %s failed: %s",
filename_.c_str(), fileStrerror(errNum).c_str()));
}
mapaddr_ = 0;
mapaddr_ = nullptr;
maplen_ = 0;
enableMmap_ = false;
}
@ -381,7 +381,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
}
#else // !__MINGW32__
mapaddr_ = reinterpret_cast<unsigned char*>
(mmap(0, size(), PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
(mmap(nullptr, size(), PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0));
if(!mapaddr_) {
errNum = errno;
}

View File

@ -102,7 +102,7 @@ namespace {
std::string errToString(OSStatus err)
{
std::string rv = "Unkown error";
CFStringRef cerr = SecCopyErrorMessageString(err, 0);
CFStringRef cerr = SecCopyErrorMessageString(err, nullptr);
if (cerr) {
size_t len = CFStringGetLength(cerr) * 4;
char *buf = new char[len];
@ -118,7 +118,7 @@ namespace {
bool checkIdentity(const SecIdentityRef id, const std::string& fingerPrint,
const std::vector<std::string> supported)
{
SecCertificateRef ref = 0;
SecCertificateRef ref = nullptr;
if (SecIdentityCopyCertificate(id, &ref) != errSecSuccess) {
A2_LOG_ERROR("Failed to get a certref!");
return false;
@ -155,7 +155,7 @@ AppleTLSContext::~AppleTLSContext()
{
if (credentials_) {
CFRelease(credentials_);
credentials_ = 0;
credentials_ = nullptr;
}
}
@ -198,7 +198,7 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint)
A2_LOG_DEBUG(fmt("Looking for cert with fingerprint %s", fp.c_str()));
// Build and run the KeyChain the query.
SecPolicyRef policy = SecPolicyCreateSSL(true, 0);
SecPolicyRef policy = SecPolicyCreateSSL(true, nullptr);
if (!policy) {
A2_LOG_ERROR("Failed to create SecPolicy");
return false;
@ -210,8 +210,8 @@ bool AppleTLSContext::tryAsFingerprint(const std::string& fingerprint)
policy,
kSecMatchLimitAll
};
CFDictionaryRef query = CFDictionaryCreate(0, query_keys, query_values,
4, 0, 0);
CFDictionaryRef query = CFDictionaryCreate(nullptr, query_keys, query_values,
4, nullptr, nullptr);
if (!query) {
A2_LOG_ERROR("Failed to create identity query");
return false;

View File

@ -51,7 +51,7 @@ public:
AppleTLSContext(TLSSessionSide side)
: side_(side),
verifyPeer_(true),
credentials_(0)
credentials_(nullptr)
{}
virtual ~AppleTLSContext();

View File

@ -295,7 +295,7 @@ TLSSession* TLSSession::make(TLSContext* ctx)
AppleTLSSession::AppleTLSSession(AppleTLSContext* ctx)
: ctx_(ctx),
sslCtx_(0),
sslCtx_(nullptr),
sockfd_(0),
state_(st_constructed),
lastError_(noErr),
@ -343,7 +343,7 @@ AppleTLSSession::AppleTLSSession(AppleTLSContext* ctx)
state_ = st_error;
return;
}
CFArrayRef certs = CFArrayCreate(0, (const void**)&creds, 1, 0);
CFArrayRef certs = CFArrayCreate(nullptr, (const void**)&creds, 1, nullptr);
if (!certs) {
A2_LOG_ERROR("AppleTLS: Failed to setup credentials");
state_ = st_error;
@ -374,7 +374,7 @@ AppleTLSSession::~AppleTLSSession()
closeConnection();
if (sslCtx_) {
SSLDisposeContext(sslCtx_);
sslCtx_ = 0;
sslCtx_ = nullptr;
}
state_ = st_error;
}
@ -448,7 +448,7 @@ ssize_t AppleTLSSession::writeData(const void* data, size_t len)
}
size_t processed = 0;
if (writeBuffered_) {
lastError_ = SSLWrite(sslCtx_, 0, 0, &processed);
lastError_ = SSLWrite(sslCtx_, nullptr, 0, &processed);
switch (lastError_) {
case noErr:
processed = writeBuffered_;

View File

@ -148,21 +148,21 @@ ares_addr_node* parseAsyncDNSServers(const std::string& serversOpt)
',',
true /* doStrip */);
ares_addr_node root;
root.next = 0;
root.next = nullptr;
ares_addr_node* tail = &root;
ares_addr_node* node = 0;
ares_addr_node* node = nullptr;
for(std::vector<std::string>::const_iterator i = servers.begin(),
eoi = servers.end(); i != eoi; ++i) {
if(node == 0) {
if(node == nullptr) {
node = new ares_addr_node();
}
size_t len = net::getBinAddr(&node->addr, (*i).c_str());
if(len != 0) {
node->next = 0;
node->next = nullptr;
node->family = (len == 4 ? AF_INET : AF_INET6);
tail->next = node;
tail = node;
node = 0;
node = nullptr;
}
}
if(node) {

View File

@ -164,7 +164,7 @@ ssize_t BencodeParser::parseUpdate(const char* data, size_t size)
i = j;
currentState_ = BENCODE_STRING;
if(strLength_ == 0) {
runCharactersCallback(0, 0);
runCharactersCallback(nullptr, 0);
onStringEnd();
}
} else {

View File

@ -50,9 +50,9 @@ BitfieldMan::BitfieldMan(int32_t blockLength, int64_t totalLength)
bitfieldLength_(0),
blocks_(0),
filterEnabled_(false),
bitfield_(0),
useBitfield_(0),
filterBitfield_(0),
bitfield_(nullptr),
useBitfield_(nullptr),
filterBitfield_(nullptr),
cachedNumMissingBlock_(0),
cachedNumFilteredBlock_(0),
cachedCompletedLength_(0),
@ -78,7 +78,7 @@ BitfieldMan::BitfieldMan(const BitfieldMan& bitfieldMan)
filterEnabled_(bitfieldMan.filterEnabled_),
bitfield_(new unsigned char[bitfieldLength_]),
useBitfield_(new unsigned char[bitfieldLength_]),
filterBitfield_(0),
filterBitfield_(nullptr),
cachedNumMissingBlock_(0),
cachedNumFilteredBlock_(0),
cachedCompletedLength_(0),
@ -116,7 +116,7 @@ BitfieldMan& BitfieldMan::operator=(const BitfieldMan& bitfieldMan)
filterBitfield_ = new unsigned char[bitfieldLength_];
memcpy(filterBitfield_, bitfieldMan.filterBitfield_, bitfieldLength_);
} else {
filterBitfield_ = 0;
filterBitfield_ = nullptr;
}
updateCache();
@ -724,7 +724,7 @@ void BitfieldMan::disableFilter() {
void BitfieldMan::clearFilter() {
if(filterBitfield_) {
delete [] filterBitfield_;
filterBitfield_ = 0;
filterBitfield_ = nullptr;
}
filterEnabled_ = false;
updateCache();

View File

@ -49,14 +49,14 @@ namespace aria2 {
const char BtBitfieldMessage::NAME[] = "bitfield";
BtBitfieldMessage::BtBitfieldMessage():SimpleBtMessage(ID, NAME),
bitfield_(0),
bitfield_(nullptr),
bitfieldLength_(0)
{}
BtBitfieldMessage::BtBitfieldMessage
(const unsigned char* bitfield, size_t bitfieldLength):
SimpleBtMessage(ID, NAME),
bitfield_(0),
bitfield_(nullptr),
bitfieldLength_(0)
{
setBitfield(bitfield, bitfieldLength);

View File

@ -44,7 +44,7 @@
namespace aria2 {
BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup):
PieceHashCheckIntegrityEntry(requestGroup, 0) {}
PieceHashCheckIntegrityEntry(requestGroup, nullptr) {}
BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {}

View File

@ -51,7 +51,7 @@
namespace aria2 {
BtFileAllocationEntry::BtFileAllocationEntry(RequestGroup* requestGroup):
FileAllocationEntry(requestGroup, 0) {}
FileAllocationEntry(requestGroup, nullptr) {}
BtFileAllocationEntry::~BtFileAllocationEntry() {}

View File

@ -43,7 +43,7 @@ const char BtInterestedMessage::NAME[] = "interested";
BtInterestedMessage::BtInterestedMessage()
: ZeroBtMessage(ID, NAME),
peerStorage_(0)
peerStorage_(nullptr)
{}
BtInterestedMessage::~BtInterestedMessage() {}

View File

@ -43,7 +43,7 @@ const char BtNotInterestedMessage::NAME[] = "not interested";
BtNotInterestedMessage::BtNotInterestedMessage()
: ZeroBtMessage(ID, NAME),
peerStorage_(0)
peerStorage_(nullptr)
{}
BtNotInterestedMessage::~BtNotInterestedMessage() {}

View File

@ -72,9 +72,9 @@ BtPieceMessage::BtPieceMessage
index_(index),
begin_(begin),
blockLength_(blockLength),
data_(0),
downloadContext_(0),
peerStorage_(0)
data_(nullptr),
downloadContext_(nullptr),
peerStorage_(nullptr)
{
setUploading(true);
}

View File

@ -55,10 +55,10 @@ const char BtPortMessage::NAME[] = "port";
BtPortMessage::BtPortMessage(uint16_t port)
: SimpleBtMessage(ID, NAME),
port_(port),
localNode_(0),
routingTable_(0),
taskQueue_(0),
taskFactory_(0)
localNode_(nullptr),
routingTable_(nullptr),
taskQueue_(nullptr),
taskFactory_(nullptr)
{}
std::unique_ptr<BtPortMessage> BtPortMessage::create

View File

@ -82,7 +82,7 @@ int BufferedFile::onClose()
int rv = 0;
if (fp_) {
rv = fclose(fp_);
fp_ = 0;
fp_ = nullptr;
}
return rv;
}

View File

@ -240,8 +240,8 @@ void printProgressSummary
time_t now;
struct tm* staticNowtmPtr;
char buf[26];
if(time(&now) != (time_t)-1 && (staticNowtmPtr = localtime(&now)) != 0 &&
asctime_r(staticNowtmPtr, buf) != 0) {
if(time(&now) != (time_t)-1 && (staticNowtmPtr = localtime(&now)) != nullptr &&
asctime_r(staticNowtmPtr, buf) != nullptr) {
char* lfptr = strchr(buf, '\n');
if(lfptr) {
*lfptr = '\0';

View File

@ -47,10 +47,10 @@ namespace aria2 {
DHTAbstractTask::DHTAbstractTask():
finished_(false),
routingTable_(0),
dispatcher_(0),
factory_(0),
taskQueue_(0)
routingTable_(nullptr),
dispatcher_(nullptr),
factory_(nullptr),
taskQueue_(nullptr)
{}
bool DHTAbstractTask::finished()

View File

@ -45,7 +45,7 @@ namespace aria2 {
DHTBucketTreeNode::DHTBucketTreeNode
(DHTBucketTreeNode* left,
DHTBucketTreeNode* right)
: parent_(0),
: parent_(nullptr),
left_(left),
right_(right)
{
@ -53,9 +53,9 @@ DHTBucketTreeNode::DHTBucketTreeNode
}
DHTBucketTreeNode::DHTBucketTreeNode(const std::shared_ptr<DHTBucket>& bucket)
: parent_(0),
left_(0),
right_(0),
: parent_(nullptr),
left_(nullptr),
right_(nullptr),
bucket_(bucket)
{
memcpy(minId_, bucket_->getMinID(), DHT_ID_LENGTH);
@ -79,7 +79,7 @@ void DHTBucketTreeNode::resetRelation()
DHTBucketTreeNode* DHTBucketTreeNode::dig(const unsigned char* key)
{
if(leaf()) {
return 0;
return nullptr;
}
if(left_->isInRange(key)) {
return left_;

View File

@ -51,10 +51,10 @@
namespace aria2 {
DHTTaskFactoryImpl::DHTTaskFactoryImpl()
: routingTable_(0),
dispatcher_(0),
factory_(0),
taskQueue_(0),
: routingTable_(nullptr),
dispatcher_(nullptr),
factory_(nullptr),
taskQueue_(nullptr),
timeout_(DHT_MESSAGE_TIMEOUT)
{}

View File

@ -56,7 +56,7 @@ DHTUnknownMessage::DHTUnknownMessage(const std::shared_ptr<DHTNode>& localNode,
port_(port)
{
if(length_ == 0) {
data_ = 0;
data_ = nullptr;
} else {
data_ = new unsigned char[length];
memcpy(data_, data, length);

View File

@ -91,7 +91,7 @@ DefaultBtInteractive::DefaultBtInteractive
downloadContext_(downloadContext),
peer_(peer),
metadataGetMode_(false),
localNode_(0),
localNode_(nullptr),
allowedFastSetSize_(10),
haveTimer_(global::wallclock()),
keepAliveTimer_(global::wallclock()),
@ -104,7 +104,7 @@ DefaultBtInteractive::DefaultBtInteractive
dhtEnabled_(false),
numReceivedMessage_(0),
maxOutstandingRequest_(DEFAULT_MAX_OUTSTANDING_REQUEST),
requestGroupMan_(0),
requestGroupMan_(nullptr),
tcpPort_(0),
haveLastSent_(global::wallclock())
{}

View File

@ -119,7 +119,7 @@ std::unique_ptr<BtMessage> DefaultBtMessageReceiver::receiveMessage()
{
size_t dataLength = 0;
// Give 0 to PeerConnection::receiveMessage() to prevent memcpy.
if(!peerConnection_->receiveMessage(0, dataLength)) {
if(!peerConnection_->receiveMessage(nullptr, dataLength)) {
return nullptr;
}
auto msg =

View File

@ -53,9 +53,9 @@
namespace aria2 {
DefaultBtRequestFactory::DefaultBtRequestFactory()
: pieceStorage_(0),
dispatcher_(0),
messageFactory_(0),
: pieceStorage_(nullptr),
dispatcher_(nullptr),
messageFactory_(nullptr),
cuid_(0)
{}

View File

@ -84,7 +84,7 @@ DefaultPieceStorage::DefaultPieceStorage
option_(option),
pieceStatMan_(new PieceStatMan(downloadContext->getNumPieces(), true)),
pieceSelector_(make_unique<RarestPieceSelector>(pieceStatMan_)),
wrDiskCache_(0)
wrDiskCache_(nullptr)
{
const std::string& pieceSelectorOpt =
option_->get(PREF_STREAM_PIECE_SELECTOR);

View File

@ -51,7 +51,7 @@ DownloadContext::DownloadContext():
pieceLength_(0),
checksumVerified_(false),
knowsTotalLength_(true),
ownerRequestGroup_(0),
ownerRequestGroup_(nullptr),
attrs_(MAX_CTX_ATTR),
downloadStopTime_(0),
acceptMetalink_(true) {}
@ -62,7 +62,7 @@ DownloadContext::DownloadContext(int32_t pieceLength,
pieceLength_(pieceLength),
checksumVerified_(false),
knowsTotalLength_(true),
ownerRequestGroup_(0),
ownerRequestGroup_(nullptr),
attrs_(MAX_CTX_ATTR),
downloadStopTime_(0),
acceptMetalink_(true)

View File

@ -99,10 +99,10 @@ DownloadEngine::DownloadEngine(std::unique_ptr<EventPoll> eventPoll)
btRegistry_(make_unique<BtRegistry>()),
#endif // ENABLE_BITTORRENT
#ifdef HAVE_ARES_ADDR_NODE
asyncDNSServers_(0),
asyncDNSServers_(nullptr),
#endif // HAVE_ARES_ADDR_NODE
dnsCache_(make_unique<DNSCache>()),
option_(0)
option_(nullptr)
{
unsigned char sessionId[20];
util::generateRandomKey(sessionId);
@ -112,7 +112,7 @@ DownloadEngine::DownloadEngine(std::unique_ptr<EventPoll> eventPoll)
DownloadEngine::~DownloadEngine()
{
#ifdef HAVE_ARES_ADDR_NODE
setAsyncDNSServers(0);
setAsyncDNSServers(nullptr);
#endif // HAVE_ARES_ADDR_NODE
}

View File

@ -40,7 +40,7 @@ namespace {
const char* METALINK_EXTENSIONS[] = {
".metalink", // Metalink3Spec
".meta4", // Metalink4Spec
0
nullptr
};
} // namespace
@ -53,7 +53,7 @@ namespace {
const char* METALINK_CONTENT_TYPES[] = {
"application/metalink4+xml", // Metalink4Spec
"application/metalink+xml", // Metalink3Spec
0
nullptr
};
} // namespace
@ -65,7 +65,7 @@ const char** getMetalinkContentTypes()
namespace {
const char* BT_EXTENSIONS[] = {
".torrent",
0
nullptr
};
} // namespace
@ -77,7 +77,7 @@ const char** getBtExtensions()
namespace {
const char* BT_CONTENT_TYPES[] = {
"application/x-bittorrent",
0
nullptr
};
} // namespace

View File

@ -40,7 +40,7 @@
namespace aria2 {
DownloadResult::DownloadResult()
: gid(0),
: gid(nullptr),
inMemoryDownload(false),
sessionDownloadLength(0),
sessionTime(0),

View File

@ -49,7 +49,7 @@ namespace {
const char* EXTENSION_NAMES[] = {
"ut_metadata",
"ut_pex",
0
nullptr
};
} // namespace
@ -63,7 +63,7 @@ const char* ExtensionMessageRegistry::getExtensionName(uint8_t id) const
{
int i;
if(id == 0) {
return 0;
return nullptr;
}
for(i = 0; i < MAX_EXTENSION; ++i) {
if(extensions_[i] == id) {
@ -93,7 +93,7 @@ void ExtensionMessageRegistry::setExtensions(const Extensions& extensions)
const char* strBtExtension(int key)
{
if(key >= ExtensionMessageRegistry::MAX_EXTENSION) {
return 0;
return nullptr;
} else {
return EXTENSION_NAMES[key];
}

View File

@ -104,7 +104,7 @@ const char* strSupportedFeature(int feature)
#ifdef ENABLE_ASYNC_DNS
return "Async DNS";
#else // !ENABLE_ASYNC_DNS
return 0;
return nullptr;
#endif // !ENABLE_ASYNC_DNS
break;
@ -120,7 +120,7 @@ const char* strSupportedFeature(int feature)
#ifdef HAVE_SQLITE3
return "Firefox3 Cookie";
#else // !HAVE_SQLITE3
return 0;
return nullptr;
#endif // !HAVE_SQLITE3
break;
@ -165,7 +165,7 @@ const char* strSupportedFeature(int feature)
break;
default:
return 0;
return nullptr;
}
}

View File

@ -536,7 +536,7 @@ size_t FileEntry::setUris(const std::vector<std::string>& uris)
bool FileEntry::addUri(const std::string& uri)
{
std::string peUri = util::percentEncodeMini(uri);
if(uri_split(NULL, peUri.c_str()) == 0) {
if(uri_split(nullptr, peUri.c_str()) == 0) {
uris_.push_back(peUri);
return true;
} else {
@ -547,7 +547,7 @@ bool FileEntry::addUri(const std::string& uri)
bool FileEntry::insertUri(const std::string& uri, size_t pos)
{
std::string peUri = util::percentEncodeMini(uri);
if(uri_split(NULL, peUri.c_str()) == 0) {
if(uri_split(nullptr, peUri.c_str()) == 0) {
pos = std::min(pos, uris_.size());
uris_.insert(uris_.begin()+pos, peUri);
return true;

View File

@ -78,7 +78,7 @@ void GZipDecodingStreamFilter::release()
if(strm_) {
inflateEnd(strm_);
delete strm_;
strm_ = 0;
strm_ = nullptr;
}
}

View File

@ -46,7 +46,7 @@ namespace {
const int OUTBUF_LENGTH = 4096;
} // namespace
GZipEncoder::GZipEncoder():strm_(0) {}
GZipEncoder::GZipEncoder():strm_(nullptr) {}
GZipEncoder::~GZipEncoder()
{
@ -74,7 +74,7 @@ void GZipEncoder::release()
if(strm_) {
deflateEnd(strm_);
delete strm_;
strm_ = 0;
strm_ = nullptr;
}
}
@ -104,7 +104,7 @@ std::string GZipEncoder::encode
std::string GZipEncoder::str()
{
internalBuf_ += encode(0, 0, Z_FINISH);
internalBuf_ += encode(nullptr, 0, Z_FINISH);
return internalBuf_;
}

View File

@ -44,7 +44,7 @@
namespace aria2 {
GZipFile::GZipFile(const char* filename, const char* mode)
: fp_(0),
: fp_(nullptr),
buflen_(1024), buf_(reinterpret_cast<char*>(malloc(buflen_)))
{
FILE* fp =
@ -85,7 +85,7 @@ int GZipFile::onClose()
int rv = 0;
if (fp_) {
rv = gzclose(fp_);
fp_ = 0;
fp_ = nullptr;
}
return rv;
}
@ -99,7 +99,7 @@ bool GZipFile::isError() const
{
int rv = 0;
const char *e = gzerror(fp_, &rv);
return (e != 0 && *e != 0) || rv != 0;
return (e != nullptr && *e != 0) || rv != 0;
}
bool GZipFile::isEOF() const

View File

@ -63,7 +63,7 @@ void GrowSegment::clear(WrDiskCache* diskCache)
{
writtenLength_ = 0;
// cache won't be used in this object.
piece_->clearAllBlock(0);
piece_->clearAllBlock(nullptr);
}
std::shared_ptr<Piece> GrowSegment::getPiece() const

View File

@ -103,7 +103,7 @@ bool HttpListenCommand::bindPort(uint16_t port)
if(e_->getOption()->getAsBool(PREF_RPC_LISTEN_ALL)) {
flags = AI_PASSIVE;
}
serverSocket_->bind(0, port, family_, flags);
serverSocket_->bind(nullptr, port, family_, flags);
serverSocket_->beginListen();
A2_LOG_INFO(fmt(MSG_LISTENING_PORT,
getCuid(), port));

View File

@ -61,9 +61,9 @@ HttpRequest::HttpRequest()
: contentEncodingEnabled_(true),
userAgent_(USER_AGENT),
acceptMetalink_(false),
cookieStorage_(0),
authConfigFactory_(0),
option_(0),
cookieStorage_(nullptr),
authConfigFactory_(nullptr),
option_(nullptr),
noCache_(true),
acceptGzip_(false),
endOffsetOverride_(0)

View File

@ -50,7 +50,7 @@ const char IOFile::APPEND[] = "ab";
IOFile::operator unspecified_bool_type() const
{
bool ok = isOpen() && !isError();
return ok ? &IOFile::goodState : 0;
return ok ? &IOFile::goodState : nullptr;
}
size_t IOFile::read(void* ptr, size_t count)

View File

@ -115,7 +115,7 @@ LibuvEventPoll::~LibuvEventPoll()
if (loop_) {
uv_loop_delete(loop_);
loop_ = 0;
loop_ = nullptr;
}
// Need this to free only after the loop is gone.

View File

@ -133,7 +133,7 @@ void writeHeader
(Output& fp, Logger::LEVEL level, const char* sourceFile, int lineNum)
{
struct timeval tv;
gettimeofday(&tv, 0);
gettimeofday(&tv, nullptr);
char datestr[20]; // 'YYYY-MM-DD hh:mm:ss'+'\0' = 20 bytes
struct tm tm;
//tv.tv_sec may not be of type time_t.
@ -172,7 +172,7 @@ template<typename Output>
void writeHeaderConsole(Output& fp, Logger::LEVEL level, bool useColor)
{
struct timeval tv;
gettimeofday(&tv, 0);
gettimeofday(&tv, nullptr);
char datestr[15]; // 'MM/DD hh:mm:ss'+'\0' = 15 bytes
struct tm tm;
//tv.tv_sec may not be of type time_t.

View File

@ -81,12 +81,12 @@ MSEHandshake::MSEHandshake
rbufLength_(0),
socketBuffer_(socket),
negotiatedCryptoType_(CRYPTO_NONE),
dh_(0),
dh_(nullptr),
initiator_(true),
markerIndex_(0),
padLength_(0),
iaLength_(0),
ia_(0),
ia_(nullptr),
sha1_(MessageDigest::sha1())
{}

View File

@ -581,7 +581,7 @@ void MetalinkParserController::setURLOfMetaurl(const std::string& url)
#endif // ENABLE_BITTORRENT
{
std::string u = uri::joinUri(baseUri_, url);
if(uri_split(NULL, u.c_str()) == 0) {
if(uri_split(nullptr, u.c_str()) == 0) {
tMetaurl_->url = u;
} else {
tMetaurl_->url = url;

View File

@ -58,7 +58,7 @@ public:
bool operator()(const XmlAttr& attr) const
{
return strcmp(attr.localname, localname_) == 0 &&
(attr.nsUri == 0 || strcmp(attr.nsUri, nsUri_) == 0);
(attr.nsUri == nullptr || strcmp(attr.nsUri, nsUri_) == 0);
}
};
} // namespace

View File

@ -52,7 +52,7 @@ void NameResolver::resolve(std::vector<std::string>& resolvedAddresses,
{
struct addrinfo* res;
int s;
s = callGetaddrinfo(&res, hostname.c_str(), 0, family_, socktype_, 0, 0);
s = callGetaddrinfo(&res, hostname.c_str(), nullptr, family_, socktype_, 0, 0);
if(s) {
throw DL_ABORT_EX2(fmt(EX_RESOLVE_HOSTNAME,
hostname.c_str(), gai_strerror(s)),

View File

@ -122,7 +122,7 @@ int32_t Option::getAsInt(const Pref* pref) const {
if(value.empty()) {
return 0;
} else {
return strtol(value.c_str(), 0, 10);
return strtol(value.c_str(), nullptr, 10);
}
}
@ -131,7 +131,7 @@ int64_t Option::getAsLLInt(const Pref* pref) const {
if(value.empty()) {
return 0;
} else {
return strtoll(value.c_str(), 0, 10);
return strtoll(value.c_str(), nullptr, 10);
}
}
@ -144,7 +144,7 @@ double Option::getAsDouble(const Pref* pref) const {
if(value.empty()) {
return 0.0;
} else {
return strtod(value.c_str(), 0);
return strtod(value.c_str(), nullptr);
}
}

View File

@ -241,7 +241,7 @@ FloatNumberOptionHandler::~FloatNumberOptionHandler() {}
void FloatNumberOptionHandler::parseArg
(Option& option, const std::string& optarg) const
{
double number = strtod(optarg.c_str(), 0);
double number = strtod(optarg.c_str(), nullptr);
if((min_ < 0 || min_ <= number) && (max_ < 0 || number <= max_)) {
option.put(pref_, optarg);
} else {

View File

@ -271,7 +271,7 @@ public:
// argument.
DeprecatedOptionHandler
(OptionHandler* depOptHandler,
const OptionHandler* repOptHandler = 0);
const OptionHandler* repOptHandler = nullptr);
virtual ~DeprecatedOptionHandler();
virtual void parse(Option& option, const std::string& arg) const
CXX11_OVERRIDE;

View File

@ -59,7 +59,7 @@
namespace aria2 {
OptionParser::OptionParser()
: handlers_(option::countOption(), 0),
: handlers_(option::countOption(), nullptr),
shortOpts_(256)
{}
@ -111,15 +111,15 @@ void putOptions(struct option* longOpts, int* plopt,
(*longOpts).flag = plopt;
(*longOpts).val = (*first)->getPref()->i;
} else {
(*longOpts).flag = 0;
(*longOpts).flag = nullptr;
(*longOpts).val = (*first)->getShortName();
}
++longOpts;
}
}
(*longOpts).name = 0;
(*longOpts).name = nullptr;
(*longOpts).has_arg = 0;
(*longOpts).flag = 0;
(*longOpts).flag = nullptr;
(*longOpts).val = 0;
}
} // namespace
@ -156,11 +156,11 @@ void OptionParser::parseArg
putOptions(longOpts.get(), &lopt, handlers_.begin(), handlers_.end());
std::string optstring = createOptstring(handlers_.begin(), handlers_.end());
while(1) {
int c = getopt_long(argc, argv, optstring.c_str(), longOpts.get(), 0);
int c = getopt_long(argc, argv, optstring.c_str(), longOpts.get(), nullptr);
if(c == -1) {
break;
}
const OptionHandler* op = 0;
const OptionHandler* op = nullptr;
if(c == 0) {
op = findById(lopt);
} else if(c != '?') {

View File

@ -53,7 +53,7 @@ Peer::Peer(std::string ipaddr, uint16_t port, bool incoming):
firstContactTime_(global::wallclock()),
dropStartTime_(0),
seeder_(false),
res_(0),
res_(nullptr),
incoming_(incoming),
localPeer_(false),
disconnectedGracefully_(false)
@ -88,7 +88,7 @@ void Peer::reconfigureSessionResource(int32_t pieceLength, int64_t totalLength)
void Peer::releaseSessionResource()
{
delete res_;
res_ = 0;
res_ = nullptr;
}
void Peer::setPeerId(const unsigned char* peerId)

View File

@ -129,7 +129,7 @@ public:
// Returns true iff res_ != 0.
bool isActive() const
{
return res_ != 0;
return res_ != nullptr;
}
void setPeerId(const unsigned char* peerId);

View File

@ -77,7 +77,7 @@ bool PeerListenCommand::bindPort(uint16_t& port, SegList<int>& sgl)
eoi = ports.end(); i != eoi; ++i) {
port = *i;
try {
socket_->bind(0, port, family_);
socket_->bind(nullptr, port, family_);
socket_->beginListen();
A2_LOG_NOTICE(fmt(_("IPv%d BitTorrent: listening on TCP port %u"),
ipv, port));

View File

@ -96,7 +96,7 @@ bool PeerReceiveHandshakeCommand::executeInternal()
size_t dataLength = 0;
// Ignore return value. The received data is kept in
// PeerConnection object because of peek = true.
peerConnection_->receiveHandshake(0, dataLength, true);
peerConnection_->receiveHandshake(nullptr, dataLength, true);
}
if(peerConnection_->getBufferLength() >= 48) {
const unsigned char* data = peerConnection_->getBuffer();

View File

@ -49,7 +49,7 @@ PeerSessionResource::PeerSessionResource(int32_t pieceLength, int64_t totalLengt
bitfieldMan_(new BitfieldMan(pieceLength, totalLength)),
lastDownloadUpdate_(0),
lastAmUnchoking_(0),
dispatcher_(0),
dispatcher_(nullptr),
amChoking_(true),
amInterested_(false),
peerChoking_(true),

View File

@ -52,8 +52,8 @@
namespace aria2 {
Piece::Piece():index_(0), length_(0), blockLength_(BLOCK_LENGTH), bitfield_(0),
usedBySegment_(false), wrCache_(0)
Piece::Piece():index_(0), length_(0), blockLength_(BLOCK_LENGTH), bitfield_(nullptr),
usedBySegment_(false), wrCache_(nullptr)
#ifdef ENABLE_MESSAGE_DIGEST
, nextBegin_(0)
#endif // ENABLE_MESSAGE_DIGEST
@ -64,7 +64,7 @@ Piece::Piece(size_t index, int32_t length, int32_t blockLength)
length_(length),
blockLength_(blockLength),
bitfield_(new BitfieldMan(blockLength_, length)),
usedBySegment_(false), wrCache_(0)
usedBySegment_(false), wrCache_(nullptr)
#ifdef ENABLE_MESSAGE_DIGEST
,nextBegin_(0)
#endif // ENABLE_MESSAGE_DIGEST
@ -325,7 +325,7 @@ void Piece::initWrCache(WrDiskCache* diskCache,
if(!diskCache) {
return;
}
assert(wrCache_ == 0);
assert(wrCache_ == nullptr);
wrCache_ = new WrDiskCacheEntry(diskAdaptor);
bool rv = diskCache->add(wrCache_);
assert(rv);
@ -396,7 +396,7 @@ void Piece::releaseWrCache(WrDiskCache* diskCache)
if(diskCache && wrCache_) {
diskCache->remove(wrCache_);
delete wrCache_;
wrCache_ = 0;
wrCache_ = nullptr;
}
}

View File

@ -55,7 +55,7 @@ ProtocolDetector::~ProtocolDetector() {}
bool ProtocolDetector::isStreamProtocol(const std::string& uri) const
{
return uri_split(NULL, uri.c_str()) == 0;
return uri_split(nullptr, uri.c_str()) == 0;
}
bool ProtocolDetector::guessTorrentFile(const std::string& uri) const

View File

@ -141,15 +141,15 @@ RequestGroup::RequestGroup(const std::shared_ptr<GroupId>& gid,
fileNotFoundCount_(0),
timeout_(option->getAsInt(PREF_TIMEOUT)),
#ifdef ENABLE_BITTORRENT
btRuntime_(0),
peerStorage_(0),
btRuntime_(nullptr),
peerStorage_(nullptr),
#endif // ENABLE_BITTORRENT
inMemoryDownload_(false),
maxDownloadSpeedLimit_(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
maxUploadSpeedLimit_(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
lastErrorCode_(error_code::UNDEFINED),
belongsToGID_(0),
requestGroupMan_(0),
requestGroupMan_(nullptr),
resumeFailureCount_(0)
{
fileAllocationEnabled_ = option_->get(PREF_FILE_ALLOCATION) != V_NONE;
@ -314,7 +314,7 @@ void RequestGroup::createInitialCommand
}
}
DefaultBtProgressInfoFile* progressInfoFilePtr = 0;
DefaultBtProgressInfoFile* progressInfoFilePtr = nullptr;
std::shared_ptr<BtProgressInfoFile> progressInfoFile;
if(!metadataGetMode) {
progressInfoFilePtr = new DefaultBtProgressInfoFile(downloadContext_,
@ -997,8 +997,8 @@ void RequestGroup::releaseRuntimeResource(DownloadEngine* e)
{
#ifdef ENABLE_BITTORRENT
e->getBtRegistry()->remove(gid_->getNumericId());
btRuntime_ = 0;
peerStorage_ = 0;
btRuntime_ = nullptr;
peerStorage_ = nullptr;
#endif // ENABLE_BITTORRENT
if(pieceStorage_) {
pieceStorage_->removeAdvertisedPiece(0);

View File

@ -111,7 +111,7 @@ RequestGroupMan::RequestGroupMan
removedErrorResult_(0),
removedLastErrorResult_(error_code::FINISHED),
maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT)),
wrDiskCache_(0)
wrDiskCache_(nullptr)
{
appendReservedGroup(reservedGroups_,
requestGroups.begin(), requestGroups.end());
@ -962,7 +962,7 @@ void RequestGroupMan::setUriListParser
void RequestGroupMan::initWrDiskCache()
{
assert(wrDiskCache_ == 0);
assert(wrDiskCache_ == nullptr);
size_t limit = option_->getAsInt(PREF_DISK_CACHE);
if(limit > 0) {
wrDiskCache_ = new WrDiskCache(limit);

View File

@ -198,7 +198,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
#ifdef __MINGW32__
retval = select(fdmax_+1, &rfds, &wfds, &efds, &ttv);
#else // !__MINGW32__
retval = select(fdmax_+1, &rfds, &wfds, NULL, &ttv);
retval = select(fdmax_+1, &rfds, &wfds, nullptr, &ttv);
#endif // !__MINGW32__
} while(retval == -1 && errno == EINTR);
if(retval > 0) {

View File

@ -56,7 +56,7 @@ const std::unique_ptr<SimpleRandomizer>& SimpleRandomizer::getInstance()
void SimpleRandomizer::init()
{
#ifndef __MINGW32__
srandom(time(0)^getpid());
srandom(time(nullptr)^getpid());
#endif // !__MINGW32__
}

View File

@ -55,7 +55,7 @@ SingleFileAllocationIterator::SingleFileAllocationIterator
: stream_(stream),
offset_(offset),
totalLength_(totalLength),
buffer_(0)
buffer_(nullptr)
{}
SingleFileAllocationIterator::~SingleFileAllocationIterator()

View File

@ -47,7 +47,7 @@ private:
bool hashUpdate_;
size_t bytesProcessed_;
public:
SinkStreamFilter(WrDiskCache* wrDiskCache = 0, bool hashUpdate = false);
SinkStreamFilter(WrDiskCache* wrDiskCache = nullptr, bool hashUpdate = false);
virtual void init() CXX11_OVERRIDE {}

View File

@ -103,12 +103,12 @@ std::string errorMsg(int errNum)
if (FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nullptr,
errNum,
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPTSTR) &buf,
sizeof(buf),
NULL
nullptr
) == 0) {
snprintf(buf, sizeof(buf), EX_SOCKET_UNKNOWN_ERROR, errNum, errNum);
}
@ -267,7 +267,7 @@ void SocketCore::bindWithFamily(uint16_t port, int family, int flags)
{
closeConnection();
std::string error;
sock_t fd = bindTo(0, port, family, sockType_, flags, error);
sock_t fd = bindTo(nullptr, port, family, sockType_, flags, error);
if(fd == (sock_t) -1) {
throw DL_ABORT_EX(fmt(EX_SOCKET_BIND, error.c_str()));
} else {
@ -284,7 +284,7 @@ void SocketCore::bind
if(addr && addr[0]) {
addrp = addr;
} else {
addrp = 0;
addrp = nullptr;
}
if(!(flags&AI_PASSIVE) || bindAddrs_.empty()) {
sock_t fd = bindTo(addrp, port, family, sockType_, flags, error);
@ -297,7 +297,7 @@ void SocketCore::bind
i != eoi; ++i) {
char host[NI_MAXHOST];
int s;
s = getnameinfo(&(*i).first.sa, (*i).second, host, NI_MAXHOST, 0, 0,
s = getnameinfo(&(*i).first.sa, (*i).second, host, NI_MAXHOST, nullptr, 0,
NI_NUMERICHOST);
if(s) {
error = gai_strerror(s);
@ -321,7 +321,7 @@ void SocketCore::bind
void SocketCore::bind(uint16_t port, int flags)
{
bind(0, port, protocolFamily_, flags);
bind(nullptr, port, protocolFamily_, flags);
}
void SocketCore::bind(const struct sockaddr* addr, socklen_t addrlen)
@ -622,7 +622,7 @@ bool SocketCore::isWritable(time_t timeout)
tv.tv_sec = timeout;
tv.tv_usec = 0;
int r = select(sockfd_+1, NULL, &fds, NULL, &tv);
int r = select(sockfd_+1, nullptr, &fds, nullptr, &tv);
int errNum = SOCKET_ERRNO;
if(r == 1) {
return true;
@ -668,7 +668,7 @@ bool SocketCore::isReadable(time_t timeout)
tv.tv_sec = timeout;
tv.tv_usec = 0;
int r = select(sockfd_+1, &fds, NULL, NULL, &tv);
int r = select(sockfd_+1, &fds, nullptr, nullptr, &tv);
int errNum = SOCKET_ERRNO;
if(r == 1) {
return true;
@ -986,7 +986,7 @@ void SocketCore::bindAddress(const std::string& iface)
i != eoi; ++i) {
char host[NI_MAXHOST];
int s;
s = getnameinfo(&(*i).first.sa, (*i).second, host, NI_MAXHOST, 0, 0,
s = getnameinfo(&(*i).first.sa, (*i).second, host, NI_MAXHOST, nullptr, 0,
NI_NUMERICHOST);
if(s == 0) {
A2_LOG_DEBUG(fmt("Sockets will bind to %s", host));
@ -1002,7 +1002,7 @@ void getInterfaceAddress
A2_LOG_DEBUG(fmt("Finding interface %s", iface.c_str()));
#ifdef HAVE_GETIFADDRS
// First find interface in interface addresses
struct ifaddrs* ifaddr = 0;
struct ifaddrs* ifaddr = nullptr;
if(getifaddrs(&ifaddr) == -1) {
int errNum = SOCKET_ERRNO;
A2_LOG_INFO(fmt(MSG_INTERFACE_NOT_FOUND,
@ -1044,7 +1044,7 @@ void getInterfaceAddress
if(ifAddrs.empty()) {
addrinfo* res;
int s;
s = callGetaddrinfo(&res, iface.c_str(), 0, family, SOCK_STREAM, aiFlags,0);
s = callGetaddrinfo(&res, iface.c_str(), nullptr, family, SOCK_STREAM, aiFlags,0);
if(s) {
A2_LOG_INFO(fmt(MSG_INTERFACE_NOT_FOUND, iface.c_str(), gai_strerror(s)));
} else {
@ -1111,7 +1111,7 @@ int inetNtop(int af, const void* src, char* dst, socklen_t size)
#endif // HAVE_SOCKADDR_IN_SIN_LEN
memcpy(&su.in.sin_addr, src, sizeof(su.in.sin_addr));
s = getnameinfo(&su.sa, sizeof(su.in),
dst, size, 0, 0, NI_NUMERICHOST);
dst, size, nullptr, 0, NI_NUMERICHOST);
} else if(af == AF_INET6) {
su.in6.sin6_family = AF_INET6;
#ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
@ -1119,7 +1119,7 @@ int inetNtop(int af, const void* src, char* dst, socklen_t size)
#endif // HAVE_SOCKADDR_IN6_SIN6_LEN
memcpy(&su.in6.sin6_addr, src, sizeof(su.in6.sin6_addr));
s = getnameinfo(&su.sa, sizeof(su.in6),
dst, size, 0, 0, NI_NUMERICHOST);
dst, size, nullptr, 0, NI_NUMERICHOST);
} else {
s = EAI_FAMILY;
}
@ -1157,7 +1157,7 @@ size_t getBinAddr(void* dest, const std::string& ip)
{
size_t len = 0;
addrinfo* res;
if(callGetaddrinfo(&res, ip.c_str(), 0, AF_UNSPEC,
if(callGetaddrinfo(&res, ip.c_str(), nullptr, AF_UNSPEC,
0, AI_NUMERICHOST, 0) != 0) {
return len;
}
@ -1307,7 +1307,7 @@ void checkAddrconfig()
A2_LOG_INFO("Checking configured addresses");
ipv4AddrConfigured = false;
ipv6AddrConfigured = false;
ifaddrs* ifaddr = 0;
ifaddrs* ifaddr = nullptr;
int rv;
rv = getifaddrs(&ifaddr);
if(rv == -1) {
@ -1348,7 +1348,7 @@ void checkAddrconfig()
default:
continue;
}
rv = getnameinfo(ifa->ifa_addr, addrlen, host, NI_MAXHOST, 0, 0,
rv = getnameinfo(ifa->ifa_addr, addrlen, host, NI_MAXHOST, nullptr, 0,
NI_NUMERICHOST);
if(rv == 0) {
if(found) {

View File

@ -80,12 +80,12 @@ bool Time::operator<(const Time& time) const
}
void Time::reset() {
gettimeofday(&tv_, 0);
gettimeofday(&tv_, nullptr);
}
struct timeval Time::getCurrentTime() const {
struct timeval now;
gettimeofday(&now, 0);
gettimeofday(&now, nullptr);
return now;
}
@ -94,7 +94,7 @@ bool Time::elapsed(time_t sec) const {
// the time this function is called before specified time passes, we first do
// simple test using time.
// Then only when the further test is required, call gettimeofday.
time_t now = time(0);
time_t now = time(nullptr);
if(tv_.tv_sec+sec < now) {
return true;
} else if(tv_.tv_sec+sec == now) {

View File

@ -95,7 +95,7 @@ static timeval getCurrentTime()
tv.tv_sec = ts.tv_sec+2678400; // 1month offset(24*3600*31)
tv.tv_usec = ts.tv_nsec/1000;
} else {
gettimeofday(&tv, 0);
gettimeofday(&tv, nullptr);
}
return tv;
}

View File

@ -474,12 +474,12 @@ UDPTrackerConnection* UDPTrackerClient::getConnectionId
UDPTrackerConnection>::iterator i =
connectionIdCache_.find(std::make_pair(remoteAddr, remotePort));
if(i == connectionIdCache_.end()) {
return 0;
return nullptr;
}
if((*i).second.state == UDPT_CST_CONNECTED &&
(*i).second.lastUpdated.difference(now) > 60) {
connectionIdCache_.erase(i);
return 0;
return nullptr;
} else {
return &(*i).second;
}

View File

@ -156,7 +156,7 @@ std::shared_ptr<Piece> UnknownLengthPieceStorage::getMissingPiece
cuid_t cuid)
{
if(index == 0) {
return getMissingPiece(0, 0, 0, cuid);
return getMissingPiece(0, nullptr, 0, cuid);
} else {
return nullptr;
}

View File

@ -205,7 +205,7 @@ public:
virtual const unsigned char* getBitfield() CXX11_OVERRIDE
{
return 0;
return nullptr;
}
virtual void setBitfield(const unsigned char* bitfield,
@ -232,7 +232,7 @@ public:
virtual std::shared_ptr<DiskAdaptor> getDiskAdaptor() CXX11_OVERRIDE;
virtual WrDiskCache* getWrDiskCache() CXX11_OVERRIDE { return 0; }
virtual WrDiskCache* getWrDiskCache() CXX11_OVERRIDE { return nullptr; }
virtual void flushWrDiskCacheEntry() CXX11_OVERRIDE {}

View File

@ -107,7 +107,7 @@ void WatchProcessCommand::process()
mib[2]=KERN_PROC_PID;
mib[3]=pid_;
int ret = sysctl(mib, MIBSIZE, &kp, &len, NULL, 0);
int ret = sysctl(mib, MIBSIZE, &kp, &len, nullptr, 0);
if (ret == -1 || len <= 0) {
waiting = false;
}

View File

@ -160,7 +160,7 @@ void onMsgRecvCallback(wslay_event_context_ptr wsctx,
if(!wslay_is_ctrl_frame(arg->opcode)) {
// TODO Only process text frame
ssize_t error = 0;
auto json = wsSession->parseFinal(0, 0, error);
auto json = wsSession->parseFinal(nullptr, 0, error);
if(error < 0) {
A2_LOG_INFO("Failed to parse JSON-RPC request");
RpcResponse res

View File

@ -121,45 +121,45 @@ void mlCharacters(void* userData, const xmlChar* ch, int len)
namespace {
xmlSAXHandler mySAXHandler =
{
0, // internalSubsetSAXFunc
0, // isStandaloneSAXFunc
0, // hasInternalSubsetSAXFunc
0, // hasExternalSubsetSAXFunc
0, // resolveEntitySAXFunc
0, // getEntitySAXFunc
0, // entityDeclSAXFunc
0, // notationDeclSAXFunc
0, // attributeDeclSAXFunc
0, // elementDeclSAXFunc
0, // unparsedEntityDeclSAXFunc
0, // setDocumentLocatorSAXFunc
0, // startDocumentSAXFunc
0, // endDocumentSAXFunc
0, // startElementSAXFunc
0, // endElementSAXFunc
0, // referenceSAXFunc
nullptr, // internalSubsetSAXFunc
nullptr, // isStandaloneSAXFunc
nullptr, // hasInternalSubsetSAXFunc
nullptr, // hasExternalSubsetSAXFunc
nullptr, // resolveEntitySAXFunc
nullptr, // getEntitySAXFunc
nullptr, // entityDeclSAXFunc
nullptr, // notationDeclSAXFunc
nullptr, // attributeDeclSAXFunc
nullptr, // elementDeclSAXFunc
nullptr, // unparsedEntityDeclSAXFunc
nullptr, // setDocumentLocatorSAXFunc
nullptr, // startDocumentSAXFunc
nullptr, // endDocumentSAXFunc
nullptr, // startElementSAXFunc
nullptr, // endElementSAXFunc
nullptr, // referenceSAXFunc
&mlCharacters, // charactersSAXFunc
0, // ignorableWhitespaceSAXFunc
0, // processingInstructionSAXFunc
0, // commentSAXFunc
0, // warningSAXFunc
0, // errorSAXFunc
0, // fatalErrorSAXFunc
0, // getParameterEntitySAXFunc
0, // cdataBlockSAXFunc
0, // externalSubsetSAXFunc
nullptr, // ignorableWhitespaceSAXFunc
nullptr, // processingInstructionSAXFunc
nullptr, // commentSAXFunc
nullptr, // warningSAXFunc
nullptr, // errorSAXFunc
nullptr, // fatalErrorSAXFunc
nullptr, // getParameterEntitySAXFunc
nullptr, // cdataBlockSAXFunc
nullptr, // externalSubsetSAXFunc
XML_SAX2_MAGIC, // unsigned int initialized
0, // void * _private
nullptr, // void * _private
&mlStartElement, // startElementNsSAX2Func
&mlEndElement, // endElementNsSAX2Func
0, // xmlStructuredErrorFunc
nullptr, // xmlStructuredErrorFunc
};
} // namespace
XmlParser::XmlParser(ParserStateMachine* psm)
: psm_(psm),
sessionData_(psm),
ctx_(xmlCreatePushParserCtxt(&mySAXHandler, &sessionData_, 0, 0, 0)),
ctx_(xmlCreatePushParserCtxt(&mySAXHandler, &sessionData_, nullptr, 0, nullptr)),
lastError_(0)
{}
@ -198,7 +198,7 @@ int XmlParser::reset()
{
psm_->reset();
sessionData_.reset();
int rv = xmlCtxtResetPush(ctx_, 0, 0, 0, 0);
int rv = xmlCtxtResetPush(ctx_, nullptr, 0, nullptr, nullptr);
if(rv != 0) {
return lastError_ = ERR_RESET;
} else {

View File

@ -37,10 +37,10 @@
namespace aria2 {
XmlAttr::XmlAttr()
: localname(0),
prefix(0),
nsUri(0),
value(0),
: localname(nullptr),
prefix(nullptr),
nsUri(nullptr),
value(nullptr),
valueLength(0)
{}

View File

@ -65,7 +65,7 @@ bool parseFile(const std::string& filename, ParserStateMachine* psm)
}
}
if(nread == 0 && retval) {
if(ps.parseFinal(0, 0) < 0) {
if(ps.parseFinal(nullptr, 0) < 0) {
retval = false;
}
}

View File

@ -62,7 +62,7 @@ void XmlRpcDiskWriter::writeData(const unsigned char* data, size_t len,
int XmlRpcDiskWriter::finalize()
{
return parser_.parseFinal(0, 0);
return parser_.parseFinal(nullptr, 0);
}
RpcRequest XmlRpcDiskWriter::getResult()

View File

@ -69,7 +69,7 @@
namespace aria2 {
Session::Session(const KeyVals& options)
: context(new Context(false, 0, 0, options))
: context(new Context(false, 0, nullptr, options))
{}
Session::~Session()
@ -78,12 +78,12 @@ Session::~Session()
SessionConfig::SessionConfig()
: keepRunning(false),
useSignalHandler(true),
downloadEventCallback(0),
userData(0)
downloadEventCallback(nullptr),
userData(nullptr)
{}
namespace {
Platform* platform = 0;
Platform* platform = nullptr;
} // namespace
int libraryInit()
@ -934,7 +934,7 @@ DownloadHandle* getDownloadHandle(Session* session, A2Gid gid)
return new DownloadResultDH(ds);
}
}
return 0;
return nullptr;
}
void deleteDownloadHandle(DownloadHandle* dh)

View File

@ -143,7 +143,7 @@ std::unique_ptr<Metalinker> parseBinaryStream
offread += nread;
}
if(nread == 0 && retval) {
if(ps.parseFinal(0, 0) < 0) {
if(ps.parseFinal(nullptr, 0) < 0) {
retval = false;
}
}

View File

@ -867,7 +867,7 @@ ssize_t parse_content_disposition(char *dest, size_t destlen,
const char **charsetp, size_t *charsetlenp,
const char *in, size_t len)
{
const char *p = in, *eop = in + len, *mark_first = NULL, *mark_last = NULL;
const char *p = in, *eop = in + len, *mark_first = nullptr, *mark_last = nullptr;
int state = CD_BEFORE_DISPOSITION_TYPE;
int in_file_parm = 0;
int flags = 0;
@ -880,7 +880,7 @@ ssize_t parse_content_disposition(char *dest, size_t destlen,
uint32_t dfa_code = 0;
uint8_t pctval = 0;
*charsetp = NULL;
*charsetp = nullptr;
*charsetlenp = 0;
for(; p != eop; ++p) {
@ -1226,7 +1226,7 @@ bool isNumericHost(const std::string& name)
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_NUMERICHOST;
if(getaddrinfo(name.c_str(), 0, &hints, &res)) {
if(getaddrinfo(name.c_str(), nullptr, &hints, &res)) {
return false;
}
freeaddrinfo(res);
@ -1315,7 +1315,7 @@ void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
sigact.sa_handler = handler;
sigact.sa_flags = flags;
sigact.sa_mask = *mask;
sigaction(sig, &sigact, NULL);
sigaction(sig, &sigact, nullptr);
#else
signal(sig, handler);
#endif // HAVE_SIGACTION
@ -1847,13 +1847,13 @@ void executeHook
cmdlineLen = utf8ToWChar(wcharCmdline.get(), cmdlineLen, cmdline.c_str());
assert(cmdlineLen > 0);
A2_LOG_INFO(fmt("Executing user command: %s", cmdline.c_str()));
DWORD rc = CreateProcessW(batch ? utf8ToWChar(cmdexe).c_str() : NULL,
DWORD rc = CreateProcessW(batch ? utf8ToWChar(cmdexe).c_str() : nullptr,
wcharCmdline.get(),
NULL,
NULL,
nullptr,
nullptr,
true,
0,
NULL,
nullptr,
0,
&si,
&pi);

View File

@ -557,7 +557,7 @@ void DefaultBtProgressInfoFileTest::testUpdateFilename()
std::shared_ptr<DownloadContext> dctx
(new DownloadContext(1024, 81920, A2_TEST_DIR"/file1"));
DefaultBtProgressInfoFile infoFile(dctx, std::shared_ptr<MockPieceStorage>(), 0);
DefaultBtProgressInfoFile infoFile(dctx, std::shared_ptr<MockPieceStorage>(), nullptr);
#ifdef ENABLE_BITTORRENT
infoFile.setBtRuntime(btRuntime_);
infoFile.setPeerStorage(peerStorage_);

View File

@ -40,7 +40,7 @@ namespace aria2 {
const std::string GZipDecoder::NAME("GZipDecoder");
GZipDecoder::GZipDecoder():strm_(0), finished_(false) {}
GZipDecoder::GZipDecoder():strm_(nullptr), finished_(false) {}
GZipDecoder::~GZipDecoder()
{
@ -69,7 +69,7 @@ void GZipDecoder::release()
if(strm_) {
inflateEnd(strm_);
delete strm_;
strm_ = 0;
strm_ = nullptr;
}
}

View File

@ -37,7 +37,7 @@ void GrowSegmentTest::testClear()
GrowSegment segment(std::shared_ptr<Piece>(new Piece()));
segment.updateWrittenLength(32*1024);
CPPUNIT_ASSERT_EQUAL(32*1024, segment.getWrittenLength());
segment.clear(0);
segment.clear(nullptr);
CPPUNIT_ASSERT_EQUAL(0, segment.getWrittenLength());
}

View File

@ -229,7 +229,7 @@ void IndexedListTest::testGet()
int b = 1;
list.push_back(123, &a);
list.push_back(1, &b);
CPPUNIT_ASSERT_EQUAL((int*)0, list.get(1000));
CPPUNIT_ASSERT_EQUAL((int*)nullptr, list.get(1000));
CPPUNIT_ASSERT_EQUAL(&a, list.get(123));
}

View File

@ -270,7 +270,7 @@ void MultiDiskAdaptorTest::testResetDiskWriterEntries()
void readFile(const std::string& filename, char* buf, int bufLength) {
FILE* f = fopen(filename.c_str(), "r");
if(f == NULL) {
if(f == nullptr) {
CPPUNIT_FAIL(strerror(errno));
}
int retval = fread(buf, bufLength, 1, f);

View File

@ -684,7 +684,7 @@ void RpcMethodTest::testChangeGlobalOption_withNotAllowedOption()
void RpcMethodTest::testNoSuchMethod()
{
NoSuchMethodRpcMethod m;
auto res = m.execute(createReq("make.hamburger"), 0);
auto res = m.execute(createReq("make.hamburger"), nullptr);
CPPUNIT_ASSERT_EQUAL(1, res.code);
CPPUNIT_ASSERT_EQUAL(std::string("No such method: make.hamburger"),
getString(downcast<Dict>(res.param), "faultString"));

View File

@ -68,7 +68,7 @@ void SegmentTest::testClear()
PiecedSegment s(16*1024*10, p);
s.updateWrittenLength(16*1024*10);
CPPUNIT_ASSERT_EQUAL(16*1024*10, s.getWrittenLength());
s.clear(0);
s.clear(nullptr);
CPPUNIT_ASSERT_EQUAL(0, s.getWrittenLength());
}

View File

@ -87,7 +87,7 @@ void SocketCoreTest::testInetNtop()
{
std::string s = "192.168.0.1";
addrinfo* res;
CPPUNIT_ASSERT_EQUAL(0, callGetaddrinfo(&res, s.c_str(), 0, AF_INET,
CPPUNIT_ASSERT_EQUAL(0, callGetaddrinfo(&res, s.c_str(), nullptr, AF_INET,
SOCK_STREAM, 0, 0));
std::unique_ptr<addrinfo, decltype(&freeaddrinfo)> resDeleter
(res, freeaddrinfo);
@ -100,7 +100,7 @@ void SocketCoreTest::testInetNtop()
{
std::string s = "2001:db8::2:1";
addrinfo* res;
CPPUNIT_ASSERT_EQUAL(0, callGetaddrinfo(&res, s.c_str(), 0, AF_INET6,
CPPUNIT_ASSERT_EQUAL(0, callGetaddrinfo(&res, s.c_str(), nullptr, AF_INET6,
SOCK_STREAM, 0, 0));
std::unique_ptr<addrinfo, decltype(&freeaddrinfo)> resDeleter
(res, freeaddrinfo);

View File

@ -113,7 +113,7 @@ void TimeTest::testToHTTPDate()
void TimeTest::testElapsed()
{
struct timeval now;
gettimeofday(&now, 0);
gettimeofday(&now, nullptr);
{
struct timeval tv = now;
CPPUNIT_ASSERT(!Time(tv).elapsed(1));

View File

@ -391,28 +391,28 @@ void UriSplitTest::testUriSplit()
void UriSplitTest::testUriSplit_fail()
{
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, ""));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "h"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http:"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http:a"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http:/"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http:/a"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://:host"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://@user@host"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:65536"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass?"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass@host:65536"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass@host:x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass@host:80x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user@"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://[]"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://[::"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user[::1]"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user[::1]x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(NULL, "http://user:pass[::1]"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, ""));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "h"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http:"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http:a"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http:/"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http:/a"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://:host"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://@user@host"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:65536"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass?"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass@host:65536"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass@host:x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass@host:80x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user@"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://[]"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://[::"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user[::1]"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user[::1]x"));
CPPUNIT_ASSERT_EQUAL(-1, uri_split(nullptr, "http://user:pass[::1]"));
}
} // namespace aria2