Skip to content

Commit

Permalink
Merge bitcoin#11066: Document the preference of nullptr over NULL or …
Browse files Browse the repository at this point in the history
…(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 bitcoin#10483
  * `0 → nullptr` was handled in the recently merged PR bitcoin#10645

Tree-SHA512: f863096aa4eb21705910f89713ca9cc0d83c6df2147e3d3530c3e1589b96f6c68de8755dcf37d8ce99ebda3cfb69805e00eab13bf65424aaf16170e9dda3958a
  • Loading branch information
laanwj authored and PastaPastaPasta committed Sep 23, 2019
1 parent 01c72d3 commit 91ac93c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ code.

- **Miscellaneous**
- `++i` is preferred over `i++`.
- `nullptr` is preferred over `NULL` or `(void*)0`.
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
- Align pointers and references to the left i.e. use `type& var` and not `type &var`.

Expand Down Expand Up @@ -288,7 +289,7 @@ Wallet

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

- Include `db_cxx.h` (BerkeleyDB header) only when `ENABLE_WALLET` is set
Expand Down
8 changes: 4 additions & 4 deletions src/qt/macdockiconhandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
extern void qt_mac_set_dock_menu(QMenu *);
#endif

static MacDockIconHandler *s_instance = NULL;
static MacDockIconHandler *s_instance = nullptr;

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

if (appInst != NULL) {
if (appInst != nullptr) {
id delegate = objc_msgSend(appInst, sel_registerName("delegate"));
Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class"));
SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
Expand All @@ -53,7 +53,7 @@ void setupDockClickHandler() {
setupDockClickHandler();
this->m_dummyWidget = new QWidget();
this->m_dockMenu = new QMenu(this->m_dummyWidget);
this->setMainWindow(NULL);
this->setMainWindow(nullptr);
#if QT_VERSION < 0x050000
qt_mac_set_dock_menu(this->m_dockMenu);
#elif QT_VERSION >= 0x050200
Expand All @@ -69,7 +69,7 @@ void setupDockClickHandler() {
MacDockIconHandler::~MacDockIconHandler()
{
delete this->m_dummyWidget;
this->setMainWindow(NULL);
this->setMainWindow(nullptr);
}

QMenu *MacDockIconHandler::dockMenu()
Expand Down
2 changes: 1 addition & 1 deletion src/qt/macnotificationhandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (NSString *)__bundleIdentifier

MacNotificationHandler *MacNotificationHandler::instance()
{
static MacNotificationHandler *s_instance = NULL;
static MacNotificationHandler *s_instance = nullptr;
if (!s_instance) {
s_instance = new MacNotificationHandler();

Expand Down

0 comments on commit 91ac93c

Please sign in to comment.