[glibmm/c++11v2: 3/4] C++11: examples: Use nullptr.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/c++11v2: 3/4] C++11: examples: Use nullptr.
- Date: Wed, 21 Jan 2015 07:34:49 +0000 (UTC)
commit e4677407be25f1fa7814be41e012d1273efa993c
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jun 27 10:25:21 2013 +0200
C++11: examples: Use nullptr.
examples/child_watch/main.cc | 2 +-
examples/iochannel_stream/fdstream.cc | 8 ++++----
examples/network/resolver.cc | 2 +-
examples/thread/dispatcher.cc | 4 ++--
examples/thread/dispatcher2.cc | 10 +++++-----
5 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/examples/child_watch/main.cc b/examples/child_watch/main.cc
index 3bbc368..883577a 100644
--- a/examples/child_watch/main.cc
+++ b/examples/child_watch/main.cc
@@ -40,7 +40,7 @@ void ChildWatch::run()
{
GPid pid = fork();
- if(pid==0)
+ if(!pid)
{
sleep(5);
exit(0);
diff --git a/examples/iochannel_stream/fdstream.cc b/examples/iochannel_stream/fdstream.cc
index be97676..90df473 100644
--- a/examples/iochannel_stream/fdstream.cc
+++ b/examples/iochannel_stream/fdstream.cc
@@ -280,8 +280,8 @@ std::streamsize fdstreambuf::xsgetn(char* dest, std::streamsize num)
}
fdstream::fdstream(int fd, bool manage)
-: std::istream(0),
- std::ostream(0),
+: std::istream(nullptr),
+ std::ostream(nullptr),
buf(fd, manage)
{
std::istream::rdbuf(&buf);
@@ -289,8 +289,8 @@ fdstream::fdstream(int fd, bool manage)
}
fdstream::fdstream()
-: std::istream(0),
- std::ostream(0)
+: std::istream(nullptr),
+ std::ostream(nullptr)
{
std::istream::rdbuf(&buf);
std::ostream::rdbuf(&buf);
diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc
index 4fdf0cf..dee1ebf 100644
--- a/examples/network/resolver.cc
+++ b/examples/network/resolver.cc
@@ -405,7 +405,7 @@ do_connectable (const std::string& arg, gboolean synchronous)
{
host = arg.substr (0, pos);
port_str = arg.substr(pos);
- port = strtoul (port_str.c_str (), NULL, 10);
+ port = strtoul (port_str.c_str (), nullptr, 10);
}
else
port = 0;
diff --git a/examples/thread/dispatcher.cc b/examples/thread/dispatcher.cc
index 21833e7..1c1eb66 100644
--- a/examples/thread/dispatcher.cc
+++ b/examples/thread/dispatcher.cc
@@ -80,7 +80,7 @@ public:
ThreadProgress::ThreadProgress(int id)
:
- thread_ (0),
+ thread_ (nullptr),
id_ (id),
progress_ (0)
{
@@ -91,7 +91,7 @@ ThreadProgress::ThreadProgress(int id)
ThreadProgress::~ThreadProgress()
{
// It is an error if the thread is still running at this point.
- g_return_if_fail(thread_ == 0);
+ g_return_if_fail(thread_ == nullptr);
}
int ThreadProgress::id() const
diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc
index dd7d7de..b9afebc 100644
--- a/examples/thread/dispatcher2.cc
+++ b/examples/thread/dispatcher2.cc
@@ -77,7 +77,7 @@ ThreadTimer::ThreadTimer()
// Create a new Glib::Dispatcher that is attached to the default main context,
signal_increment_ (),
// This pointer will be initialized later by the 2nd thread.
- signal_finished_ptr_ (NULL)
+ signal_finished_ptr_ (nullptr)
{
// Connect the cross-thread signal.
signal_increment_.connect(sigc::mem_fun(*this, &ThreadTimer::timer_increment));
@@ -99,7 +99,7 @@ void ThreadTimer::launch()
sigc::mem_fun(*this, &ThreadTimer::thread_function));
// Wait for the 2nd thread's startup notification.
- while(signal_finished_ptr_ == NULL)
+ while(!signal_finished_ptr_)
startup_cond_.wait(startup_mutex_);
}
@@ -109,10 +109,10 @@ void ThreadTimer::signal_finished_emit()
signal_finished_ptr_->emit();
// wait for the thread to join
- if(thread_ != NULL)
+ if(thread_)
thread_->join();
- signal_finished_ptr_ = NULL;
+ signal_finished_ptr_ = nullptr;
}
void ThreadTimer::print() const
@@ -189,7 +189,7 @@ ThreadTimer::type_signal_end ThreadTimer::signal_end_;
ThreadDispatcher::ThreadDispatcher()
:
- timer_ (NULL)
+ timer_ (nullptr)
{
std::cout << "Thread Dispatcher Example #2" << std::endl;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]