Commit 55af3d19 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Refer to nullptr not NULL

Summary:
Folly is a C++ library not a C library, and (almost) universally uses `nullptr` everywhere, so refer to `nullptr` rather than `NULL`.
This also fixes the 1 place in our actual code where we were using `NULL` rather than `nullptr`.

Reviewed By: yfeldblum

Differential Revision: D5204766

fbshipit-source-id: 2a5d5011a28d7d5dd48789f60643a656f51b9732
parent 16f34c7d
...@@ -235,7 +235,7 @@ class ConcurrentSkipList { ...@@ -235,7 +235,7 @@ class ConcurrentSkipList {
// if found, succs[0..foundLayer] need to point to the cached foundNode, // if found, succs[0..foundLayer] need to point to the cached foundNode,
// as foundNode might be deleted at the same time thus pred->skip() can // as foundNode might be deleted at the same time thus pred->skip() can
// return NULL or another node. // return nullptr or another node.
succs[layer] = foundNode ? foundNode : node; succs[layer] = foundNode ? foundNode : node;
} }
return foundLayer; return foundLayer;
......
...@@ -67,7 +67,7 @@ namespace folly { ...@@ -67,7 +67,7 @@ namespace folly {
/** /**
* Declare *allocx() and mallctl*() as weak symbols. These will be provided by * Declare *allocx() and mallctl*() as weak symbols. These will be provided by
* jemalloc if we are using jemalloc, or will be NULL if we are using another * jemalloc if we are using jemalloc, or will be nullptr if we are using another
* malloc implementation. * malloc implementation.
*/ */
extern "C" void* mallocx(size_t, int) extern "C" void* mallocx(size_t, int)
...@@ -148,9 +148,9 @@ namespace folly { ...@@ -148,9 +148,9 @@ namespace folly {
* Determine if we are using jemalloc or not. * Determine if we are using jemalloc or not.
*/ */
FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept { FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept {
// Checking for rallocx != NULL is not sufficient; we may be in a dlopen()ed // Checking for rallocx != nullptr is not sufficient; we may be in a
// module that depends on libjemalloc, so rallocx is resolved, but the main // dlopen()ed module that depends on libjemalloc, so rallocx is resolved, but
// program might be using a different memory allocator. // the main program might be using a different memory allocator.
// How do we determine that we're using jemalloc? In the hackiest // How do we determine that we're using jemalloc? In the hackiest
// way possible. We allocate memory using malloc() and see if the // way possible. We allocate memory using malloc() and see if the
// per-thread counter of allocated memory increases. This makes me // per-thread counter of allocated memory increases. This makes me
......
...@@ -626,7 +626,7 @@ struct Synchronized : public SynchronizedBase< ...@@ -626,7 +626,7 @@ struct Synchronized : public SynchronizedBase<
/** /**
* Attempts to acquire for a given number of milliseconds. If * Attempts to acquire for a given number of milliseconds. If
* acquisition is unsuccessful, the returned LockedPtr is NULL. * acquisition is unsuccessful, the returned LockedPtr is nullptr.
* *
* NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead. * NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead.
* In the future it will be marked with a deprecation attribute to emit * In the future it will be marked with a deprecation attribute to emit
...@@ -638,7 +638,7 @@ struct Synchronized : public SynchronizedBase< ...@@ -638,7 +638,7 @@ struct Synchronized : public SynchronizedBase<
/** /**
* Attempts to acquire for a given number of milliseconds. If * Attempts to acquire for a given number of milliseconds. If
* acquisition is unsuccessful, the returned ConstLockedPtr is NULL. * acquisition is unsuccessful, the returned ConstLockedPtr is nullptr.
* *
* NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead. * NOTE: This API is deprecated. Use lock(), wlock(), or rlock() instead.
* In the future it will be marked with a deprecation attribute to emit * In the future it will be marked with a deprecation attribute to emit
......
...@@ -155,7 +155,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() { ...@@ -155,7 +155,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
// Dependent exceptions (thrown via std::rethrow_exception) aren't // Dependent exceptions (thrown via std::rethrow_exception) aren't
// standard ABI __cxa_exception objects, and are correctly labeled as // standard ABI __cxa_exception objects, and are correctly labeled as
// such in the exception_class field. We could try to extract the // such in the exception_class field. We could try to extract the
// primary exception type in horribly hacky ways, but, for now, NULL. // primary exception type in horribly hacky ways, but, for now, nullptr.
info.type = info.type =
isAbiCppException(currentException) ? isAbiCppException(currentException) ?
currentException->exceptionType : currentException->exceptionType :
......
...@@ -51,7 +51,7 @@ class ElfFile { ...@@ -51,7 +51,7 @@ class ElfFile {
// Open the ELF file. // Open the ELF file.
// Returns 0 on success, kSystemError (guaranteed to be -1) (and sets errno) // Returns 0 on success, kSystemError (guaranteed to be -1) (and sets errno)
// on IO error, kInvalidElfFile (and sets errno to EINVAL) for an invalid // on IO error, kInvalidElfFile (and sets errno to EINVAL) for an invalid
// Elf file. On error, if msg is not NULL, sets *msg to a static string // Elf file. On error, if msg is not nullptr, sets *msg to a static string
// indicating what failed. // indicating what failed.
enum { enum {
kSuccess = 0, kSuccess = 0,
......
...@@ -136,7 +136,7 @@ IOBuf::SharedInfo::SharedInfo(FreeFunction fn, void* arg) ...@@ -136,7 +136,7 @@ IOBuf::SharedInfo::SharedInfo(FreeFunction fn, void* arg)
void* IOBuf::operator new(size_t size) { void* IOBuf::operator new(size_t size) {
size_t fullSize = offsetof(HeapStorage, buf) + size; size_t fullSize = offsetof(HeapStorage, buf) + size;
auto* storage = static_cast<HeapStorage*>(malloc(fullSize)); auto* storage = static_cast<HeapStorage*>(malloc(fullSize));
// operator new is not allowed to return NULL // operator new is not allowed to return nullptr
if (UNLIKELY(storage == nullptr)) { if (UNLIKELY(storage == nullptr)) {
throw std::bad_alloc(); throw std::bad_alloc();
} }
......
...@@ -406,7 +406,7 @@ size_t AsyncSSLSocket::getRawBytesWritten() const { ...@@ -406,7 +406,7 @@ size_t AsyncSSLSocket::getRawBytesWritten() const {
return 0; return 0;
} }
BIO* next = BIO_next(b); BIO* next = BIO_next(b);
while (next != NULL) { while (next != nullptr) {
b = next; b = next;
next = BIO_next(b); next = BIO_next(b);
} }
......
...@@ -94,7 +94,7 @@ EventBase::EventBase(bool enableTimeMeasurement) ...@@ -94,7 +94,7 @@ EventBase::EventBase(bool enableTimeMeasurement)
// The value 'current_base' (libevent 1) or // The value 'current_base' (libevent 1) or
// 'event_global_current_base_' (libevent 2) is filled in by event_set(), // 'event_global_current_base_' (libevent 2) is filled in by event_set(),
// allowing examination of its value without an explicit reference here. // allowing examination of its value without an explicit reference here.
// If ev.ev_base is NULL, then event_init() must be called, otherwise // If ev.ev_base is nullptr, then event_init() must be called, otherwise
// call event_base_new(). // call event_base_new().
event_set(&ev, 0, 0, nullptr, nullptr); event_set(&ev, 0, 0, nullptr, nullptr);
if (!ev.ev_base) { if (!ev.ev_base) {
......
...@@ -97,8 +97,8 @@ unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION* s) { ...@@ -97,8 +97,8 @@ unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION* s) {
// This is taken from OpenSSL 1.1.0 // This is taken from OpenSSL 1.1.0
int DH_set0_pqg(DH* dh, BIGNUM* p, BIGNUM* q, BIGNUM* g) { int DH_set0_pqg(DH* dh, BIGNUM* p, BIGNUM* q, BIGNUM* g) {
/* If the fields p and g in d are NULL, the corresponding input /* If the fields p and g in d are nullptr, the corresponding input
* parameters MUST be non-NULL. q may remain NULL. * parameters MUST not be nullptr. q may remain nullptr.
*/ */
if (dh == nullptr || (dh->p == nullptr && p == nullptr) || if (dh == nullptr || (dh->p == nullptr && p == nullptr) ||
(dh->g == nullptr && g == nullptr)) { (dh->g == nullptr && g == nullptr)) {
......
...@@ -417,7 +417,7 @@ class Histogram { ...@@ -417,7 +417,7 @@ class Histogram {
* Get the bucket that the specified percentile falls into * Get the bucket that the specified percentile falls into
* *
* The lowest and highest percentile data points in returned bucket will be * The lowest and highest percentile data points in returned bucket will be
* returned in the lowPct and highPct arguments, if they are non-NULL. * returned in the lowPct and highPct arguments, if they are not nullptr.
*/ */
size_t getPercentileBucketIdx( size_t getPercentileBucketIdx(
double pct, double pct,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment