From c832ba7c7debddc2c2e5475dbd0b203a17bda4c1 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 17 Oct 2018 09:06:39 +1100 Subject: Backport: Use nullptr and default brace initialisation for some simple cases. Backport of changeset 7118:526318f7d6c7. --- src/Catalogue.cxx | 4 ++-- src/Editor.cxx | 2 +- src/ExternalLexer.cxx | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index 4e5b26bcc..2a42d9f99 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -33,7 +33,7 @@ const LexerModule *Catalogue::Find(int language) { return lm; } } - return 0; + return nullptr; } const LexerModule *Catalogue::Find(const char *languageName) { @@ -45,7 +45,7 @@ const LexerModule *Catalogue::Find(const char *languageName) { } } } - return 0; + return nullptr; } void Catalogue::AddLexerModule(LexerModule *plm) { diff --git a/src/Editor.cxx b/src/Editor.cxx index 1498ce4f6..8e6567a7d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -91,7 +91,7 @@ static bool IsLastStep(const DocModification &mh) { } Timer::Timer() : - ticking(false), ticksToWait(0), tickerID(0) {} + ticking(false), ticksToWait(0), tickerID{} {} Idler::Idler() : state(false), idlerID(0) {} diff --git a/src/ExternalLexer.cxx b/src/ExternalLexer.cxx index a8ed2fef5..4f2ab987b 100644 --- a/src/ExternalLexer.cxx +++ b/src/ExternalLexer.cxx @@ -64,7 +64,9 @@ LexerLibrary::LexerLibrary(const char *moduleName_) { // Assign a buffer for the lexer name. char lexname[100] = ""; GetLexerName(i, lexname, sizeof(lexname)); - ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL); + ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, nullptr, lexname, nullptr); + // This is storing a second reference to lex in the Catalogue as well as in modules. + // TODO: Should use std::shared_ptr or similar to ensure allocation safety. Catalogue::AddLexerModule(lex); // Remember ExternalLexerModule so we don't leak it -- cgit v1.2.3