summaryrefslogtreecommitdiff
path: root/src/node_crypto_bio.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-10-22 03:29:32 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2014-10-23 22:49:58 +0200
commit2d82cdf670d88f2f5acc7d1b759cf0cbb3f99962 (patch)
treea6957d0fa3f6cc76e100ae279e389447b5055029 /src/node_crypto_bio.cc
parentb2b59febe8bf1d411e7d8faacd23789784aac1f0 (diff)
downloadandroid-node-v8-2d82cdf670d88f2f5acc7d1b759cf0cbb3f99962.tar.gz
android-node-v8-2d82cdf670d88f2f5acc7d1b759cf0cbb3f99962.tar.bz2
android-node-v8-2d82cdf670d88f2f5acc7d1b759cf0cbb3f99962.zip
src: replace NULL with nullptr
Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
Diffstat (limited to 'src/node_crypto_bio.cc')
-rw-r--r--src/node_crypto_bio.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/node_crypto_bio.cc b/src/node_crypto_bio.cc
index 16ec515de9..e6ccb33f8f 100644
--- a/src/node_crypto_bio.cc
+++ b/src/node_crypto_bio.cc
@@ -37,7 +37,7 @@ const BIO_METHOD NodeBIO::method = {
NodeBIO::Ctrl,
NodeBIO::New,
NodeBIO::Free,
- NULL
+ nullptr
};
@@ -61,13 +61,13 @@ int NodeBIO::New(BIO* bio) {
int NodeBIO::Free(BIO* bio) {
- if (bio == NULL)
+ if (bio == nullptr)
return 0;
if (bio->shutdown) {
- if (bio->init && bio->ptr != NULL) {
+ if (bio->init && bio->ptr != nullptr) {
delete FromBIO(bio);
- bio->ptr = NULL;
+ bio->ptr = nullptr;
}
}
@@ -151,7 +151,7 @@ int NodeBIO::Gets(BIO* bio, char* out, int size) {
if (i < size && i >= 0 && static_cast<size_t>(i) < nbio->Length())
i++;
- // Shift `i` a bit to NULL-terminate string later
+ // Shift `i` a bit to nullptr-terminate string later
if (size == i)
i--;
@@ -183,8 +183,8 @@ long NodeBIO::Ctrl(BIO* bio, int cmd, long num, void* ptr) {
break;
case BIO_CTRL_INFO:
ret = nbio->Length();
- if (ptr != NULL)
- *reinterpret_cast<void**>(ptr) = NULL;
+ if (ptr != nullptr)
+ *reinterpret_cast<void**>(ptr) = nullptr;
break;
case BIO_C_SET_BUF_MEM:
CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
@@ -252,7 +252,7 @@ size_t NodeBIO::Read(char* out, size_t size) {
avail = left;
// Copy data
- if (out != NULL)
+ if (out != nullptr)
memcpy(out + offset, read_head_->data_ + read_head_->read_pos_, avail);
read_head_->read_pos_ += avail;
@@ -274,7 +274,7 @@ size_t NodeBIO::Read(char* out, size_t size) {
void NodeBIO::FreeEmpty() {
- if (write_head_ == NULL)
+ if (write_head_ == nullptr)
return;
Buffer* child = write_head_->next_;
if (child == write_head_ || child == read_head_)
@@ -413,16 +413,16 @@ void NodeBIO::TryAllocateForWrite(size_t hint) {
Buffer* w = write_head_;
Buffer* r = read_head_;
// If write head is full, next buffer is either read head or not empty.
- if (w == NULL ||
+ if (w == nullptr ||
(w->write_pos_ == w->len_ &&
(w->next_ == r || w->next_->write_pos_ != 0))) {
- size_t len = w == NULL ? initial_ :
+ size_t len = w == nullptr ? initial_ :
kThroughputBufferLength;
if (len < hint)
len = hint;
Buffer* next = new Buffer(len);
- if (w == NULL) {
+ if (w == nullptr) {
next->next_ = next;
write_head_ = next;
read_head_ = next;
@@ -435,7 +435,7 @@ void NodeBIO::TryAllocateForWrite(size_t hint) {
void NodeBIO::Reset() {
- if (read_head_ == NULL)
+ if (read_head_ == nullptr)
return;
while (read_head_->read_pos_ != read_head_->write_pos_) {
@@ -453,7 +453,7 @@ void NodeBIO::Reset() {
NodeBIO::~NodeBIO() {
- if (read_head_ == NULL)
+ if (read_head_ == nullptr)
return;
Buffer* current = read_head_;
@@ -463,8 +463,8 @@ NodeBIO::~NodeBIO() {
current = next;
} while (current != read_head_);
- read_head_ = NULL;
- write_head_ = NULL;
+ read_head_ = nullptr;
+ write_head_ = nullptr;
}
} // namespace node