Refer to nullptr not NULL
authorChristopher Dykes <cdykes@fb.com>
Thu, 8 Jun 2017 21:48:12 +0000 (14:48 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 8 Jun 2017 21:51:40 +0000 (14:51 -0700)
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

folly/ConcurrentSkipList.h
folly/Malloc.h
folly/Synchronized.h
folly/experimental/exception_tracer/ExceptionTracer.cpp
folly/experimental/symbolizer/Elf.h
folly/io/IOBuf.cpp
folly/io/async/AsyncSSLSocket.cpp
folly/io/async/EventBase.cpp
folly/portability/OpenSSL.cpp
folly/stats/Histogram.h

index 7d5cb9589c478fa2bcdf916a623d9149bf0fab10..8b06f3317db976f165676d407dd755a912b00d95 100644 (file)
@@ -235,7 +235,7 @@ class ConcurrentSkipList {
 
       // 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
-      // return NULL or another node.
+      // return nullptr or another node.
       succs[layer] = foundNode ? foundNode : node;
     }
     return foundLayer;
index ca9e7ae15705da3b5698b2a9e30df85cfd64fea3..cb7bfe37bd57c72027913b3db4bebac71f7dfc0a 100644 (file)
@@ -67,7 +67,7 @@ namespace folly {
 
 /**
  * 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.
  */
 extern "C" void* mallocx(size_t, int)
@@ -148,9 +148,9 @@ namespace folly {
  * Determine if we are using jemalloc or not.
  */
 FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept {
-  // Checking for rallocx != NULL is not sufficient; we may be in a dlopen()ed
-  // module that depends on libjemalloc, so rallocx is resolved, but the main
-  // program might be using a different memory allocator.
+  // Checking for rallocx != nullptr is not sufficient; we may be in a
+  // dlopen()ed module that depends on libjemalloc, so rallocx is resolved, but
+  // the main program might be using a different memory allocator.
   // How do we determine that we're using jemalloc? In the hackiest
   // way possible. We allocate memory using malloc() and see if the
   // per-thread counter of allocated memory increases. This makes me
index 5d912034b3342db94f8c1b411a860ca173d08989..4fce71b580d5e2f83b0eaf78d24a2fb429423253 100644 (file)
@@ -626,7 +626,7 @@ struct Synchronized : public SynchronizedBase<
 
   /**
    * 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.
    * In the future it will be marked with a deprecation attribute to emit
@@ -638,7 +638,7 @@ struct Synchronized : public SynchronizedBase<
 
   /**
    * 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.
    * In the future it will be marked with a deprecation attribute to emit
index e7ef30f41bd29d19465015de106762a89eb5992a..2c6e109adb4704fb57c03e57378d58ae29efc56c 100644 (file)
@@ -155,7 +155,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
     // Dependent exceptions (thrown via std::rethrow_exception) aren't
     // standard ABI __cxa_exception objects, and are correctly labeled as
     // 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 =
       isAbiCppException(currentException) ?
       currentException->exceptionType :
index 9676e23c045ad25d0de26da5e561479a1afe6f8b..b16c87186330689ddf2d92e0357a4e21a2ff4413 100644 (file)
@@ -51,7 +51,7 @@ class ElfFile {
   // Open the ELF file.
   // Returns 0 on success, kSystemError (guaranteed to be -1) (and sets errno)
   // 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.
   enum {
     kSuccess = 0,
index c34b5f41213003843d67dbe21a7dd8e35f52bbb4..5698606106d38da2ddb6734ebc8517254b916d86 100644 (file)
@@ -136,7 +136,7 @@ IOBuf::SharedInfo::SharedInfo(FreeFunction fn, void* arg)
 void* IOBuf::operator new(size_t size) {
   size_t fullSize = offsetof(HeapStorage, buf) + size;
   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)) {
     throw std::bad_alloc();
   }
index 234ab5ae9917c20ca217a0028cadedbad8ceccdf..1379bf90bc91fe37c0285cda33e7522882b85871 100644 (file)
@@ -406,7 +406,7 @@ size_t AsyncSSLSocket::getRawBytesWritten() const {
     return 0;
   }
   BIO* next = BIO_next(b);
-  while (next != NULL) {
+  while (next != nullptr) {
     b = next;
     next = BIO_next(b);
   }
index a485d33254908c9ac546038e124fadce313b467b..cf8a87fa84b5072db3ef48e1eda081b39402c0fd 100644 (file)
@@ -94,7 +94,7 @@ EventBase::EventBase(bool enableTimeMeasurement)
     // The value 'current_base' (libevent 1) or
     // 'event_global_current_base_' (libevent 2) is filled in by event_set(),
     // 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().
     event_set(&ev, 0, 0, nullptr, nullptr);
     if (!ev.ev_base) {
index fb47df42b8e6dee60cacc1f5cdf2d9b78df7693f..ccaea7657fd32ff312dacfdf787ed6eb61229901 100644 (file)
@@ -97,8 +97,8 @@ unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION* s) {
 
 // This is taken from OpenSSL 1.1.0
 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
-   * parameters MUST be non-NULL.  q may remain NULL.
+  /* If the fields p and g in d are nullptr, the corresponding input
+   * parameters MUST not be nullptr.  q may remain nullptr.
    */
   if (dh == nullptr || (dh->p == nullptr && p == nullptr) ||
       (dh->g == nullptr && g == nullptr)) {
index e8e8c97c18de786d6f905fefc9e2b590c8ceda87..ca45ba3bc4b4160a95fe0b8e23692376331ca79c 100644 (file)
@@ -417,7 +417,7 @@ class Histogram {
    * Get the bucket that the specified percentile falls into
    *
    * 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(
       double pct,