Bug 784739 - Switch from NULL to nullptr in xpcom/ (2/3); r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 10 Oct 2013 16:41:39 -0400
changeset 150398 20f2a3e61f370b7374d78c7c03f4420f92f12756
parent 150397 ec55161f805947fe5c0d2d29fa02fe427eac89c4
child 150399 ad59ee55f59606bb7d07bf0d442a9078041c20a1
push id25437
push userkwierso@gmail.com
push dateFri, 11 Oct 2013 02:00:22 +0000
treeherdermozilla-central@672cd63528d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs784739
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 784739 - Switch from NULL to nullptr in xpcom/ (2/3); r=ehsan
xpcom/glue/DeadlockDetector.h
xpcom/glue/FileUtils.cpp
xpcom/glue/FileUtils.h
xpcom/glue/GenericModule.cpp
xpcom/glue/nsBaseHashtable.h
xpcom/glue/nsCOMArray.h
xpcom/glue/nsCOMPtr.h
xpcom/glue/nsCRTGlue.cpp
xpcom/glue/nsCRTGlue.h
xpcom/glue/nsClassHashtable.h
xpcom/glue/nsClassInfoImpl.cpp
xpcom/glue/nsHashKeys.h
xpcom/glue/nsIClassInfoImpl.h
xpcom/glue/nsID.cpp
xpcom/glue/nsINIParser.cpp
xpcom/glue/nsISupportsImpl.h
xpcom/glue/nsISupportsUtils.h
xpcom/glue/nsProxyRelease.h
xpcom/glue/nsTHashtable.h
xpcom/glue/nsTextFormatter.cpp
xpcom/glue/nsTextFormatter.h
xpcom/glue/nsVoidArray.h
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
xpcom/glue/tests/gtest/TestFileUtils.cpp
xpcom/io/SpecialSystemDirectory.cpp
xpcom/io/nsEscape.cpp
xpcom/io/nsLocalFileOS2.cpp
xpcom/io/nsLocalFileUnix.cpp
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsNativeCharsetUtils.cpp
xpcom/io/nsStringStream.cpp
xpcom/io/nsWildCard.cpp
--- a/xpcom/glue/DeadlockDetector.h
+++ b/xpcom/glue/DeadlockDetector.h
@@ -375,17 +375,17 @@ public:
     // removing resources possibly reduces the # of false positives,
     // and additionally saves space.  So it's a trade off; we have
     // chosen to err on the side of caution and not implement Remove().
 
     /**
      * CheckAcquisition This method is called after acquiring |aLast|,
      * but before trying to acquire |aProposed| from |aCallContext|.
      * It determines whether actually trying to acquire |aProposed|
-     * will create problems.  It is OK if |aLast| is NULL; this is
+     * will create problems.  It is OK if |aLast| is nullptr; this is
      * interpreted as |aProposed| being the thread's first acquisition
      * of its current chain.
      *
      * Iff acquiring |aProposed| may lead to deadlock for some thread
      * interleaving (including the current one!), the cyclical
      * dependency from which this was deduced is returned.  Otherwise,
      * 0 is returned.
      *
--- a/xpcom/glue/FileUtils.cpp
+++ b/xpcom/glue/FileUtils.cpp
@@ -261,28 +261,28 @@ static const uint32_t CPU_TYPE = CPU_TYP
 #else
 #define cpu_mach_header mach_header
 #endif
 
 class ScopedMMap
 {
 public:
   ScopedMMap(const char *aFilePath)
-    : buf(NULL)
+    : buf(nullptr)
   {
     fd = open(aFilePath, O_RDONLY);
     if (fd < 0) {
       return;
     }
     struct stat st;
     if (fstat(fd, &st) < 0) {
       return;
     }
     size = st.st_size;
-    buf = (char *)mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
+    buf = (char *)mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0);
   }
   ~ScopedMMap()
   {
     if (buf) {
       munmap(buf, size);
     }
     if (fd >= 0) {
       close(fd);
@@ -475,18 +475,18 @@ mozilla::ReadAheadFile(mozilla::pathstr_
 {
 #if defined(XP_WIN)
   if (!aFilePath) {
     if (aOutFd) {
       *aOutFd = INVALID_HANDLE_VALUE;
     }
     return;
   }
-  HANDLE fd = CreateFileW(aFilePath, GENERIC_READ, FILE_SHARE_READ,
-                          NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+  HANDLE fd = CreateFileW(aFilePath, GENERIC_READ, FILE_SHARE_READ, nullptr,
+                          OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
   if (aOutFd) {
     *aOutFd = fd;
   }
   if (fd == INVALID_HANDLE_VALUE) {
     return;
   }
   ReadAhead(fd, aOffset, aCount);
   if (!aOutFd) {
--- a/xpcom/glue/FileUtils.h
+++ b/xpcom/glue/FileUtils.h
@@ -54,19 +54,19 @@ typedef Scoped<ScopedCloseFDTraits> Scop
 /**
  * AutoFDClose is a RAII wrapper for PRFileDesc.
  *
  * Instances |PR_Close| their fds when they go out of scope.
  **/
 struct ScopedClosePRFDTraits
 {
   typedef PRFileDesc* type;
-  static type empty() { return NULL; }
+  static type empty() { return nullptr; }
   static void release(type fd) {
-    if (fd != NULL) {
+    if (fd != nullptr) {
       PR_Close(fd);
     }
   }
 };
 typedef Scoped<ScopedClosePRFDTraits> AutoFDClose;
 
 /* RAII wrapper for FILE descriptors */
 struct ScopedCloseFileTraits
--- a/xpcom/glue/GenericModule.cpp
+++ b/xpcom/glue/GenericModule.cpp
@@ -46,17 +46,17 @@ GenericModule::GetClassObject(nsICompone
 NS_IMETHODIMP
 GenericModule::RegisterSelf(nsIComponentManager* aCompMgr,
                             nsIFile* aLocation,
                             const char* aLoaderStr,
                             const char* aType)
 {
   nsCOMPtr<nsIComponentRegistrar> r = do_QueryInterface(aCompMgr);
   for (const Module::CIDEntry* e = mData->mCIDs; e->cid; ++e)
-    r->RegisterFactoryLocation(*e->cid, "", NULL, aLocation, aLoaderStr, aType);
+    r->RegisterFactoryLocation(*e->cid, "", nullptr, aLocation, aLoaderStr, aType);
 
   for (const Module::ContractIDEntry* e = mData->mContractIDs;
        e && e->contractid;
        ++e)
     r->RegisterFactoryLocation(*e->cid, "", e->contractid, aLocation, aLoaderStr, aType);
 
   nsCOMPtr<nsICategoryManager> catman;
   for (const Module::CategoryEntry* e = mData->mCategoryEntries;
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -260,17 +260,18 @@ public:
   size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                              mozilla::MallocSizeOf mallocSizeOf, void *userArg = nullptr) const
   {
     if (sizeOfEntryExcludingThis) {
       s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
       return PL_DHashTableSizeOfExcludingThis(&this->mTable, s_SizeOfStub,
                                               mallocSizeOf, &args);
     }
-    return PL_DHashTableSizeOfExcludingThis(&this->mTable, NULL, mallocSizeOf);
+    return PL_DHashTableSizeOfExcludingThis(&this->mTable, nullptr,
+                                            mallocSizeOf);
   }
 
 protected:
   /**
    * used internally during EnumerateRead.  Allocated on the stack.
    * @param func the enumerator passed to EnumerateRead
    * @param userArg the userArg passed to EnumerateRead
    */
--- a/xpcom/glue/nsCOMArray.h
+++ b/xpcom/glue/nsCOMArray.h
@@ -160,21 +160,21 @@ public:
     uint32_t Capacity() {
         return mArray.Capacity();
     }
 
     typedef size_t (* nsBaseArraySizeOfElementIncludingThisFunc)
         (nsISupports* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData);
 
     // Measures the size of the array's element storage, and if
-    // |aSizeOfElement| is non-NULL, measures the size of things pointed to by
-    // elements.
+    // |aSizeOfElement| is non-nullptr, measures the size of things pointed to
+    // by elements.
     size_t SizeOfExcludingThis(
              nsBaseArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis,
-             mozilla::MallocSizeOf aMallocSizeOf, void* aData = NULL) const;
+             mozilla::MallocSizeOf aMallocSizeOf, void* aData = nullptr) const;
 
 private:
     
     // the actual storage
     nsTArray<nsISupports*> mArray;
 
     // don't implement these, defaults will muck with refcounts!
     nsCOMArray_base& operator=(const nsCOMArray_base& other) MOZ_DELETE;
@@ -376,17 +376,17 @@ class nsCOMArray : public nsCOMArray_bas
     // Each element in an nsCOMArray<T> is actually a T*, so this function is
     // "IncludingThis" rather than "ExcludingThis" because it needs to measure
     // the memory taken by the T itself as well as anything it points to.
     typedef size_t (* nsCOMArraySizeOfElementIncludingThisFunc)
         (T* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData);
     
     size_t SizeOfExcludingThis(
              nsCOMArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, 
-             mozilla::MallocSizeOf aMallocSizeOf, void *aData = NULL) const {
+             mozilla::MallocSizeOf aMallocSizeOf, void *aData = nullptr) const {
         return nsCOMArray_base::SizeOfExcludingThis(
                  nsBaseArraySizeOfElementIncludingThisFunc(aSizeOfElementIncludingThis),
                  aMallocSizeOf, aData);
     }
 
 private:
 
     // don't implement these!
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -179,17 +179,17 @@ struct already_AddRefed
      *
      *    nsRefPtr<BaseClass> y = x.forget();
      *    return y.forget();
      */
     template<class U>
     operator already_AddRefed<U>()
     {
       U* tmp = mRawPtr;
-      mRawPtr = NULL;
+      mRawPtr = nullptr;
       return already_AddRefed<U>(tmp);
     }
 
     /**
      * This helper provides a static_cast replacement for already_AddRefed, so
      * if you have
      *
      *   already_AddRefed<Parent> F();
--- a/xpcom/glue/nsCRTGlue.cpp
+++ b/xpcom/glue/nsCRTGlue.cpp
@@ -36,38 +36,38 @@ NS_strspnp(const char *delims, const cha
 
   return str;
 }
 
 char*
 NS_strtok(const char *delims, char **str)
 {
   if (!*str)
-    return NULL;
+    return nullptr;
 
   char *ret = (char*) NS_strspnp(delims, *str);
 
   if (!*ret) {
     *str = ret;
-    return NULL;
+    return nullptr;
   }
 
   char *i = ret;
   do {
     for (const char *d = delims; *d != '\0'; ++d) {
       if (*i == *d) {
         *i = '\0';
         *str = ++i;
         return ret;
       }
     }
     ++i;
   } while (*i);
 
-  *str = NULL;
+  *str = nullptr;
   return ret;
 }
 
 uint32_t
 NS_strlen(const PRUnichar *aString)
 {
   const PRUnichar *end;
 
--- a/xpcom/glue/nsCRTGlue.h
+++ b/xpcom/glue/nsCRTGlue.h
@@ -27,17 +27,17 @@ NS_strspnp(const char *delims, const cha
  * until an additional delimiter or end-of-string is found. The final
  * delimiter is set to '\0'.
  *
  * @param delims The set of delimiters.
  * @param str    The string to search. This is an in-out parameter; it is
  *               reset to the end of the found token + 1, or to the
  *               end-of-string if there are no more tokens.
  * @return       The token. If no token is found (the string is only
- *               delimiter characters), NULL is returned.
+ *               delimiter characters), nullptr is returned.
  */
 NS_COM_GLUE char*
 NS_strtok(const char *delims, char **str);
 
 /**
  * "strlen" for PRUnichar strings
  */
 NS_COM_GLUE uint32_t
--- a/xpcom/glue/nsClassHashtable.h
+++ b/xpcom/glue/nsClassHashtable.h
@@ -38,23 +38,24 @@ public:
   /**
    * @copydoc nsBaseHashtable::Get
    * @param pData if the key doesn't exist, pData will be set to nullptr.
    */
   bool Get(KeyType aKey, UserDataType* pData) const;
 
   /**
    * @copydoc nsBaseHashtable::Get
-   * @returns NULL if the key is not present.
+   * @returns nullptr if the key is not present.
    */
   UserDataType Get(KeyType aKey) const;
 
   /**
    * Remove the entry for the given key from the hashtable and return it in
-   * aOut.  If the key is not in the hashtable, aOut's pointer is set to NULL.
+   * aOut.  If the key is not in the hashtable, aOut's pointer is set to
+   * nullptr.
    *
    * Normally, an entry is deleted when it's removed from an nsClassHashtable,
    * but this function transfers ownership of the entry back to the caller
    * through aOut -- the entry will be deleted when aOut goes out of scope.
    *
    * @param aKey the key to get and remove from the hashtable
    */
   void RemoveAndForget(KeyType aKey, nsAutoPtr<T> &aOut);
@@ -86,17 +87,17 @@ nsClassHashtable<KeyClass,T>::Get(KeyTyp
 
 template<class KeyClass,class T>
 T*
 nsClassHashtable<KeyClass,T>::Get(KeyType aKey) const
 {
   typename base_type::EntryType* ent = this->GetEntry(aKey);
 
   if (!ent)
-    return NULL;
+    return nullptr;
 
   return ent->mData;
 }
 
 template<class KeyClass,class T>
 void
 nsClassHashtable<KeyClass,T>::RemoveAndForget(KeyType aKey, nsAutoPtr<T> &aOut)
 {
--- a/xpcom/glue/nsClassInfoImpl.cpp
+++ b/xpcom/glue/nsClassInfoImpl.cpp
@@ -32,32 +32,32 @@ GenericClassInfo::GetHelperForLanguage(u
     return mData->getlanguagehelper(language, helper);
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 GenericClassInfo::GetContractID(char** contractid)
 {
   NS_ERROR("GetContractID not implemented");
-  *contractid = NULL;
+  *contractid = nullptr;
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 GenericClassInfo::GetClassDescription(char** description)
 {
-  *description = NULL;
+  *description = nullptr;
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 GenericClassInfo::GetClassID(nsCID** classid)
 {
   NS_ERROR("GetClassID not implemented");
-  *classid = NULL;
+  *classid = nullptr;
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 GenericClassInfo::GetImplementationLanguage(uint32_t* language)
 {
   *language = nsIProgrammingLanguage::CPLUSPLUS;
   return NS_OK;
--- a/xpcom/glue/nsHashKeys.h
+++ b/xpcom/glue/nsHashKeys.h
@@ -347,17 +347,17 @@ class nsPtrHashKey : public PLDHashEntry
   }
   enum { ALLOW_MEMMOVE = true };
 
  protected:
   T *mKey;
 };
 
 /**
- * hashkey wrapper using T* KeyType that sets key to NULL upon
+ * hashkey wrapper using T* KeyType that sets key to nullptr upon
  * destruction. Relevant only in cases where a memory pointer-scanner
  * like valgrind might get confused about stale references.
  *
  * @see nsTHashtable::EntryType for specification
  */
 
 template<class T>
 class nsClearingPtrHashKey : public nsPtrHashKey<T>
--- a/xpcom/glue/nsIClassInfoImpl.h
+++ b/xpcom/glue/nsIClassInfoImpl.h
@@ -26,26 +26,26 @@
  *
  * you should already have the following nsISupports implementation in its cpp
  * file:
  *
  *   NS_IMPL_ISUPPORTS2(nsFooBar, nsIFoo, nsIBar).
  *
  * Change this to
  *
- *   NS_IMPL_CLASSINFO(nsFooBar, NULL, 0, NS_FOOBAR_CID)
+ *   NS_IMPL_CLASSINFO(nsFooBar, nullptr, 0, NS_FOOBAR_CID)
  *   NS_IMPL_ISUPPORTS2_CI(nsFooBar, nsIFoo, nsIBar)
  *
  * If nsFooBar is threadsafe, change the 0 above to nsIClassInfo::THREADSAFE.
  * If it's a singleton, use nsIClassInfo::SINGLETON.  The full list of flags is
  * in nsIClassInfo.idl.
  *
- * The NULL parameter is there so you can pass a function for converting from
- * an XPCOM object to a scriptable helper.  Unless you're doing specialized JS
- * work, you can probably leave this as NULL.
+ * The nullptr parameter is there so you can pass a function for converting
+ * from an XPCOM object to a scriptable helper.  Unless you're doing
+ * specialized JS work, you can probably leave this as nullptr.
  *
  * This file also defines the NS_IMPL_QUERY_INTERFACE2_CI macro, which you can
  * use to replace NS_IMPL_QUERY_INTERFACE2, if you use that instead of
  * NS_IMPL_ISUPPORTS2.
  *
  * That's it!  The rest is gory details.
  *
  *
@@ -116,17 +116,17 @@ private:
   NS_DECL_CI_INTERFACE_GETTER(_class)                                   \
   static const GenericClassInfo::ClassInfoData k##_class##ClassInfoData = { \
     NS_CI_INTERFACE_GETTER_NAME(_class),                                \
     _getlanguagehelper,                                                 \
     _flags | nsIClassInfo::SINGLETON_CLASSINFO,                         \
     _cid,                                                               \
   };                                                                    \
   mozilla::AlignedStorage2<GenericClassInfo> k##_class##ClassInfoDataPlace;   \
-  nsIClassInfo* NS_CLASSINFO_NAME(_class) = NULL;
+  nsIClassInfo* NS_CLASSINFO_NAME(_class) = nullptr;
 
 #define NS_IMPL_QUERY_CLASSINFO(_class)                                       \
   if ( aIID.Equals(NS_GET_IID(nsIClassInfo)) ) {                              \
     if (!NS_CLASSINFO_NAME(_class))                                           \
       NS_CLASSINFO_NAME(_class) = new (k##_class##ClassInfoDataPlace.addr())  \
         GenericClassInfo(&k##_class##ClassInfoData);                          \
     foundInterface = NS_CLASSINFO_NAME(_class);                               \
   } else
--- a/xpcom/glue/nsID.cpp
+++ b/xpcom/glue/nsID.cpp
@@ -92,17 +92,17 @@ bool nsID::Parse(const char *aIDStr)
  * format. The string is allocated with NS_Alloc and should be freed by
  * the caller.
  */
 
 char *nsID::ToString() const 
 {
   char *res = (char*)NS_Alloc(NSID_LENGTH);
 
-  if (res != NULL) {
+  if (res != nullptr) {
     PR_snprintf(res, NSID_LENGTH, gIDFormat,
                 m0, (uint32_t) m1, (uint32_t) m2,
                 (uint32_t) m3[0], (uint32_t) m3[1], (uint32_t) m3[2],
                 (uint32_t) m3[3], (uint32_t) m3[4], (uint32_t) m3[5],
                 (uint32_t) m3[6], (uint32_t) m3[7]);
   }
   return res;
 }
--- a/xpcom/glue/nsINIParser.cpp
+++ b/xpcom/glue/nsINIParser.cpp
@@ -143,33 +143,33 @@ nsINIParser::InitFromFILE(FILE *fd)
      && mFileContents[1] == static_cast<char>(0xFE)) {
         // Someone set us up the Utf-16LE BOM
         buffer = &mFileContents[2];
         // Get the size required for our Utf8 buffer
         flen = WideCharToMultiByte(CP_UTF8,
                                    0,
                                    reinterpret_cast<LPWSTR>(buffer),
                                    -1,
-                                   NULL,
+                                   nullptr,
                                    0,
-                                   NULL,
-                                   NULL);
+                                   nullptr,
+                                   nullptr);
         if (0 == flen) {
             return NS_ERROR_FAILURE;
         }
 
         nsAutoArrayPtr<char> utf8Buffer(new char[flen]);
         if (0 == WideCharToMultiByte(CP_UTF8,
                                      0,
                                      reinterpret_cast<LPWSTR>(buffer),
                                      -1,
                                      utf8Buffer,
                                      flen,
-                                     NULL,
-                                     NULL)) {
+                                     nullptr,
+                                     nullptr)) {
             return NS_ERROR_FAILURE;
         }
         mFileContents = utf8Buffer.forget();
         buffer = mFileContents;
     }
 #endif
 
     char *currSection = nullptr;
--- a/xpcom/glue/nsISupportsImpl.h
+++ b/xpcom/glue/nsISupportsImpl.h
@@ -38,17 +38,17 @@ inline nsISupports*
 ToSupports(nsISupports* p)
 {
     return p;
 }
 
 inline nsISupports*
 ToCanonicalSupports(nsISupports* p)
 {
-    return NULL;
+    return nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Macros to help detect thread-safety:
 
 #if (defined(DEBUG) || (defined(NIGHTLY_BUILD) && !defined(MOZ_PROFILING))) && !defined(XPCOM_GLUE_AVOID_NSPR)
 
 class nsAutoOwningThread {
@@ -77,17 +77,17 @@ private:
 struct nsPurpleBufferEntry {
   union {
     void *mObject;                        // when low bit unset
     nsPurpleBufferEntry *mNextInFreeList; // when low bit set
   };
 
   nsCycleCollectingAutoRefCnt *mRefCnt;
 
-  nsCycleCollectionParticipant *mParticipant; // NULL for nsISupports
+  nsCycleCollectionParticipant *mParticipant; // nullptr for nsISupports
 };
 
 #define NS_NUMBER_OF_FLAGS_IN_REFCNT 2
 #define NS_IN_PURPLE_BUFFER (1 << 0)
 #define NS_IS_PURPLE (1 << 1)
 #define NS_REFCOUNT_CHANGE (1 << NS_NUMBER_OF_FLAGS_IN_REFCNT)
 #define NS_REFCOUNT_VALUE(_val) (_val >> NS_NUMBER_OF_FLAGS_IN_REFCNT)
 
--- a/xpcom/glue/nsISupportsUtils.h
+++ b/xpcom/glue/nsISupportsUtils.h
@@ -58,17 +58,17 @@ ns_if_addref( T expr )
     if (expr) {
         expr->AddRef();
     }
 }
 
 } /* extern "C++" */
 
 /**
- * Macro for adding a reference to an interface that checks for NULL.
+ * Macro for adding a reference to an interface that checks for nullptr.
  * @param _expr The interface pointer.
  */
 #define NS_IF_ADDREF(_expr) ns_if_addref(_expr)
 
 /*
  * Given these declarations, it explicitly OK and efficient to end a `getter' with:
  *
  *    NS_IF_ADDREF(*result = mThing);
@@ -104,17 +104,17 @@ ns_if_addref( T expr )
  */
 #define NS_RELEASE2(_ptr, _rc)                                                \
   do {                                                                        \
     _rc = (_ptr)->Release();                                                  \
     if (0 == (_rc)) (_ptr) = 0;                                               \
   } while (0)
 
 /**
- * Macro for releasing a reference to an interface that checks for NULL;
+ * Macro for releasing a reference to an interface that checks for nullptr;
  * @param _ptr The interface pointer.
  */
 #define NS_IF_RELEASE(_ptr)                                                   \
   do {                                                                        \
     if (_ptr) {                                                               \
       (_ptr)->Release();                                                      \
       (_ptr) = 0;                                                             \
     }                                                                         \
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -106,17 +106,17 @@ template<class T>
 class nsMainThreadPtrHolder MOZ_FINAL
 {
 public:
   // We can only acquire a pointer on the main thread. We to fail fast for
   // threading bugs, so by default we assert if our pointer is used or acquired
   // off-main-thread. But some consumers need to use the same pointer for
   // multiple classes, some of which are main-thread-only and some of which
   // aren't. So we allow them to explicitly disable this strict checking.
-  nsMainThreadPtrHolder(T* ptr, bool strict = true) : mRawPtr(NULL), mStrict(strict) {
+  nsMainThreadPtrHolder(T* ptr, bool strict = true) : mRawPtr(nullptr), mStrict(strict) {
     // We can only AddRef our pointer on the main thread, which means that the
     // holder must be constructed on the main thread.
     MOZ_ASSERT(!mStrict || NS_IsMainThread());
     NS_IF_ADDREF(mRawPtr = ptr);
   }
 
   // We can be released on any thread.
   ~nsMainThreadPtrHolder() {
@@ -160,17 +160,17 @@ private:
 };
 
 template<class T>
 class nsMainThreadPtrHandle
 {
   nsRefPtr<nsMainThreadPtrHolder<T> > mPtr;
 
   public:
-  nsMainThreadPtrHandle() : mPtr(NULL) {}
+  nsMainThreadPtrHandle() : mPtr(nullptr) {}
   nsMainThreadPtrHandle(nsMainThreadPtrHolder<T> *aHolder) : mPtr(aHolder) {}
   nsMainThreadPtrHandle(const nsMainThreadPtrHandle& aOther) : mPtr(aOther.mPtr) {}
   nsMainThreadPtrHandle& operator=(const nsMainThreadPtrHandle& aOther) {
     mPtr = aOther.mPtr;
     return *this;
   }
 
   // These all call through to nsMainThreadPtrHolder, and thus implicitly
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -249,34 +249,35 @@ public:
    * @return    summed size of the things pointed to by the entries
    */
   typedef size_t (* SizeOfEntryExcludingThisFun)(EntryType* aEntry,
                                                  mozilla::MallocSizeOf mallocSizeOf,
                                                  void *arg);
 
   /**
    * Measure the size of the table's entry storage, and if
-   * |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed
-   * to by entries.
+   * |sizeOfEntryExcludingThis| is non-nullptr, measure the size of things
+   * pointed to by entries.
    * 
    * @param     sizeOfEntryExcludingThis the
    *            <code>SizeOfEntryExcludingThisFun</code> function to call
    * @param     mallocSizeOf the function used to measure heap-allocated blocks
    * @param     userArg a pointer to pass to the
    *            <code>SizeOfEntryExcludingThisFun</code> function
    * @return    the summed size of all the entries
    */
   size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
-                             mozilla::MallocSizeOf mallocSizeOf, void *userArg = NULL) const
+                             mozilla::MallocSizeOf mallocSizeOf,
+                             void *userArg = nullptr) const
   {
     if (sizeOfEntryExcludingThis) {
       s_SizeOfArgs args = { sizeOfEntryExcludingThis, userArg };
       return PL_DHashTableSizeOfExcludingThis(&mTable, s_SizeOfStub, mallocSizeOf, &args);
     }
-    return PL_DHashTableSizeOfExcludingThis(&mTable, NULL, mallocSizeOf);
+    return PL_DHashTableSizeOfExcludingThis(&mTable, nullptr, mallocSizeOf);
   }
 
 #ifdef DEBUG
   /**
    * Mark the table as constant after initialization.
    *
    * This will prevent assertions when a read-only hash is accessed on multiple
    * threads without synchronization.
--- a/xpcom/glue/nsTextFormatter.cpp
+++ b/xpcom/glue/nsTextFormatter.cpp
@@ -561,44 +561,44 @@ static struct NumArgState* BuildArgArray
         }
 
 	while( c != 0 ){
 	    if (c > '9' || c < '0') {
                 /* numbered argument csae */
 		if (c == '$') {
 		    if (i > 0) {
 			*rv = -1;
-			return NULL;
+			return nullptr;
 		    }
 		    number++;
 		    break;
 
 		} else {
                     /* non-numbered argument case */
 		    if (number > 0) {
 			*rv = -1;
-			return NULL;
+			return nullptr;
 		    }
 		    i = 1;
 		    break;
 		}
 	    }
 	    c = *p++;
 	}
     }
 
     if (number == 0) {
-	return NULL;
+	return nullptr;
     }
     
     if (number > NAS_DEFAULT_NUM) {
 	nas = (struct NumArgState*)nsMemory::Alloc(number * sizeof(struct NumArgState));
 	if (!nas) {
 	    *rv = -1;
-	    return NULL;
+	    return nullptr;
 	}
     } else {
 	nas = nasArray;
     }
 
     for (i = 0; i < number; i++) {
 	nas[i].type = TYPE_UNKNOWN;
     }
@@ -745,17 +745,17 @@ static struct NumArgState* BuildArgArray
     /*
     ** third pass
     ** fill the nas[cn].ap
     */
     if (*rv < 0) {
 	if( nas != nasArray ) {
 	    PR_DELETE(nas);
         }
-	return NULL;
+	return nullptr;
     }
 
     cn = 0;
     while (cn < number) {
 	if (nas[cn].type == TYPE_UNKNOWN) {
 	    cn++;
 	    continue;
 	}
@@ -784,17 +784,17 @@ static struct NumArgState* BuildArgArray
 
 	case TYPE_UNISTRING: (void)va_arg(ap, PRUnichar*);  break;
 
 	default:
 	    if( nas != nasArray ) {
 		PR_DELETE( nas );
             }
 	    *rv = -1;
-	    return NULL;
+	    return nullptr;
 	}
 	cn++;
     }
     return nas;
 }
 
 /*
 ** The workhorse sprintf code.
@@ -818,17 +818,17 @@ static int dosprintf(SprintfState *ss, c
     nsAutoString hex;
     hex.AssignLiteral("0123456789abcdef");
 
     nsAutoString HEX;
     HEX.AssignLiteral("0123456789ABCDEF");
 
     const PRUnichar *hexp;
     int rv, i;
-    struct NumArgState* nas = NULL;
+    struct NumArgState* nas = nullptr;
     struct NumArgState  nasArray[NAS_DEFAULT_NUM];
 
 
     /*
     ** build an argument array, IF the fmt is numbered argument
     ** list style, to contain the Numbered Argument list pointers
     */
     nas = BuildArgArray (fmt, ap, &rv, nasArray);
@@ -857,17 +857,17 @@ static int dosprintf(SprintfState *ss, c
 	    /* quoting a % with %% */
 	    rv = (*ss->stuff)(ss, fmt - 1, 1);
 	    if (rv < 0) {
 		return rv;
 	    }
 	    continue;
 	}
 
-	if (nas != NULL) {
+	if (nas != nullptr) {
 	    /* the fmt contains the Numbered Arguments feature */
 	    i = 0;
 	    /* should imporve error check later */
 	    while (c && c != '$') {
 		i = (i * 10) + (c - '0');
 		c = *fmt++;
 	    }
 
--- a/xpcom/glue/nsTextFormatter.h
+++ b/xpcom/glue/nsTextFormatter.h
@@ -40,25 +40,25 @@
 #error "nsTextFormatter is not available in the standalone glue due to NSPR dependencies."
 #endif
 
 class NS_COM_GLUE nsTextFormatter {
 
   public:
 
     /*
-     * sprintf into a fixed size buffer. Guarantees that a NULL is at the end
-     * of the buffer. Returns the length of the written output, NOT including
-     * the NUL, or (uint32_t)-1 if an error occurs.
+     * sprintf into a fixed size buffer. Guarantees that the buffer is null
+     * terminated. Returns the length of the written output, NOT including the
+     * null terminator, or (uint32_t)-1 if an error occurs.
      */
     static uint32_t snprintf(PRUnichar *out, uint32_t outlen, const PRUnichar *fmt, ...);
 
     /*
      * sprintf into a nsMemory::Alloc'd buffer. Return a pointer to 
-     * buffer on success, NULL on failure. 
+     * buffer on success, nullptr on failure. 
      */
     static PRUnichar* smprintf(const PRUnichar *fmt, ...);
 
     static uint32_t ssprintf(nsAString& out, const PRUnichar* fmt, ...);
 
     /*
      * va_list forms of the above.
      */
--- a/xpcom/glue/nsVoidArray.h
+++ b/xpcom/glue/nsVoidArray.h
@@ -103,21 +103,21 @@ public:
 
   void Sort(nsVoidArrayComparatorFunc aFunc, void* aData);
 
   bool EnumerateForwards(nsVoidArrayEnumFunc aFunc, void* aData);
   bool EnumerateForwards(nsVoidArrayEnumFuncConst aFunc, void* aData) const;
   bool EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData);
 
   // Measures the size of the array's element storage, and if
-  // |aSizeOfElementIncludingThis| is non-NULL, measures the size of things
+  // |aSizeOfElementIncludingThis| is non-nullptr, measures the size of things
   // pointed to by elements.
   size_t SizeOfExcludingThis(
            nsVoidArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis,
-           mozilla::MallocSizeOf aMallocSizeOf, void* aData = NULL) const;
+           mozilla::MallocSizeOf aMallocSizeOf, void* aData = nullptr) const;
 
 protected:
   bool GrowArrayBy(int32_t aGrowBy);
 
   struct Impl {
     /**
      * The actual array size.
      */
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -155,37 +155,37 @@ PL_DHashFinalizeStub(PLDHashTable *table
 static const PLDHashTableOps stub_ops = {
     PL_DHashAllocTable,
     PL_DHashFreeTable,
     PL_DHashVoidPtrKeyStub,
     PL_DHashMatchEntryStub,
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub,
     PL_DHashFinalizeStub,
-    NULL
+    nullptr
 };
 
 const PLDHashTableOps *
 PL_DHashGetStubOps(void)
 {
     return &stub_ops;
 }
 
 PLDHashTable *
 PL_NewDHashTable(const PLDHashTableOps *ops, void *data, uint32_t entrySize,
                  uint32_t capacity)
 {
     PLDHashTable *table;
 
     table = (PLDHashTable *) malloc(sizeof *table);
     if (!table)
-        return NULL;
+        return nullptr;
     if (!PL_DHashTableInit(table, ops, data, entrySize, capacity)) {
         free(table);
-        return NULL;
+        return nullptr;
     }
     return table;
 }
 
 void
 PL_DHashTableDestroy(PLDHashTable *table)
 {
     PL_DHashTableFinish(table);
@@ -329,23 +329,23 @@ PL_DHashTableSetAlphaBounds(PLDHashTable
 void
 PL_DHashTableFinish(PLDHashTable *table)
 {
     char *entryAddr, *entryLimit;
     uint32_t entrySize;
     PLDHashEntryHdr *entry;
 
 #ifdef DEBUG_XXXbrendan
-    static FILE *dumpfp = NULL;
+    static FILE *dumpfp = nullptr;
     if (!dumpfp) dumpfp = fopen("/tmp/pldhash.bigdump", "w");
     if (dumpfp) {
 #ifdef MOZILLA_CLIENT
         NS_TraceStack(1, dumpfp);
 #endif
-        PL_DHashTableDumpMeter(table, NULL, dumpfp);
+        PL_DHashTableDumpMeter(table, nullptr, dumpfp);
         fputc('\n', dumpfp);
     }
 #endif
 
     INCREMENT_RECURSION_LEVEL(table);
 
     /* Call finalize before clearing entries, so it can enumerate them. */
     table->ops->finalize(table);
@@ -403,17 +403,17 @@ SearchTable(PLDHashTable *table, const v
     }
 
     /* Collision: double hash. */
     sizeLog2 = PL_DHASH_BITS - table->hashShift;
     hash2 = HASH2(keyHash, sizeLog2, hashShift);
     sizeMask = (1u << sizeLog2) - 1;
 
     /* Save the first removed entry pointer so PL_DHASH_ADD can recycle it. */
-    firstRemoved = NULL;
+    firstRemoved = nullptr;
 
     for (;;) {
         if (MOZ_UNLIKELY(ENTRY_IS_REMOVED(entry))) {
             if (!firstRemoved)
                 firstRemoved = entry;
         } else {
             if (op == PL_DHASH_ADD)
                 entry->keyHash |= COLLISION_FLAG;
@@ -432,17 +432,17 @@ SearchTable(PLDHashTable *table, const v
         if (MATCH_ENTRY_KEYHASH(entry, keyHash) &&
             matchEntry(table, entry, key)) {
             METER(table->stats.hits++);
             return entry;
         }
     }
 
     /* NOTREACHED */
-    return NULL;
+    return nullptr;
 }
 
 /*
  * This is a copy of SearchTable, used by ChangeTable, hardcoded to
  *   1. assume |op == PL_DHASH_ADD|,
  *   2. assume that |key| will never match an existing entry, and
  *   3. assume that no entries have been removed from the current table
  *      structure.
@@ -490,17 +490,17 @@ FindFreeEntry(PLDHashTable *table, PLDHa
         entry = ADDRESS_ENTRY(table, hash1);
         if (PL_DHASH_ENTRY_IS_FREE(entry)) {
             METER(table->stats.misses++);
             return entry;
         }
     }
 
     /* NOTREACHED */
-    return NULL;
+    return nullptr;
 }
 
 static bool
 ChangeTable(PLDHashTable *table, int deltaLog2)
 {
     int oldLog2, newLog2;
     uint32_t oldCapacity, newCapacity;
     char *newEntryStore, *oldEntryStore, *oldEntryAddr;
@@ -604,17 +604,17 @@ PL_DHashTableOperate(PLDHashTable *table
 
             /*
              * Grow or compress table, returning null if ChangeTable fails and
              * falling through might claim the last free entry.
              */
             if (!ChangeTable(table, deltaLog2) &&
                 table->entryCount + table->removedCount == size - 1) {
                 METER(table->stats.addFailures++);
-                entry = NULL;
+                entry = nullptr;
                 break;
             }
         }
 
         /*
          * Look for entry after possibly growing, so we don't have to add it,
          * then skip it while growing the table and re-add it after.
          */
@@ -626,17 +626,17 @@ PL_DHashTableOperate(PLDHashTable *table
                 METER(table->stats.addOverRemoved++);
                 table->removedCount--;
                 keyHash |= COLLISION_FLAG;
             }
             if (table->ops->initEntry &&
                 !table->ops->initEntry(table, entry, key)) {
                 /* We haven't claimed entry yet; fail with null return. */
                 memset(entry + 1, 0, table->entrySize - sizeof *entry);
-                entry = NULL;
+                entry = nullptr;
                 break;
             }
             entry->keyHash = keyHash;
             table->entryCount++;
         }
         METER(else table->stats.addHits++);
         break;
 
@@ -651,22 +651,22 @@ PL_DHashTableOperate(PLDHashTable *table
             size = PL_DHASH_TABLE_SIZE(table);
             if (size > PL_DHASH_MIN_SIZE &&
                 table->entryCount <= MIN_LOAD(table, size)) {
                 METER(table->stats.shrinks++);
                 (void) ChangeTable(table, -1);
             }
         }
         METER(else table->stats.removeMisses++);
-        entry = NULL;
+        entry = nullptr;
         break;
 
       default:
         NS_NOTREACHED("0");
-        entry = NULL;
+        entry = nullptr;
     }
 
     DECREMENT_RECURSION_LEVEL(table);
 
     return entry;
 }
 
 void
@@ -768,34 +768,34 @@ SizeOfEntryExcludingThisEnumerator(PLDHa
     e->total += e->sizeOfEntryExcludingThis(hdr, e->mallocSizeOf, e->arg);
     return PL_DHASH_NEXT;
 }
 
 size_t
 PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table,
                                  PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                                  MallocSizeOf mallocSizeOf,
-                                 void *arg /* = NULL */)
+                                 void *arg /* = nullptr */)
 {
     size_t n = 0;
     n += mallocSizeOf(table->entryStore);
     if (sizeOfEntryExcludingThis) {
         SizeOfEntryExcludingThisArg arg2 = { 0, sizeOfEntryExcludingThis, mallocSizeOf, arg };
         PL_DHashTableEnumerate(const_cast<PLDHashTable *>(table),
                                SizeOfEntryExcludingThisEnumerator, &arg2);
         n += arg2.total;
     }
     return n;
 }
 
 size_t
 PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table,
                                  PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                                  MallocSizeOf mallocSizeOf,
-                                 void *arg /* = NULL */)
+                                 void *arg /* = nullptr */)
 {
     return mallocSizeOf(table) +
            PL_DHashTableSizeOfExcludingThis(table, sizeOfEntryExcludingThis,
                                             mallocSizeOf, arg);
 }
 
 #ifdef DEBUG
 void
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -564,34 +564,34 @@ PL_DHashTableEnumerate(PLDHashTable *tab
 
 typedef size_t
 (* PLDHashSizeOfEntryExcludingThisFun)(PLDHashEntryHdr *hdr,
                                        mozilla::MallocSizeOf mallocSizeOf,
                                        void *arg);
 
 /**
  * Measure the size of the table's entry storage, and if
- * |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed
- * to by entries.  Doesn't measure |ops| because it's often shared between
- * tables, nor |data| because it's opaque.
+ * |sizeOfEntryExcludingThis| is non-nullptr, measure the size of things
+ * pointed to by entries.  Doesn't measure |ops| because it's often shared
+ * between tables, nor |data| because it's opaque.
  */
 NS_COM_GLUE size_t
 PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table,
                                  PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                                  mozilla::MallocSizeOf mallocSizeOf,
-                                 void *arg = NULL);
+                                 void *arg = nullptr);
 
 /**
  * Like PL_DHashTableSizeOfExcludingThis, but includes sizeof(*this).
  */
 NS_COM_GLUE size_t
 PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table,
                                  PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis,
                                  mozilla::MallocSizeOf mallocSizeOf,
-                                 void *arg = NULL);
+                                 void *arg = nullptr);
 
 #ifdef DEBUG
 /**
  * Mark a table as immutable for the remainder of its lifetime.  This
  * changes the implementation from ASSERTing one set of invariants to
  * ASSERTing a different set.
  *
  * When a table is NOT marked as immutable, the table implementation
--- a/xpcom/glue/tests/gtest/TestFileUtils.cpp
+++ b/xpcom/glue/tests/gtest/TestFileUtils.cpp
@@ -61,17 +61,17 @@ WriteFile(
   }
   return true;
 }
 
 TEST(ReadSysFile, Nonexistent) {
   bool ret;
   int errno_saved;
 
-  ret = ReadSysFile("/nonexistent", NULL, 0);
+  ret = ReadSysFile("/nonexistent", nullptr, 0);
   errno_saved = errno;
 
   ASSERT_FALSE(ret);
   ASSERT_EQ(errno_saved, ENOENT);
 }
 
 TEST(ReadSysFile, Main) {
   /* Use a different file name for each test since different tests could be
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -62,17 +62,17 @@
 #endif
 
 #ifdef XP_WIN
 typedef HRESULT (WINAPI* nsGetKnownFolderPath)(GUID& rfid,
                                                DWORD dwFlags,
                                                HANDLE hToken,
                                                PWSTR *ppszPath);
 
-static nsGetKnownFolderPath gGetKnownFolderPath = NULL;
+static nsGetKnownFolderPath gGetKnownFolderPath = nullptr;
 #endif
 
 void StartupSpecialSystemDirectory()
 {
 #if defined (XP_WIN)
     // SHGetKnownFolderPath is only available on Windows Vista
     // so that we need to use GetProcAddress to get the pointer.
     HMODULE hShell32DLLInst = GetModuleHandleW(L"shell32.dll");
@@ -86,18 +86,18 @@ void StartupSpecialSystemDirectory()
 
 #if defined (XP_WIN)
 
 static nsresult GetKnownFolder(GUID* guid, nsIFile** aFile)
 {
     if (!guid || !gGetKnownFolderPath)
         return NS_ERROR_FAILURE;
 
-    PWSTR path = NULL;
-    gGetKnownFolderPath(*guid, 0, NULL, &path);
+    PWSTR path = nullptr;
+    gGetKnownFolderPath(*guid, 0, nullptr, &path);
 
     if (!path)
         return NS_ERROR_FAILURE;
 
     nsresult rv = NS_NewLocalFile(nsDependentString(path),
                                   true,
                                   aFile);
 
@@ -105,17 +105,17 @@ static nsresult GetKnownFolder(GUID* gui
     return rv;
 }
 
 static nsresult
 GetWindowsFolder(int folder, nsIFile** aFile)
 {
     WCHAR path_orig[MAX_PATH + 3];
     WCHAR *path = path_orig+1;
-    HRESULT result = SHGetSpecialFolderPathW(NULL, path, folder, true);
+    HRESULT result = SHGetSpecialFolderPathW(nullptr, path, folder, true);
 
     if (!SUCCEEDED(result))
         return NS_ERROR_FAILURE;
 
     // Append the trailing slash
     int len = wcslen(path);
     if (len > 1 && path[len - 1] != L'\\')
     {
@@ -125,19 +125,19 @@ GetWindowsFolder(int folder, nsIFile** a
 
     return NS_NewLocalFile(nsDependentString(path, len), true, aFile);
 }
 
 __inline HRESULT
 SHLoadLibraryFromKnownFolder(REFKNOWNFOLDERID aFolderId, DWORD aMode,
                              REFIID riid, void **ppv)
 {
-    *ppv = NULL;
+    *ppv = nullptr;
     IShellLibrary *plib;
-    HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, NULL,
+    HRESULT hr = CoCreateInstance(CLSID_ShellLibrary, nullptr,
                                   CLSCTX_INPROC_SERVER,
                                   IID_PPV_ARGS(&plib));
     if (SUCCEEDED(hr)) {
         hr = plib->LoadLibraryFromKnownFolder(aFolderId, aMode);
         if (SUCCEEDED(hr)) {
             hr = plib->QueryInterface(riid, ppv);
         }
         plib->Release();
@@ -197,18 +197,18 @@ static nsresult GetRegWindowsAppDataFold
     "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
     DWORD res = ::RegOpenKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, KEY_READ,
                                 &key);
     if (res != ERROR_SUCCESS)
         return NS_ERROR_FAILURE;
 
     WCHAR path[MAX_PATH + 2];
     DWORD type, size;
-    res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"), NULL,
-                           &type, (LPBYTE)&path, &size);
+    res = RegQueryValueExW(key, (aLocal ? L"Local AppData" : L"AppData"),
+                           nullptr, &type, (LPBYTE)&path, &size);
     ::RegCloseKey(key);
     // The call to RegQueryValueExW must succeed, the type must be REG_SZ, the
     // buffer size must not equal 0, and the buffer size be a multiple of 2.
     if (res != ERROR_SUCCESS || type != REG_SZ || size == 0 || size % 2 != 0)
         return NS_ERROR_FAILURE;
 
     // Append the trailing slash
     int len = wcslen(path);
@@ -282,45 +282,45 @@ xdg_user_dir_lookup (const char *type)
   char buffer[512];
   char *user_dir;
   char *p, *d;
   int len;
   int relative;
 
   home_dir = getenv ("HOME");
 
-  if (home_dir == NULL)
+  if (home_dir == nullptr)
     goto error;
 
   config_home = getenv ("XDG_CONFIG_HOME");
-  if (config_home == NULL || config_home[0] == 0)
+  if (config_home == nullptr || config_home[0] == 0)
     {
       config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
-      if (config_file == NULL)
+      if (config_file == nullptr)
         goto error;
 
       strcpy (config_file, home_dir);
       strcat (config_file, "/.config/user-dirs.dirs");
     }
   else
     {
       config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
-      if (config_file == NULL)
+      if (config_file == nullptr)
         goto error;
 
       strcpy (config_file, config_home);
       strcat (config_file, "/user-dirs.dirs");
     }
 
   file = fopen (config_file, "r");
   free (config_file);
-  if (file == NULL)
+  if (file == nullptr)
     goto error;
 
-  user_dir = NULL;
+  user_dir = nullptr;
   while (fgets (buffer, sizeof (buffer), file))
     {
       /* Remove newline at end */
       len = strlen (buffer);
       if (len > 0 && buffer[len-1] == '\n')
 	buffer[len-1] = 0;
 
       p = buffer;
@@ -358,26 +358,26 @@ xdg_user_dir_lookup (const char *type)
 	  relative = 1;
 	}
       else if (*p != '/')
 	continue;
 
       if (relative)
 	{
 	  user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
-          if (user_dir == NULL)
+          if (user_dir == nullptr)
             goto error2;
 
 	  strcpy (user_dir, home_dir);
 	  strcat (user_dir, "/");
 	}
       else
 	{
 	  user_dir = (char*) malloc (strlen (p) + 1);
-          if (user_dir == NULL)
+          if (user_dir == nullptr)
             goto error2;
 
 	  *user_dir = 0;
 	}
 
       d = user_dir + strlen (user_dir);
       while (*p && *p != '"')
 	{
@@ -389,17 +389,17 @@ xdg_user_dir_lookup (const char *type)
     }
 error2:
   fclose (file);
 
   if (user_dir)
     return user_dir;
 
  error:
-  return NULL;
+  return nullptr;
 }
 
 static const char xdg_user_dirs[] =
     "DESKTOP\0"
     "DOCUMENTS\0"
     "DOWNLOAD\0"
     "MUSIC\0"
     "PICTURES\0"
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -123,18 +123,18 @@ static char* nsEscapeCount(
     return result;
 }
 
 //----------------------------------------------------------------------------------------
 char* nsEscape(const char * str, nsEscapeMask flags)
 //----------------------------------------------------------------------------------------
 {
     if(!str)
-        return NULL;
-    return nsEscapeCount(str, flags, NULL);
+        return nullptr;
+    return nsEscapeCount(str, flags, nullptr);
 }
 
 //----------------------------------------------------------------------------------------
 char* nsUnescape(char * str)
 //----------------------------------------------------------------------------------------
 {
 	nsUnescapeCount(str);
 	return str;
--- a/xpcom/io/nsLocalFileOS2.cpp
+++ b/xpcom/io/nsLocalFileOS2.cpp
@@ -104,18 +104,18 @@ static unsigned char*
     const unsigned char* p = stringToSearch;
 
     do {
         if (*p == charToSearchFor)
             break;
         p  = (const unsigned char*)WinNextChar(0,0,0,(char*)p);
     } while (*p);
 
-    // Result is p or NULL
-    return *p ? (unsigned char*)p : NULL;
+    // Result is p or nullptr
+    return *p ? (unsigned char*)p : nullptr;
 }
 
 // Locates the first occurrence of subString in the stringToSearch
 static unsigned char*
 _mbsstr(const unsigned char* stringToSearch, const unsigned char* subString)
 {
     const unsigned char* pStr = stringToSearch;
     const unsigned char* pSub = subString;
@@ -137,34 +137,34 @@ static unsigned char*
             break;
 
         pSub = subString;
         pStr = (const unsigned char*)WinNextChar(0,0,0,(char*)pStr);
 
     } while (*pStr);
 
     // if we got to the end of pSub, we've found it
-    return *pSub ? NULL : (unsigned char*)pStr;
+    return *pSub ? nullptr : (unsigned char*)pStr;
 }
 
 // Locates last occurence of charToSearchFor in the stringToSearch
 NS_EXPORT unsigned char*
 _mbsrchr(const unsigned char* stringToSearch, int charToSearchFor)
 {
     int length = strlen((const char*)stringToSearch);
     const unsigned char* p = stringToSearch+length;
 
     do {
         if (*p == charToSearchFor)
             break;
         p  = (const unsigned char*)WinPrevChar(0,0,0,(char*)stringToSearch,(char*)p);
     } while (p > stringToSearch);
 
-    // Result is p or NULL
-    return (*p == charToSearchFor) ? (unsigned char*)p : NULL;
+    // Result is p or nullptr
+    return (*p == charToSearchFor) ? (unsigned char*)p : nullptr;
 }
 
 // Implement equivalent of Win32 CreateDirectoryA
 static nsresult
 CreateDirectoryA(PSZ path, PEAOP2 ppEABuf)
 {
     APIRET rc;
     nsresult rv;
@@ -558,17 +558,17 @@ nsLocalFile::nsLocalFile()
 
 nsresult
 nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
 {
     NS_ENSURE_ARG_POINTER(aInstancePtr);
     NS_ENSURE_NO_AGGREGATION(outer);
 
     nsLocalFile* inst = new nsLocalFile();
-    if (inst == NULL)
+    if (inst == nullptr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
     if (NS_FAILED(rv))
     {
         delete inst;
         return rv;
     }
@@ -760,17 +760,17 @@ nsLocalFile::Create(uint32_t type, uint3
         // skip the first '\\'
         ++slash;
         slash = _mbschr(slash, '\\');
 
         while (slash)
         {
             *slash = '\0';
 
-            rv = CreateDirectoryA(const_cast<char*>(mWorkingPath.get()), NULL);
+            rv = CreateDirectoryA(const_cast<char*>(mWorkingPath.get()), nullptr);
             if (rv) {
                 rv = ConvertOS2Error(rv);
                 if (rv != NS_ERROR_FILE_ALREADY_EXISTS)
                     return rv;
             }
             *slash = '\\';
             ++slash;
             slash = _mbschr(slash, '\\');
@@ -784,17 +784,17 @@ nsLocalFile::Create(uint32_t type, uint3
             return NS_ERROR_FILE_ALREADY_EXISTS;
 
         PR_Close(file);
         return NS_OK;
     }
 
     if (type == DIRECTORY_TYPE)
     {
-        rv = CreateDirectoryA(const_cast<char*>(mWorkingPath.get()), NULL);
+        rv = CreateDirectoryA(const_cast<char*>(mWorkingPath.get()), nullptr);
         if (rv)
             return ConvertOS2Error(rv);
         else
             return NS_OK;
     }
 
     return NS_ERROR_FILE_UNKNOWN_TYPE;
 }
@@ -1386,18 +1386,18 @@ nsLocalFile::CopySingleFile(nsIFile *sou
             strcpy(achProgram, "CMD.EXE  /C ");
             strcat(achProgram, """COPY ");
             strcat(achProgram, filePath.get());
             strcat(achProgram, " ");
             strcat(achProgram, (PSZ)const_cast<char*>(destPath.get()));
             strcat(achProgram, """");
             achProgram[strlen(achProgram) + 1] = '\0';
             achProgram[7] = '\0';
-            DosExecPgm(NULL, 0,
-                       EXEC_SYNC, achProgram, (PSZ)NULL,
+            DosExecPgm(nullptr, 0,
+                       EXEC_SYNC, achProgram, (PSZ)nullptr,
                        &rescResults, achProgram);
             rc = 0; // Assume it worked
 
         } // rc == 65
 
         // moving the file is supposed to act like a rename, so delete the
         // original file if we got this far without error
         if(move && (rc == NO_ERROR))
@@ -1904,17 +1904,17 @@ nsLocalFile::SetFileSize(int64_t aFileSi
 
     rc = DosOpen(mWorkingPath.get(),
                  &hFile,
                  &actionTaken,
                  0,
                  FILE_NORMAL,
                  OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
                  OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE,
-                 NULL);
+                 nullptr);
 
     if (rc != NO_ERROR)
     {
         MakeDirty();
         return NS_ERROR_FAILURE;
     }
 
     // Seek to new, desired end of file
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -1152,17 +1152,17 @@ GetDeviceName(int deviceMajor, int devic
         return ret;
 
     // Expects /proc/self/mountinfo in format:
     // 'ID ID major:minor root mountpoint flags - type devicename flags'
     while(fgets(mountinfo_line,kMountInfoLineLength,f)) {
         char *p_dev = strstr(mountinfo_line,device_num);
     
         int i;
-        for(i = 0; i < kMountInfoDevPosition && p_dev != NULL; i++) {
+        for(i = 0; i < kMountInfoDevPosition && p_dev != nullptr; i++) {
             p_dev = strchr(p_dev,' ');
             if(p_dev)
               p_dev++;
         }
     
         if(p_dev) {
             char *p_dev_end = strchr(p_dev,' ');
             if(p_dev_end) {
@@ -2025,17 +2025,17 @@ static nsresult MacErrorMapper(OSErr inE
 }
 
 static nsresult CFStringReftoUTF8(CFStringRef aInStrRef, nsACString& aOutStr)
 {
   // first see if the conversion would succeed and find the length of the result
   CFIndex usedBufLen, inStrLen = ::CFStringGetLength(aInStrRef);
   CFIndex charsConverted = ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen),
                                               kCFStringEncodingUTF8, 0, false,
-                                              NULL, 0, &usedBufLen);
+                                              nullptr, 0, &usedBufLen);
   if (charsConverted == inStrLen) {
     // all characters converted, do the actual conversion
     aOutStr.SetLength(usedBufLen);
     if (aOutStr.Length() != (unsigned int)usedBufLen)
       return NS_ERROR_OUT_OF_MEMORY;
     UInt8 *buffer = (UInt8*)aOutStr.BeginWriting();
     ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen), kCFStringEncodingUTF8,
                        0, false, buffer, usedBufLen, &usedBufLen);
@@ -2089,17 +2089,17 @@ nsLocalFile::GetCFURL(CFURLRef *_retval)
 
 NS_IMETHODIMP
 nsLocalFile::GetFSRef(FSRef *_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
 
   nsresult rv = NS_ERROR_FAILURE;
 
-  CFURLRef url = NULL;
+  CFURLRef url = nullptr;
   if (NS_SUCCEEDED(GetCFURL(&url))) {
     if (::CFURLGetFSRef(url, _retval)) {
       rv = NS_OK;
     }
     ::CFRelease(url);
   }
 
   return rv;
@@ -2219,33 +2219,33 @@ nsLocalFile::LaunchWithDoc(nsIFile *aDoc
 
   thelaunchSpec.appRef = &appFSRef;
   if (aDocToLoad) {
     thelaunchSpec.numDocs = 1;
     thelaunchSpec.itemRefs = &docFSRef;
   }
   thelaunchSpec.launchFlags = theLaunchFlags;
 
-  OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, NULL);
+  OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, nullptr);
   if (err != noErr)
     return MacErrorMapper(err);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::OpenDocWithApp(nsIFile *aAppToOpenWith, bool aLaunchInBackground)
 {
   FSRef docFSRef;
   nsresult rv = GetFSRef(&docFSRef);
   if (NS_FAILED(rv))
     return rv;
 
   if (!aAppToOpenWith) {
-    OSErr err = ::LSOpenFSRef(&docFSRef, NULL);
+    OSErr err = ::LSOpenFSRef(&docFSRef, nullptr);
     return MacErrorMapper(err);
   }
 
   nsCOMPtr<nsILocalFileMac> appFileMac = do_QueryInterface(aAppToOpenWith, &rv);
   if (!appFileMac)
     return rv;
 
   bool isExecutable;
@@ -2267,17 +2267,17 @@ nsLocalFile::OpenDocWithApp(nsIFile *aAp
     theLaunchFlags |= kLSLaunchDontSwitch;
   memset(&thelaunchSpec, 0, sizeof(LSLaunchFSRefSpec));
 
   thelaunchSpec.appRef = &appFSRef;
   thelaunchSpec.numDocs = 1;
   thelaunchSpec.itemRefs = &docFSRef;
   thelaunchSpec.launchFlags = theLaunchFlags;
 
-  OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, NULL);
+  OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, nullptr);
   if (err != noErr)
     return MacErrorMapper(err);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsLocalFile::IsPackage(bool *_retval)
@@ -2331,17 +2331,17 @@ nsLocalFile::GetBundleDisplayName(nsAStr
 
 NS_IMETHODIMP
 nsLocalFile::GetBundleIdentifier(nsACString& outBundleIdentifier)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   CFURLRef urlRef;
   if (NS_SUCCEEDED(GetCFURL(&urlRef))) {
-    CFBundleRef bundle = ::CFBundleCreate(NULL, urlRef);
+    CFBundleRef bundle = ::CFBundleCreate(nullptr, urlRef);
     if (bundle) {
       CFStringRef bundleIdentifier = ::CFBundleGetIdentifier(bundle);
       if (bundleIdentifier)
         rv = CFStringReftoUTF8(bundleIdentifier, outBundleIdentifier);
       ::CFRelease(bundle);
     }
     ::CFRelease(urlRef);
   }
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -113,17 +113,17 @@ public:
         mResolvedPath(aResolvedPath)
     {
     }
 
     NS_IMETHOD Run() {
         MOZ_ASSERT(!NS_IsMainThread(),
             "AsyncLocalFileWinOperation should not be run on the main thread!");
 
-        CoInitialize(NULL);
+        CoInitialize(nullptr);
         switch(mOperation) {
         case RevealOp: {
             Reveal();
         }
         break;
         case LaunchOp: {
             Launch();
         }
@@ -200,21 +200,21 @@ private:
     // Launches the default shell operation for the file path
     nsresult Launch()
     {
         // use the app registry name to launch a shell execute....
         SHELLEXECUTEINFOW seinfo;
         memset(&seinfo, 0, sizeof(seinfo));
         seinfo.cbSize = sizeof(SHELLEXECUTEINFOW);
         seinfo.fMask  = 0;
-        seinfo.hwnd   = NULL;
-        seinfo.lpVerb = NULL;
+        seinfo.hwnd   = nullptr;
+        seinfo.lpVerb = nullptr;
         seinfo.lpFile = mResolvedPath.get();
-        seinfo.lpParameters =  NULL;
-        seinfo.lpDirectory  = NULL;
+        seinfo.lpParameters =  nullptr;
+        seinfo.lpDirectory  = nullptr;
         seinfo.nShow  = SW_SHOWNORMAL;
 
         // Use the directory of the file we're launching as the working
         // directory.  That way if we have a self extracting EXE it won't
         // suggest to extract to the install directory.
         WCHAR workingDirectory[MAX_PATH + 1] = { L'\0' };
         wcsncpy(workingDirectory,  mResolvedPath.get(), MAX_PATH);
         if (PathRemoveFileSpecW(workingDirectory)) {
@@ -321,30 +321,30 @@ private:
     Mutex                  mLock;
     nsRefPtr<IPersistFile> mPersistFile;
     nsRefPtr<IShellLinkW>  mShellLink;
 };
 
 ShortcutResolver::ShortcutResolver() :
     mLock("ShortcutResolver.mLock")
 {
-    CoInitialize(NULL);
+    CoInitialize(nullptr);
 }
 
 ShortcutResolver::~ShortcutResolver()
 {
     CoUninitialize();
 }
 
 nsresult
 ShortcutResolver::Init()
 {
     // Get a pointer to the IPersistFile interface.
     if (FAILED(CoCreateInstance(CLSID_ShellLink,
-                                NULL,
+                                nullptr,
                                 CLSCTX_INPROC_SERVER,
                                 IID_IShellLinkW,
                                 getter_AddRefs(mShellLink))) ||
         FAILED(mShellLink->QueryInterface(IID_IPersistFile,
                                           getter_AddRefs(mPersistFile)))) {
         mShellLink = nullptr;
         return NS_ERROR_FAILURE;
     }
@@ -357,17 +357,17 @@ ShortcutResolver::Resolve(const WCHAR* i
 {
     if (!mShellLink)
         return NS_ERROR_FAILURE;
 
     MutexAutoLock lock(mLock);
 
     if (FAILED(mPersistFile->Load(in, STGM_READ)) ||
         FAILED(mShellLink->Resolve(nullptr, SLR_NO_UI)) ||
-        FAILED(mShellLink->GetPath(out, MAX_PATH, NULL, SLGP_UNCPRIORITY)))
+        FAILED(mShellLink->GetPath(out, MAX_PATH, nullptr, SLGP_UNCPRIORITY)))
         return NS_ERROR_FAILURE;
     return NS_OK;
 }
 
 nsresult
 ShortcutResolver::SetShortcut(bool updateExisting,
                               const WCHAR* shortcutPath,
                               const WCHAR* targetPath,
@@ -631,17 +631,17 @@ OpenFile(const nsAFlatString &name, int 
     // The flag has no effect if we happen to open the file.
     if (!(mode & (PR_IWUSR | PR_IWGRP | PR_IWOTH)) &&
         disposition != OPEN_EXISTING) {
         attributes |= FILE_ATTRIBUTE_READONLY;
     }
 
     HANDLE file = ::CreateFileW(name.get(), access,
                                 FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                NULL, disposition, attributes, NULL);
+                                nullptr, disposition, attributes, nullptr);
 
     if (file == INVALID_HANDLE_VALUE) { 
         *fd = nullptr;
         return ConvertWinError(GetLastError());
     }
 
     *fd = PR_ImportFile((PROsfd) file); 
     if (*fd) {
@@ -958,17 +958,17 @@ nsLocalFile::nsLocalFile()
 
 nsresult
 nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
 {
     NS_ENSURE_ARG_POINTER(aInstancePtr);
     NS_ENSURE_NO_AGGREGATION(outer);
 
     nsLocalFile* inst = new nsLocalFile();
-    if (inst == NULL)
+    if (inst == nullptr)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
     if (NS_FAILED(rv))
     {
         delete inst;
         return rv;
     }
@@ -1266,17 +1266,17 @@ nsLocalFile::Create(uint32_t type, uint3
         // skip the first '\\'
         ++slash;
         slash = wcschr(slash, L'\\');
 
         while (slash)
         {
             *slash = L'\0';
 
-            if (!::CreateDirectoryW(mResolvedPath.get(), NULL)) {
+            if (!::CreateDirectoryW(mResolvedPath.get(), nullptr)) {
                 rv = ConvertWinError(GetLastError());
                 if (NS_ERROR_FILE_NOT_FOUND == rv &&
                     NS_ERROR_FILE_ACCESS_DENIED == directoryCreateError) {
                     // If a previous CreateDirectory failed due to access, return that.
                     return NS_ERROR_FILE_ACCESS_DENIED;
                 }
                 // perhaps the base path already exists, or perhaps we don't have
                 // permissions to create the directory.  NOTE: access denied could
@@ -1314,17 +1314,17 @@ nsLocalFile::Create(uint32_t type, uint3
             // If a previous CreateDirectory failed due to access, return that.
             return NS_ERROR_FILE_ACCESS_DENIED;
         }
         return rv;
     }
 
     if (type == DIRECTORY_TYPE)
     {
-        if (!::CreateDirectoryW(mResolvedPath.get(), NULL)) {
+        if (!::CreateDirectoryW(mResolvedPath.get(), nullptr)) {
           rv = ConvertWinError(GetLastError());
           if (NS_ERROR_FILE_NOT_FOUND == rv && 
               NS_ERROR_FILE_ACCESS_DENIED == directoryCreateError) {
               // If a previous CreateDirectory failed due to access, return that.
               return NS_ERROR_FILE_ACCESS_DENIED;
           } else {
               return rv;
           }
@@ -1687,19 +1687,19 @@ nsLocalFile::SetShortcut(nsIFile* target
                          int32_t iconIndex)
 {
     bool exists;
     nsresult rv = this->Exists(&exists);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
-    const WCHAR* targetFilePath = NULL;
-    const WCHAR* workingDirPath = NULL;
-    const WCHAR* iconFilePath = NULL;
+    const WCHAR* targetFilePath = nullptr;
+    const WCHAR* workingDirPath = nullptr;
+    const WCHAR* iconFilePath = nullptr;
 
     nsAutoString targetFilePathAuto;
     if (targetFile) {
         rv = targetFile->GetPath(targetFilePathAuto);
         if (NS_FAILED(rv)) {
           return rv;
         }
         targetFilePath = targetFilePathAuto.get();
@@ -1834,49 +1834,51 @@ nsLocalFile::CopySingleFile(nsIFile *sou
             !IsRemoteFilePath(destPath.get(), path2Remote) ||
             path1Remote || path2Remote) {
             dwCopyFlags |= COPY_FILE_NO_BUFFERING;
         }
     }
     
     if (!move)
     {
-        copyOK = ::CopyFileExW(filePath.get(), destPath.get(), NULL, NULL, NULL, dwCopyFlags);
+        copyOK = ::CopyFileExW(filePath.get(), destPath.get(), nullptr,
+                               nullptr, nullptr, dwCopyFlags);
     }
     else
     {
         copyOK = ::MoveFileExW(filePath.get(), destPath.get(), MOVEFILE_REPLACE_EXISTING);
 
         // Check if copying the source file to a different volume,
         // as this could be an SMBV2 mapped drive.
         if (!copyOK && GetLastError() == ERROR_NOT_SAME_DEVICE)
         {
-            copyOK = CopyFileExW(filePath.get(), destPath.get(), NULL, NULL, NULL, dwCopyFlags);
+            copyOK = CopyFileExW(filePath.get(), destPath.get(), nullptr,
+                                 nullptr, nullptr, dwCopyFlags);
 
             if (copyOK)
                 DeleteFileW(filePath.get());
         }
     }
 
     if (!copyOK)  // CopyFileEx and MoveFileEx return zero at failure.
         rv = ConvertWinError(GetLastError());
     else if (move && !skipNtfsAclReset)
     {
         // Set security permissions to inherit from parent.
         // Note: propagates to all children: slow for big file trees
-        PACL pOldDACL = NULL;
-        PSECURITY_DESCRIPTOR pSD = NULL;
+        PACL pOldDACL = nullptr;
+        PSECURITY_DESCRIPTOR pSD = nullptr;
         ::GetNamedSecurityInfoW((LPWSTR)destPath.get(), SE_FILE_OBJECT,
                                 DACL_SECURITY_INFORMATION,
-                                NULL, NULL, &pOldDACL, NULL, &pSD);
+                                nullptr, nullptr, &pOldDACL, nullptr, &pSD);
         if (pOldDACL)
             ::SetNamedSecurityInfoW((LPWSTR)destPath.get(), SE_FILE_OBJECT,
                                     DACL_SECURITY_INFORMATION |
                                     UNPROTECTED_DACL_SECURITY_INFORMATION,
-                                    NULL, NULL, pOldDACL, NULL);
+                                    nullptr, nullptr, pOldDACL, nullptr);
         if (pSD)
             LocalFree((HLOCAL)pSD);
     }
 
     return rv;
 }
 
 nsresult
@@ -2331,20 +2333,20 @@ nsLocalFile::SetLastModifiedTimeOfLink(P
 nsresult
 nsLocalFile::SetModDate(PRTime aLastModifiedTime, const PRUnichar *filePath)
 {
     // The FILE_FLAG_BACKUP_SEMANTICS is required in order to change the
     // modification time for directories.
     HANDLE file = ::CreateFileW(filePath,          // pointer to name of the file
                                 GENERIC_WRITE,     // access (write) mode
                                 0,                 // share mode
-                                NULL,              // pointer to security attributes
+                                nullptr,           // pointer to security attributes
                                 OPEN_EXISTING,     // how to create
                                 FILE_FLAG_BACKUP_SEMANTICS,  // file attributes
-                                NULL);
+                                nullptr);
 
     if (file == INVALID_HANDLE_VALUE)
     {
         return ConvertWinError(GetLastError());
     }
 
     FILETIME ft;
     SYSTEMTIME st;
@@ -2359,17 +2361,17 @@ nsLocalFile::SetModDate(PRTime aLastModi
     st.wHour            = pret.tm_hour;
     st.wMinute          = pret.tm_min;
     st.wSecond          = pret.tm_sec;
     st.wMilliseconds    = pret.tm_usec/1000;
 
     nsresult rv = NS_OK;
     // if at least one of these fails...
     if (!(SystemTimeToFileTime(&st, &ft) != 0 &&
-          SetFileTime(file, NULL, &ft, &ft) != 0))
+          SetFileTime(file, nullptr, &ft, &ft) != 0))
     {
       rv = ConvertWinError(GetLastError());
     }
 
     CloseHandle(file);
     return rv;
 }
 
@@ -2512,20 +2514,20 @@ nsLocalFile::SetFileSize(int64_t aFileSi
 
     nsresult rv = ResolveAndStat();
     if (NS_FAILED(rv))
         return rv;
 
     HANDLE hFile = ::CreateFileW(mResolvedPath.get(),// pointer to name of the file
                                  GENERIC_WRITE,      // access (write) mode
                                  FILE_SHARE_READ,    // share mode
-                                 NULL,               // pointer to security attributes
+                                 nullptr,            // pointer to security attributes
                                  OPEN_EXISTING,          // how to create
                                  FILE_ATTRIBUTE_NORMAL,  // file attributes
-                                 NULL);
+                                 nullptr);
     if (hFile == INVALID_HANDLE_VALUE)
     {
         return ConvertWinError(GetLastError());
     }
 
     // seek the file pointer to the new, desired end of file
     // and then truncate the file at that position
     rv = NS_ERROR_FAILURE;
@@ -2555,17 +2557,17 @@ nsLocalFile::GetDiskSpaceAvailable(int64
       nsCOMPtr<nsIFile> parent;
       if (NS_SUCCEEDED(GetParent(getter_AddRefs(parent))) && parent) {
         return parent->GetDiskSpaceAvailable(aDiskSpaceAvailable);
       }
     }
 
     ULARGE_INTEGER liFreeBytesAvailableToCaller, liTotalNumberOfBytes;
     if (::GetDiskFreeSpaceExW(mResolvedPath.get(), &liFreeBytesAvailableToCaller, 
-                              &liTotalNumberOfBytes, NULL))
+                              &liTotalNumberOfBytes, nullptr))
     {
         *aDiskSpaceAvailable = liFreeBytesAvailableToCaller.QuadPart;
         return NS_OK;
     }
     *aDiskSpaceAvailable = 0;
     return NS_OK;
 }
 
@@ -3345,18 +3347,18 @@ nsLocalFile::EnsureShortPath()
 {
     if (!mShortWorkingPath.IsEmpty())
         return;
 
     WCHAR shortPath[MAX_PATH + 1];
     DWORD lengthNeeded = ::GetShortPathNameW(mWorkingPath.get(), shortPath,
                                              ArrayLength(shortPath));
     // If an error occurred then lengthNeeded is set to 0 or the length of the
-    // needed buffer including NULL termination.  If it succeeds the number of
-    // wide characters not including NULL termination is returned.
+    // needed buffer including null termination.  If it succeeds the number of
+    // wide characters not including null termination is returned.
     if (lengthNeeded != 0 && lengthNeeded < ArrayLength(shortPath))
         mShortWorkingPath.Assign(shortPath);
     else
         mShortWorkingPath.Assign(mWorkingPath);
 }
 
 // nsIHashable
 
--- a/xpcom/io/nsMultiplexInputStream.cpp
+++ b/xpcom/io/nsMultiplexInputStream.cpp
@@ -58,17 +58,17 @@ private:
     uint32_t mCurrentStream;
     bool mStartedReadingCurrent;
     nsresult mStatus;
 };
 
 NS_IMPL_ADDREF(nsMultiplexInputStream)
 NS_IMPL_RELEASE(nsMultiplexInputStream)
 
-NS_IMPL_CLASSINFO(nsMultiplexInputStream, NULL, nsIClassInfo::THREADSAFE,
+NS_IMPL_CLASSINFO(nsMultiplexInputStream, nullptr, nsIClassInfo::THREADSAFE,
                   NS_MULTIPLEXINPUTSTREAM_CID)
 
 NS_IMPL_QUERY_INTERFACE4_CI(nsMultiplexInputStream,
                             nsIMultiplexInputStream,
                             nsIInputStream,
                             nsISeekableStream,
                             nsIIPCSerializableInputStream)
 NS_IMPL_CI_INTERFACE_GETTER3(nsMultiplexInputStream,
--- a/xpcom/io/nsNativeCharsetUtils.cpp
+++ b/xpcom/io/nsNativeCharsetUtils.cpp
@@ -134,22 +134,22 @@ xp_iconv(iconv_t converter,
             res = 0;
     }
     return res;
 }
 
 static inline void
 xp_iconv_reset(iconv_t converter)
 {
-    // NOTE: the man pages on Solaris claim that you can pass NULL
+    // NOTE: the man pages on Solaris claim that you can pass nullptr
     // for all parameter to reset the converter, but beware the 
     // evil Solaris crash if you go down this route >:-)
     
-    const char *zero_char_in_ptr  = NULL;
-    char       *zero_char_out_ptr = NULL;
+    const char *zero_char_in_ptr  = nullptr;
+    char       *zero_char_out_ptr = nullptr;
     size_t      zero_size_in      = 0,
                 zero_size_out     = 0;
 
     xp_iconv(converter, &zero_char_in_ptr,
                         &zero_size_in,
                         &zero_char_out_ptr,
                         &zero_size_out);
 }
@@ -211,45 +211,45 @@ static const char *UTF_16_NAMES[] = {
 #endif
     "UTF-16",
     "UCS-2",
     "UCS2",
     "UCS_2",
     "ucs-2",
     "ucs2",
     "ucs_2",
-    NULL
+    nullptr
 };
 
 #if defined(ENABLE_UTF8_FALLBACK_SUPPORT)
 static const char *UTF_8_NAMES[] = {
     "UTF-8",
     "UTF8",
     "UTF_8",
     "utf-8",
     "utf8",
     "utf_8",
-    NULL
+    nullptr
 };
 #endif
 
 static const char *ISO_8859_1_NAMES[] = {
     "ISO-8859-1",
 #if !defined(__GLIBC__)
     "ISO8859-1",
     "ISO88591",
     "ISO_8859_1",
     "ISO8859_1",
     "iso-8859-1",
     "iso8859-1",
     "iso88591",
     "iso_8859_1",
     "iso8859_1",
 #endif
-    NULL
+    nullptr
 };
 
 class nsNativeCharsetConverter
 {
 public:
     nsNativeCharsetConverter();
    ~nsNativeCharsetConverter();
 
@@ -297,17 +297,17 @@ void
 nsNativeCharsetConverter::LazyInit()
 {
     // LazyInit may be called before NS_StartupNativeCharsetUtils, but
     // the setlocale it does has to be called before nl_langinfo. Like in
     // NS_StartupNativeCharsetUtils, assume we are called early enough that
     // we are the first to care about the locale's charset.
     if (!gLock)
       setlocale(LC_CTYPE, "");
-    const char  *blank_list[] = { "", NULL };
+    const char  *blank_list[] = { "", nullptr };
     const char **native_charset_list = blank_list;
     const char  *native_charset = nl_langinfo(CODESET);
     if (native_charset == nullptr) {
         NS_ERROR("native charset is unknown");
         // fallback to ISO-8859-1
         native_charset_list = ISO_8859_1_NAMES;
     }
     else
@@ -883,17 +883,17 @@ NS_CopyNativeToUnicode(const nsACString 
 
     nsACString::const_iterator iter;
     input.BeginReading(iter);
 
     const char *buf = iter.get();
 
     // determine length of result
     uint32_t resultLen = 0;
-    int n = ::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, NULL, 0);
+    int n = ::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, nullptr, 0);
     if (n > 0)
         resultLen += n;
 
     // allocate sufficient space
     if (!output.SetLength(resultLen, fallible_t()))
         return NS_ERROR_OUT_OF_MEMORY;
     if (resultLen > 0) {
         nsAString::iterator out_iter;
@@ -914,17 +914,18 @@ NS_CopyUnicodeToNative(const nsAString  
     nsAString::const_iterator iter;
     input.BeginReading(iter);
 
     const PRUnichar *buf = iter.get();
 
     // determine length of result
     uint32_t resultLen = 0;
 
-    int n = ::WideCharToMultiByte(CP_ACP, 0, buf, inputLen, NULL, 0, NULL, NULL);
+    int n = ::WideCharToMultiByte(CP_ACP, 0, buf, inputLen, nullptr, 0,
+                                  nullptr, nullptr);
     if (n > 0)
         resultLen += n;
 
     // allocate sufficient space
     if (!output.SetLength(resultLen, fallible_t()))
         return NS_ERROR_OUT_OF_MEMORY;
     if (resultLen > 0) {
         nsACString::iterator out_iter;
@@ -932,17 +933,17 @@ NS_CopyUnicodeToNative(const nsAString  
 
         // default "defaultChar" is '?', which is an illegal character on windows
         // file system.  That will cause file uncreatable. Change it to '_'
         const char defaultChar = '_';
 
         char *result = out_iter.get();
 
         ::WideCharToMultiByte(CP_ACP, 0, buf, inputLen, result, resultLen,
-                              &defaultChar, NULL);
+                              &defaultChar, nullptr);
     }
     return NS_OK;
 }
 
 // moved from widget/windows/nsToolkit.cpp
 int32_t 
 NS_ConvertAtoW(const char *aStrInA, int aBufferSize, PRUnichar *aStrOutW)
 {
@@ -953,17 +954,17 @@ int32_t
 NS_ConvertWtoA(const PRUnichar *aStrInW, int aBufferSizeOut,
                char *aStrOutA, const char *aDefault)
 {
     if ((!aStrInW) || (!aStrOutA) || (aBufferSizeOut <= 0))
         return 0;
 
     int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, aStrInW, -1, 
                                                 aStrOutA, aBufferSizeOut,
-                                                aDefault, NULL);
+                                                aDefault, nullptr);
 
     if (!numCharsConverted) {
         if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
             // Overflow, add missing null termination but return 0
             aStrOutA[aBufferSizeOut-1] = '\0';
         }
         else {
             // Other error, clear string and return 0
@@ -988,17 +989,17 @@ NS_ConvertWtoA(const PRUnichar *aStrInW,
 #include <uconv.h>
 #include "nsAString.h"
 #include "nsReadableUtils.h"
 #include <ulserrno.h>
 #include "nsNativeCharsetUtils.h"
 
 using namespace mozilla;
 
-static UconvObject UnicodeConverter = NULL;
+static UconvObject UnicodeConverter = nullptr;
 
 nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output)
 {
     uint32_t inputLen = input.Length();
 
     nsACString::const_iterator iter;
     input.BeginReading(iter);
@@ -1085,17 +1086,17 @@ NS_StartupNativeCharsetUtils()
 
     UniChar codepage[20];
     int unirc = ::UniMapCpToUcsCp(ulCodePage, codepage, 20);
     if (unirc == ULS_SUCCESS) {
         unirc = ::UniCreateUconvObject(codepage, &UnicodeConverter);
         if (unirc == ULS_SUCCESS) {
             uconv_attribute_t attr;
             ::UniQueryUconvObject(UnicodeConverter, &attr, sizeof(uconv_attribute_t), 
-                                  NULL, NULL, NULL);
+                                  nullptr, nullptr, nullptr);
             attr.options = UCONV_OPTION_SUBSTITUTE_BOTH;
             attr.subchar_len=1;
             attr.subchar[0]='_';
             ::UniSetUconvObject(UnicodeConverter, &attr);
         }
     }
 }
 
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -76,17 +76,17 @@ private:
     uint32_t mOffset;
 };
 
 // This class needs to support threadsafe refcounting since people often
 // allocate a string stream, and then read it from a background thread.
 NS_IMPL_ADDREF(nsStringInputStream)
 NS_IMPL_RELEASE(nsStringInputStream)
 
-NS_IMPL_CLASSINFO(nsStringInputStream, NULL, nsIClassInfo::THREADSAFE,
+NS_IMPL_CLASSINFO(nsStringInputStream, nullptr, nsIClassInfo::THREADSAFE,
                   NS_STRINGINPUTSTREAM_CID)
 NS_IMPL_QUERY_INTERFACE5_CI(nsStringInputStream,
                             nsIStringInputStream,
                             nsIInputStream,
                             nsISupportsCString,
                             nsISeekableStream,
                             nsIIPCSerializableInputStream)
 NS_IMPL_CI_INTERFACE_GETTER4(nsStringInputStream,
--- a/xpcom/io/nsWildCard.cpp
+++ b/xpcom/io/nsWildCard.cpp
@@ -163,17 +163,17 @@ static int
 
 /**
  * Count characters until we reach a NUL character or either of the
  * two delimiter characters, stop1 or stop2.  If we encounter a bracketed
  * expression, look only for NUL or ']' inside it.  Do not look for stop1
  * or stop2 inside it. Return ABORTED if bracketed expression is unterminated.
  * Handle all escaping.
  * Return index in input string of first stop found, or ABORTED if not found.
- * If "dest" is non-NULL, copy counted characters to it and NUL terminate.
+ * If "dest" is non-nullptr, copy counted characters to it and null terminate.
  */
 template<class T>
 static int
 _scan_and_copy(const T *expr, T stop1, T stop2, T *dest)
 {
     register int sx;     /* source index */
     register T cc;
 
@@ -214,17 +214,17 @@ static int
 {
     register int sx;     /* source index */
     int cp;              /* source index of closing parenthesis */
     int count;
     int ret   = NOMATCH;
     T *e2;
 
     /* Find the closing parenthesis that ends this union in the expression */
-    cp = ::_scan_and_copy(expr, T(')'), T('\0'), static_cast<T*>(NULL));
+    cp = ::_scan_and_copy(expr, T(')'), T('\0'), static_cast<T*>(nullptr));
     if (cp == ABORTED || cp < 4) /* must be at least "(a|b" before ')' */
         return ABORTED;
     ++cp;                /* now index of char after closing parenthesis */
     e2 = (T *) NS_Alloc((1 + nsCharTraits<T>::length(expr)) * sizeof(T));
     if (!e2)
         return ABORTED;
     for (sx = 1; ; ++sx) {
         /* Here, expr[sx] is one character past the preceding '(' or '|'. */
@@ -378,28 +378,28 @@ static int
     return (str[x] ? NOMATCH : MATCH);
 }
 
 
 template<class T>
 static int
 ns_WildCardMatch(const T *str, const T *xp, bool case_insensitive)
 {
-    T *expr = NULL;
+    T *expr = nullptr;
     int x, ret = MATCH;
 
     if (!nsCharTraits<T>::find(xp, nsCharTraits<T>::length(xp), T('~')))
         return ::_shexp_match(str, xp, case_insensitive, 0);
 
     expr = (T *) NS_Alloc((nsCharTraits<T>::length(xp) + 1) * sizeof(T));
     if(!expr)
         return NOMATCH;
     memcpy(expr, xp, (nsCharTraits<T>::length(xp) + 1) * sizeof(T));
 
-    x = ::_scan_and_copy(expr, T('~'), T('\0'), static_cast<T*>(NULL));
+    x = ::_scan_and_copy(expr, T('~'), T('\0'), static_cast<T*>(nullptr));
     if (x != ABORTED && expr[x] == '~') {
         expr[x++] = '\0';
         ret = ::_shexp_match(str, &expr[x], case_insensitive, 0);
         switch (ret) {
         case NOMATCH: ret = MATCH;   break;
         case MATCH:   ret = NOMATCH; break;
         default:                     break;
         }