Skip to content

Commit 9e00a62

Browse files
committed
Merge #11066: Document the preference of nullptr over NULL or (void*)0
bea8e9e Document the preference of nullptr over NULL or (void*)0 (practicalswift) Pull request description: Document the preference of `nullptr` over `NULL` or `(void*)0`. After this commit: ``` $ git grep "[^A-Za-z_]NULL[^A-Za-z_]" | grep -vE '(leveldb|univalue|secp256k1|torcontrol|NULL certificates|ctaes|release-notes|patches|configure.ac|developer-notes)' $ ``` Some context: * `NULL → nullptr` was handled in the recently merged PR #10483 * `0 → nullptr` was handled in the recently merged PR #10645 Tree-SHA512: f863096aa4eb21705910f89713ca9cc0d83c6df2147e3d3530c3e1589b96f6c68de8755dcf37d8ce99ebda3cfb69805e00eab13bf65424aaf16170e9dda3958a
2 parents aeec8b4 + bea8e9e commit 9e00a62

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

doc/developer-notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ code.
3737

3838
- **Miscellaneous**
3939
- `++i` is preferred over `i++`.
40+
- `nullptr` is preferred over `NULL` or `(void*)0`.
4041
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
4142

4243
Block style example:
@@ -276,7 +277,7 @@ Wallet
276277

277278
- *Rationale*: In RPC code that conditionally uses the wallet (such as
278279
`validateaddress`) it is easy to forget that global pointer `pwalletMain`
279-
can be NULL. See `test/functional/disablewallet.py` for functional tests
280+
can be nullptr. See `test/functional/disablewallet.py` for functional tests
280281
exercising the API with `-disablewallet`
281282

282283
- Include `db_cxx.h` (BerkeleyDB header) only when `ENABLE_WALLET` is set

src/qt/macdockiconhandler.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
extern void qt_mac_set_dock_menu(QMenu *);
1919
#endif
2020

21-
static MacDockIconHandler *s_instance = NULL;
21+
static MacDockIconHandler *s_instance = nullptr;
2222

2323
bool dockClickHandler(id self,SEL _cmd,...) {
2424
Q_UNUSED(self)
@@ -34,7 +34,7 @@ void setupDockClickHandler() {
3434
Class cls = objc_getClass("NSApplication");
3535
id appInst = objc_msgSend((id)cls, sel_registerName("sharedApplication"));
3636

37-
if (appInst != NULL) {
37+
if (appInst != nullptr) {
3838
id delegate = objc_msgSend(appInst, sel_registerName("delegate"));
3939
Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class"));
4040
SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
@@ -53,7 +53,7 @@ void setupDockClickHandler() {
5353
setupDockClickHandler();
5454
this->m_dummyWidget = new QWidget();
5555
this->m_dockMenu = new QMenu(this->m_dummyWidget);
56-
this->setMainWindow(NULL);
56+
this->setMainWindow(nullptr);
5757
#if QT_VERSION < 0x050000
5858
qt_mac_set_dock_menu(this->m_dockMenu);
5959
#elif QT_VERSION >= 0x050200
@@ -69,7 +69,7 @@ void setupDockClickHandler() {
6969
MacDockIconHandler::~MacDockIconHandler()
7070
{
7171
delete this->m_dummyWidget;
72-
this->setMainWindow(NULL);
72+
this->setMainWindow(nullptr);
7373
}
7474

7575
QMenu *MacDockIconHandler::dockMenu()

src/qt/macnotificationhandler.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ - (NSString *)__bundleIdentifier
7575

7676
MacNotificationHandler *MacNotificationHandler::instance()
7777
{
78-
static MacNotificationHandler *s_instance = NULL;
78+
static MacNotificationHandler *s_instance = nullptr;
7979
if (!s_instance) {
8080
s_instance = new MacNotificationHandler();
8181

src/random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void GetOSRand(unsigned char *ent32)
242242
}
243243
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
244244
// We need a fallback for OSX < 10.12
245-
if (&getentropy != NULL) {
245+
if (&getentropy != nullptr) {
246246
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
247247
RandFailure();
248248
}

0 commit comments

Comments
 (0)