Skip to content

Commit 9722682

Browse files
committed
Bug 784739 - Switch from NULL to nullptr in modules/; r=ehsan
--HG-- extra : rebase_source : d82c3e2e18986d3b9ffc454ff84caf3634a6bbe7
1 parent 6f158bc commit 9722682

File tree

12 files changed

+69
-69
lines changed

12 files changed

+69
-69
lines changed

modules/libjar/nsJARChannel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ nsJARChannel::~nsJARChannel()
213213
{
214214
// release owning reference to the jar handler
215215
nsJARProtocolHandler *handler = gJarHandler;
216-
NS_RELEASE(handler); // NULL parameter
216+
NS_RELEASE(handler); // nullptr parameter
217217
}
218218

219219
NS_IMPL_ISUPPORTS_INHERITED7(nsJARChannel,

modules/libjar/nsJARFactory.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ NS_DEFINE_NAMED_CID(NS_JARPROTOCOLHANDLER_CID);
2828
NS_DEFINE_NAMED_CID(NS_JARURI_CID);
2929

3030
static const mozilla::Module::CIDEntry kJARCIDs[] = {
31-
{ &kNS_ZIPREADER_CID, false, NULL, nsJARConstructor },
32-
{ &kNS_ZIPREADERCACHE_CID, false, NULL, nsZipReaderCacheConstructor },
33-
{ &kNS_JARPROTOCOLHANDLER_CID, false, NULL, nsJARProtocolHandlerConstructor },
34-
{ &kNS_JARURI_CID, false, NULL, nsJARURIConstructor },
35-
{ NULL }
31+
{ &kNS_ZIPREADER_CID, false, nullptr, nsJARConstructor },
32+
{ &kNS_ZIPREADERCACHE_CID, false, nullptr, nsZipReaderCacheConstructor },
33+
{ &kNS_JARPROTOCOLHANDLER_CID, false, nullptr, nsJARProtocolHandlerConstructor },
34+
{ &kNS_JARURI_CID, false, nullptr, nsJARURIConstructor },
35+
{ nullptr }
3636
};
3737

3838
static const mozilla::Module::ContractIDEntry kJARContracts[] = {
3939
{ "@mozilla.org/libjar/zip-reader;1", &kNS_ZIPREADER_CID },
4040
{ "@mozilla.org/libjar/zip-reader-cache;1", &kNS_ZIPREADERCACHE_CID },
4141
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar", &kNS_JARPROTOCOLHANDLER_CID },
42-
{ NULL }
42+
{ nullptr }
4343
};
4444

4545
// Jar module shutdown hook
@@ -52,9 +52,9 @@ static const mozilla::Module kJARModule = {
5252
mozilla::Module::kVersion,
5353
kJARCIDs,
5454
kJARContracts,
55-
NULL,
56-
NULL,
57-
NULL,
55+
nullptr,
56+
nullptr,
57+
nullptr,
5858
nsJarShutdown
5959
};
6060

modules/libjar/nsZipArchive.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ZipArchiveLogger {
100100
if (path.IsEmpty())
101101
return;
102102
HANDLE handle = CreateFileW(path.get(), FILE_APPEND_DATA, FILE_SHARE_WRITE,
103-
NULL, OPEN_ALWAYS, 0, NULL);
103+
nullptr, OPEN_ALWAYS, 0, nullptr);
104104
if (handle == INVALID_HANDLE_VALUE)
105105
return;
106106
file = PR_ImportFile((PROsfd)handle);
@@ -129,7 +129,7 @@ class ZipArchiveLogger {
129129
MOZ_ASSERT(refCnt > 0);
130130
if ((0 == --refCnt) && fd) {
131131
PR_Close(fd);
132-
fd = NULL;
132+
fd = nullptr;
133133
}
134134
}
135135
private:
@@ -333,7 +333,7 @@ nsresult nsZipArchive::CloseArchive()
333333
{
334334
if (mFd) {
335335
PL_FinishArenaPool(&mArena);
336-
mFd = NULL;
336+
mFd = nullptr;
337337
}
338338

339339
// CAUTION:
@@ -445,7 +445,7 @@ nsZipArchive::FindInit(const char * aPattern, nsZipFind **aFind)
445445
return NS_ERROR_ILLEGAL_VALUE;
446446

447447
// null out param in case an error happens
448-
*aFind = NULL;
448+
*aFind = nullptr;
449449

450450
bool regExp = false;
451451
char* pattern = 0;
@@ -715,7 +715,7 @@ MOZ_WIN_MEM_TRY_BEGIN
715715
// Is the directory already in the file table?
716716
uint32_t hash = HashName(item->Name(), dirlen);
717717
bool found = false;
718-
for (nsZipItem* zi = mFiles[hash]; zi != NULL; zi = zi->next)
718+
for (nsZipItem* zi = mFiles[hash]; zi != nullptr; zi = zi->next)
719719
{
720720
if ((dirlen == zi->nameLength) &&
721721
(0 == memcmp(item->Name(), zi->Name(), dirlen)))
@@ -753,7 +753,7 @@ MOZ_WIN_MEM_TRY_CATCH(return NS_ERROR_FAILURE)
753753
nsZipHandle* nsZipArchive::GetFD()
754754
{
755755
if (!mFd)
756-
return NULL;
756+
return nullptr;
757757
return mFd.get();
758758
}
759759

@@ -821,7 +821,7 @@ nsZipArchive::nsZipArchive()
821821

822822
MOZ_COUNT_CTOR(nsZipArchive);
823823

824-
// initialize the table to NULL
824+
// initialize the table to nullptr
825825
memset(mFiles, 0, sizeof(mFiles));
826826
}
827827

modules/libjar/nsZipArchive.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ class nsZipArchive
169169
* the actual matches. The nsZipFind must be deleted when you're done
170170
*
171171
* @param aPattern a string or RegExp pattern to search for
172-
* (may be NULL to find all files in archive)
172+
* (may be nullptr to find all files in archive)
173173
* @param aFind a pointer to a pointer to a structure used
174174
* in FindNext. In the case of an error this
175-
* will be set to NULL.
175+
* will be set to nullptr.
176176
* @return status code
177177
*/
178178
nsresult FindInit(const char * aPattern, nsZipFind** aFind);
@@ -272,7 +272,7 @@ class nsZipCursor {
272272
* @param aBufSize Buffer size
273273
* @param doCRC When set to true Read() will check crc
274274
*/
275-
nsZipCursor(nsZipItem *aItem, nsZipArchive *aZip, uint8_t* aBuf = NULL, uint32_t aBufSize = 0, bool doCRC = false);
275+
nsZipCursor(nsZipItem *aItem, nsZipArchive *aZip, uint8_t* aBuf = nullptr, uint32_t aBufSize = 0, bool doCRC = false);
276276

277277
~nsZipCursor();
278278

@@ -281,7 +281,7 @@ class nsZipCursor {
281281
* it returns a zero-copy buffer.
282282
*
283283
* @param aBytesRead Outparam for number of bytes read.
284-
* @return data read or NULL if item is corrupted.
284+
* @return data read or nullptr if item is corrupted.
285285
*/
286286
uint8_t* Read(uint32_t *aBytesRead) {
287287
return ReadOrCopy(aBytesRead, false);
@@ -291,7 +291,7 @@ class nsZipCursor {
291291
* Performs a copy. It always uses aBuf(passed in constructor).
292292
*
293293
* @param aBytesRead Outparam for number of bytes read.
294-
* @return data read or NULL if item is corrupted.
294+
* @return data read or nullptr if item is corrupted.
295295
*/
296296
uint8_t* Copy(uint32_t *aBytesRead) {
297297
return ReadOrCopy(aBytesRead, true);
@@ -342,7 +342,7 @@ class nsZipItemPtr : public nsZipItemPtr_base {
342342
public:
343343
nsZipItemPtr(nsZipArchive *aZip, const char *aEntryName, bool doCRC = false) : nsZipItemPtr_base(aZip, aEntryName, doCRC) { }
344344
/**
345-
* @return buffer containing the whole zip member or NULL on error.
345+
* @return buffer containing the whole zip member or nullptr on error.
346346
* The returned buffer is owned by nsZipItemReader.
347347
*/
348348
const T* Buffer() const {
@@ -360,15 +360,15 @@ class nsZipItemPtr : public nsZipItemPtr_base {
360360
*/
361361
T* Forget() {
362362
if (!mReturnBuf)
363-
return NULL;
363+
return nullptr;
364364
// In uncompressed mmap case, give up buffer
365365
if (mAutoBuf.get() == mReturnBuf) {
366-
mReturnBuf = NULL;
366+
mReturnBuf = nullptr;
367367
return (T*) mAutoBuf.forget();
368368
}
369369
T *ret = (T*) malloc(Length());
370370
memcpy(ret, mReturnBuf, Length());
371-
mReturnBuf = NULL;
371+
mReturnBuf = nullptr;
372372
return ret;
373373
}
374374
};

modules/libjar/zipwriter/src/ZipWriterModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ NS_DEFINE_NAMED_CID(DEFLATECONVERTER_CID);
1414
NS_DEFINE_NAMED_CID(ZIPWRITER_CID);
1515

1616
static const mozilla::Module::CIDEntry kZipWriterCIDs[] = {
17-
{ &kDEFLATECONVERTER_CID, false, NULL, nsDeflateConverterConstructor },
18-
{ &kZIPWRITER_CID, false, NULL, nsZipWriterConstructor },
19-
{ NULL }
17+
{ &kDEFLATECONVERTER_CID, false, nullptr, nsDeflateConverterConstructor },
18+
{ &kZIPWRITER_CID, false, nullptr, nsZipWriterConstructor },
19+
{ nullptr }
2020
};
2121

2222
static const mozilla::Module::ContractIDEntry kZipWriterContracts[] = {
@@ -25,7 +25,7 @@ static const mozilla::Module::ContractIDEntry kZipWriterContracts[] = {
2525
{ "@mozilla.org/streamconv;1?from=uncompressed&to=x-gzip", &kDEFLATECONVERTER_CID },
2626
{ "@mozilla.org/streamconv;1?from=uncompressed&to=rawdeflate", &kDEFLATECONVERTER_CID },
2727
{ ZIPWRITER_CONTRACTID, &kZIPWRITER_CID },
28-
{ NULL }
28+
{ nullptr }
2929
};
3030

3131
static const mozilla::Module kZipWriterModule = {

modules/libjar/zipwriter/src/nsZipHeader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,5 @@ const uint8_t * nsZipHeader::GetExtraField(uint16_t aTag, bool aLocal, uint16_t
340340
pos += blocksize;
341341
}
342342

343-
return NULL;
343+
return nullptr;
344344
}

modules/libjar/zipwriter/src/nsZipHeader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ class nsZipHeader MOZ_FINAL : public nsIZipEntry
4747
mIAttr(0),
4848
mInited(false),
4949
mWriteOnClose(false),
50-
mExtraField(NULL),
51-
mLocalExtraField(NULL)
50+
mExtraField(nullptr),
51+
mLocalExtraField(nullptr)
5252
{
5353
}
5454

5555
~nsZipHeader()
5656
{
57-
mExtraField = NULL;
58-
mLocalExtraField = NULL;
57+
mExtraField = nullptr;
58+
mLocalExtraField = nullptr;
5959
}
6060

6161
uint32_t mCRC;

modules/libpref/public/Preferences.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class Preferences : public nsIPrefService,
133133

134134
/**
135135
* Gets char type pref value directly. If failed, the get() of result
136-
* returns NULL. Even if succeeded but the result was empty string, the
137-
* get() does NOT return NULL. So, you can check whether the method
136+
* returns nullptr. Even if succeeded but the result was empty string, the
137+
* get() does NOT return nullptr. So, you can check whether the method
138138
* succeeded or not by:
139139
*
140140
* nsAdoptingString value = Prefereces::GetString("foo.bar");
@@ -149,8 +149,8 @@ class Preferences : public nsIPrefService,
149149
* // the condition is always FALSE!!
150150
* }
151151
*
152-
* The value.get() doesn't return NULL. You must use nsAdoptingString when
153-
* you need to check whether it was failure or not.
152+
* The value.get() doesn't return nullptr. You must use nsAdoptingString
153+
* when you need to check whether it was failure or not.
154154
*/
155155
static nsAdoptingCString GetCString(const char* aPref);
156156
static nsAdoptingString GetString(const char* aPref);
@@ -162,8 +162,8 @@ class Preferences : public nsIPrefService,
162162
* nsIPrefBranch.
163163
*
164164
* @param aPref A pref name.
165-
* @param aResult Must not be NULL. The value is never modified when
166-
* these methods fail.
165+
* @param aResult Must not be nullptr. The value is never modified
166+
* when these methods fail.
167167
*/
168168
static nsresult GetBool(const char* aPref, bool* aResult);
169169
static nsresult GetInt(const char* aPref, int32_t* aResult);
@@ -182,8 +182,8 @@ class Preferences : public nsIPrefService,
182182
* Gets string type pref value with raw return value of nsIPrefBranch.
183183
*
184184
* @param aPref A pref name.
185-
* @param aResult Must not be NULL. The value is never modified when
186-
* these methods fail.
185+
* @param aResult Must not be nullptr. The value is never modified
186+
* when these methods fail.
187187
*/
188188
static nsresult GetCString(const char* aPref, nsACString* aResult);
189189
static nsresult GetString(const char* aPref, nsAString* aResult);
@@ -237,7 +237,7 @@ class Preferences : public nsIPrefService,
237237

238238
/**
239239
* Adds/Removes two or more observers for the root pref branch.
240-
* Pass to aPrefs an array of const char* whose last item is NULL.
240+
* Pass to aPrefs an array of const char* whose last item is nullptr.
241241
*/
242242
static nsresult AddStrongObservers(nsIObserver* aObserver,
243243
const char** aPrefs);
@@ -318,7 +318,7 @@ class Preferences : public nsIPrefService,
318318

319319
/**
320320
* Gets the default value of the char type pref.
321-
* If the get() of the result returned NULL, that meant the value didn't
321+
* If the get() of the result returned nullptr, that meant the value didn't
322322
* have default value.
323323
*
324324
* See the comment at definition at GetString() and GetCString() for more

modules/libpref/src/Preferences.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ Preferences::Shutdown()
412412
if (!sShutdown) {
413413
sShutdown = true; // Don't create the singleton instance after here.
414414

415-
// Don't set NULL to sPreferences here. The instance may be grabbed by
415+
// Don't set sPreferences to nullptr here. The instance may be grabbed by
416416
// other modules. The utility methods of Preferences should be available
417417
// until the singleton instance actually released.
418418
if (sPreferences) {
@@ -659,7 +659,7 @@ ReadExtensionPrefs(nsIFile *aFile)
659659
uint32_t read;
660660

661661
PrefParseState ps;
662-
PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
662+
PREF_InitParseState(&ps, PREF_ReaderCallback, nullptr);
663663
while (NS_SUCCEEDED(rv = stream->Available(&avail)) && avail) {
664664
rv = stream->Read(buffer, 4096, &read);
665665
if (NS_FAILED(rv)) {
@@ -916,7 +916,7 @@ Preferences::WritePrefFile(nsIFile* aFile)
916916
PL_DHashTableEnumerate(&gHashTable, pref_savePref, &saveArgs);
917917

918918
/* Sort the preferences to make a readable file on disk */
919-
NS_QuickSort(valueArray, gHashTable.entryCount, sizeof(char *), pref_CompareStrings, NULL);
919+
NS_QuickSort(valueArray, gHashTable.entryCount, sizeof(char *), pref_CompareStrings, nullptr);
920920

921921
// write out the file header
922922
outStream->Write(outHeader, sizeof(outHeader) - 1, &writeAmount);
@@ -966,7 +966,7 @@ static nsresult openPrefFile(nsIFile* aFile)
966966
return NS_ERROR_OUT_OF_MEMORY;
967967

968968
PrefParseState ps;
969-
PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
969+
PREF_InitParseState(&ps, PREF_ReaderCallback, nullptr);
970970

971971
// Read is not guaranteed to return a buf the size of fileSize,
972972
// but usually will.
@@ -1141,7 +1141,7 @@ static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
11411141
NS_ENSURE_TRUE(manifest.Buffer(), NS_ERROR_NOT_AVAILABLE);
11421142

11431143
PrefParseState ps;
1144-
PREF_InitParseState(&ps, PREF_ReaderCallback, NULL);
1144+
PREF_InitParseState(&ps, PREF_ReaderCallback, nullptr);
11451145
PREF_ParseBuf(&ps, manifest, manifest.Length());
11461146
PREF_FinalizeParseState(&ps);
11471147

modules/libpref/src/nsPrefsFactory.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
2020
static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID);
2121

2222
static mozilla::Module::CIDEntry kPrefCIDs[] = {
23-
{ &kPrefServiceCID, true, NULL, PreferencesConstructor },
24-
{ &kPrefLocalizedStringCID, false, NULL, nsPrefLocalizedStringConstructor },
25-
{ &kRelativeFilePrefCID, false, NULL, nsRelativeFilePrefConstructor },
26-
{ NULL }
23+
{ &kPrefServiceCID, true, nullptr, PreferencesConstructor },
24+
{ &kPrefLocalizedStringCID, false, nullptr, nsPrefLocalizedStringConstructor },
25+
{ &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor },
26+
{ nullptr }
2727
};
2828

2929
static mozilla::Module::ContractIDEntry kPrefContracts[] = {
@@ -32,7 +32,7 @@ static mozilla::Module::ContractIDEntry kPrefContracts[] = {
3232
{ NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID },
3333
// compatibility for extension that uses old service
3434
{ "@mozilla.org/preferences;1", &kPrefServiceCID },
35-
{ NULL }
35+
{ nullptr }
3636
};
3737

3838
static void
@@ -45,9 +45,9 @@ static const mozilla::Module kPrefModule = {
4545
mozilla::Module::kVersion,
4646
kPrefCIDs,
4747
kPrefContracts,
48-
NULL,
49-
NULL,
50-
NULL,
48+
nullptr,
49+
nullptr,
50+
nullptr,
5151
UnloadPrefsModule
5252
};
5353

0 commit comments

Comments
 (0)