From 6244d73850074631ceaaccdf7f755970323f8de2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 29 Sep 2018 12:34:41 +0200 Subject: Use nullptr --- src/AtomReader.cpp | 6 +++--- src/AtomWriter.cpp | 2 +- src/SocketWriter.cpp | 2 +- src/URI.cpp | 14 +++++++------- src/URIMap.cpp | 2 +- src/gui/Arc.cpp | 2 +- src/gui/GraphBox.cpp | 2 +- src/gui/GraphTreeWindow.hpp | 2 +- src/gui/WindowFactory.cpp | 2 +- src/gui/WindowFactory.hpp | 4 ++-- src/ingen/ingen.cpp | 3 ++- src/server/ControlBindings.cpp | 14 ++++++++++---- src/server/Driver.hpp | 2 +- src/server/PostProcessor.cpp | 2 +- src/server/PreProcessor.cpp | 6 +++--- src/server/RunContext.hpp | 2 +- src/server/events/Delete.hpp | 4 ++-- 17 files changed, 39 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index 209966cf..cc47498f 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -156,7 +156,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) lv2_atom_object_get(obj, (LV2_URID)_uris.patch_subject, &subject, (LV2_URID)_uris.patch_sequenceNumber, &number, - NULL); + nullptr); const boost::optional subject_uri = atom_to_uri(subject); @@ -187,7 +187,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) (LV2_URID)_uris.ingen_tail, &tail, (LV2_URID)_uris.ingen_head, &head, (LV2_URID)_uris.ingen_incidentTo, &incidentTo, - NULL); + nullptr); boost::optional subject_path(atom_to_path(subject)); boost::optional tail_path(atom_to_path(tail)); @@ -223,7 +223,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id) lv2_atom_object_get(body, (LV2_URID)_uris.ingen_tail, &tail, (LV2_URID)_uris.ingen_head, &head, - NULL); + nullptr); if (!tail || !head) { _log.warn("Arc has no tail or head\n"); return false; diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index c83c5c5a..9c7da98e 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -24,7 +24,7 @@ * * 1. When Ingen is running as a process, a socket accepts messages in * (textual) Turtle syntax, and responds in the same syntax. Transfers are - * delimited by NULL characters in the stream, so the client knows when to + * delimited by null characters in the stream, so the client knows when to * finish parsing to interpret responses. By default, Ingen listens on * unix:///tmp/ingen.sock and tcp://localhost:16180 * diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp index f3ab671d..dcba5799 100644 --- a/src/SocketWriter.cpp +++ b/src/SocketWriter.cpp @@ -50,7 +50,7 @@ SocketWriter::bundle_end() { TurtleWriter::bundle_end(); - // Send a NULL byte to indicate end of bundle + // Send a null byte to indicate end of bundle const char end[] = { 0 }; send(_socket->fd(), end, 1, MSG_NOSIGNAL); } diff --git a/src/URI.cpp b/src/URI.cpp index 5de447a6..8f71b70c 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -28,12 +28,12 @@ URI::URI() URI::URI(const std::string& str) : _node(serd_node_new_uri_from_string((const uint8_t*)str.c_str(), - NULL, + nullptr, &_uri)) {} URI::URI(const char* str) - : _node(serd_node_new_uri_from_string((const uint8_t*)str, NULL, &_uri)) + : _node(serd_node_new_uri_from_string((const uint8_t*)str, nullptr, &_uri)) {} URI::URI(const std::string& str, const URI& base) @@ -43,7 +43,7 @@ URI::URI(const std::string& str, const URI& base) {} URI::URI(SerdNode node) - : _node(serd_node_new_uri_from_node(&node, NULL, &_uri)) + : _node(serd_node_new_uri_from_node(&node, nullptr, &_uri)) { assert(node.type == SERD_URI); } @@ -62,20 +62,20 @@ URI::URI(const Sord::Node& node) URI::URI(const FilePath& path) : _node(serd_node_new_file_uri((const uint8_t*)path.c_str(), - NULL, + nullptr, &_uri, true)) {} URI::URI(const URI& uri) - : _node(serd_node_new_uri(&uri._uri, NULL, &_uri)) + : _node(serd_node_new_uri(&uri._uri, nullptr, &_uri)) {} URI& URI::operator=(const URI& uri) { serd_node_free(&_node); - _node = serd_node_new_uri(&uri._uri, NULL, &_uri); + _node = serd_node_new_uri(&uri._uri, nullptr, &_uri); return *this; } @@ -106,7 +106,7 @@ URI URI::make_relative(const URI& base) const { SerdURI uri; - SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, NULL, &uri); + SerdNode node = serd_node_new_relative_uri(&_uri, &base._uri, nullptr, &uri); return URI(node, uri); } diff --git a/src/URIMap.cpp b/src/URIMap.cpp index db1cd9e3..7c5774f8 100644 --- a/src/URIMap.cpp +++ b/src/URIMap.cpp @@ -91,7 +91,7 @@ URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle h, return (urid > 0 && urid <= map->_unmap.size() ? map->_unmap[urid - 1].c_str() - : NULL); + : nullptr); } const char* diff --git a/src/gui/Arc.cpp b/src/gui/Arc.cpp index db8b3a85..339a1248 100644 --- a/src/gui/Arc.cpp +++ b/src/gui/Arc.cpp @@ -34,7 +34,7 @@ Arc::Arc(Ganv::Canvas& canvas, SPtr tparent_block; if ((tparent_block = dynamic_ptr_cast(tparent))) { if (tparent_block->plugin_uri() == NS_INTERNALS "BlockDelay") { - g_object_set(_gobj, "dash-length", 4.0, NULL); + g_object_set(_gobj, "dash-length", 4.0, nullptr); set_constraining(false); } } diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index be076f6c..966e8b9c 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -265,7 +265,7 @@ GraphBox::set_graph_from_path(const Raul::Path& path, SPtr view) /** Sets the graph for this box and initializes everything. * - * If `view` is NULL, a new view will be created. + * If `view` is null, a new view will be created. */ void GraphBox::set_graph(SPtr graph, diff --git a/src/gui/GraphTreeWindow.hpp b/src/gui/GraphTreeWindow.hpp index 9ab05f94..0df5d01c 100644 --- a/src/gui/GraphTreeWindow.hpp +++ b/src/gui/GraphTreeWindow.hpp @@ -98,7 +98,7 @@ public: GraphTreeView(BaseObjectType* cobject, const Glib::RefPtr& xml) : Gtk::TreeView(cobject) - , _window(NULL) + , _window(nullptr) {} void set_window(GraphTreeWindow* win) { _window = win; } diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index c5f9c089..06c8266a 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -130,7 +130,7 @@ WindowFactory::parent_graph_window(SPtr block) /** Present a GraphWindow for a Graph. * - * If `preferred` is not NULL, it will be set to display `graph` if the graph + * If `preferred` is not null, it will be set to display `graph` if the graph * does not already have a visible window, otherwise that window will be * presented and `preferred` left unmodified. */ diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp index a6ddb682..4e71c7cf 100644 --- a/src/gui/WindowFactory.hpp +++ b/src/gui/WindowFactory.hpp @@ -61,7 +61,7 @@ public: void present_graph( SPtr graph, - GraphWindow* preferred = NULL, + GraphWindow* preferred = nullptr, SPtr view = SPtr()); void present_load_plugin(SPtr graph, Properties data=Properties()); @@ -71,7 +71,7 @@ public: void present_rename(SPtr object); void present_properties(SPtr object); - bool remove_graph_window(GraphWindow* win, GdkEventAny* ignored = NULL); + bool remove_graph_window(GraphWindow* win, GdkEventAny* ignored = nullptr); void set_main_box(GraphBox* box) { _main_box = box; } diff --git a/src/ingen/ingen.cpp b/src/ingen/ingen.cpp index bf18f0dd..9d099a43 100644 --- a/src/ingen/ingen.cpp +++ b/src/ingen/ingen.cpp @@ -92,7 +92,8 @@ main(int argc, char** argv) // Create world try { - world = unique_ptr(new ingen::World(nullptr, NULL, NULL)); + world = unique_ptr( + new ingen::World(nullptr, nullptr, nullptr)); world->load_configuration(argc, argv); if (argc <= 1) { world->conf().print_usage("ingen", cout); diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 45df0e8f..94a12a7e 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -75,8 +75,11 @@ ControlBindings::binding_key(const Atom& binding) const } else if (obj->otype == uris.midi_ChannelPressure) { key = Key(Type::MIDI_CHANNEL_PRESSURE); } else if (obj->otype == uris.midi_Controller) { - lv2_atom_object_body_get( - binding.size(), obj, (LV2_URID)uris.midi_controllerNumber, &num, NULL); + lv2_atom_object_body_get(binding.size(), + obj, + (LV2_URID)uris.midi_controllerNumber, + &num, + nullptr); if (!num) { _engine.log().rt_error("Controller binding missing number\n"); } else if (num->type != uris.atom_Int) { @@ -85,8 +88,11 @@ ControlBindings::binding_key(const Atom& binding) const key = Key(Type::MIDI_CC, ((LV2_Atom_Int*)num)->body); } } else if (obj->otype == uris.midi_NoteOn) { - lv2_atom_object_body_get( - binding.size(), obj, (LV2_URID)uris.midi_noteNumber, &num, NULL); + lv2_atom_object_body_get(binding.size(), + obj, + (LV2_URID)uris.midi_noteNumber, + &num, + nullptr); if (!num) { _engine.log().rt_error("Note binding missing number\n"); } else if (num->type != uris.atom_Int) { diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp index dbb67bf3..76040395 100644 --- a/src/server/Driver.hpp +++ b/src/server/Driver.hpp @@ -48,7 +48,7 @@ public: virtual void deactivate() {} /** Create a port ready to be inserted with add_input (non realtime). - * May return NULL if the Driver can not create the port for some reason. + * May return null if the Driver can not create the port for some reason. */ virtual EnginePort* create_port(DuplexPort* graph_port) = 0; diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp index 02a6f639..70be6f7b 100644 --- a/src/server/PostProcessor.cpp +++ b/src/server/PostProcessor.cpp @@ -76,7 +76,7 @@ PostProcessor::process() { const FrameTime end_time = _max_time; - /* We can never empty the list and set _head = _tail = NULL since this + /* We can never empty the list and set _head = _tail = null since this would cause a race with append. Instead, head is an already post-processed node, or initially a sentinel. */ Event* ev = _head.load(); diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index a9d9cf2d..dbe7ddbe 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -64,7 +64,7 @@ PreProcessor::event(Event* const ev, Event::Mode mode) ev->set_mode(mode); /* Note that tail is only used here, not in process(). The head must be - checked first here, since if it is NULL the tail pointer is junk. */ + checked first here, since if it is null the tail pointer is junk. */ Event* const head = _head.load(); if (!head) { _head = ev; @@ -153,10 +153,10 @@ PreProcessor::process(RunContext& context, PostProcessor& dest, size_t limit) last->next(nullptr); dest.append(context, head, last); - // Since _head was not NULL, we know it hasn't been changed since + // Since _head was not null, we know it hasn't been changed since _head = next; - /* If next is NULL, then _tail may now be invalid. However, it would cause + /* If next is null, then _tail may now be invalid. However, it would cause a race to reset _tail here. Instead, append() checks only _head for emptiness, and resets the tail appropriately. */ } diff --git a/src/server/RunContext.hpp b/src/server/RunContext.hpp index 78580fd7..15e65806 100644 --- a/src/server/RunContext.hpp +++ b/src/server/RunContext.hpp @@ -144,7 +144,7 @@ protected: Engine& _engine; ///< Engine we're running in Raul::RingBuffer* _event_sink; ///< Port updates from process context Task* _task; ///< Currently executing task - std::thread* _thread; ///< Thread (NULL for main run context) + std::thread* _thread; ///< Thread (null for main run context) unsigned _id; ///< Context ID FrameTime _start; ///< Start frame of this cycle, timeline relative diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index ebc57122..4b0c314b 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -67,8 +67,8 @@ private: const ingen::Del _msg; Raul::Path _path; - SPtr _block; ///< Non-NULL iff a block - SPtr _port; ///< Non-NULL iff a port + SPtr _block; ///< Non-null iff a block + SPtr _port; ///< Non-null iff a port EnginePort* _engine_port; MPtr _ports_array; ///< New (external) ports for Graph MPtr _compiled_graph; ///< Graph's new process order -- cgit v1.2.1