]> git.tdb.fi Git - libs/core.git/commitdiff
Use nullptr instead of 0 for pointers
authorMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 17:09:29 +0000 (19:09 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 31 Oct 2021 19:35:23 +0000 (21:35 +0200)
58 files changed:
examples/z.cpp
source/core/android/main.cpp
source/core/android/mainthread.cpp
source/core/android/mainthread.h
source/core/application.cpp
source/core/application.h
source/core/getopt.h
source/core/module.h
source/core/mutex.h
source/core/osx/main.cpp
source/core/process.cpp
source/core/process.h
source/core/refptr.h
source/core/semaphore.h
source/core/thread.cpp
source/core/thread.h
source/core/unix/main.cpp
source/core/unix/mutex.cpp
source/core/unix/process.cpp
source/core/unix/semaphore.cpp
source/core/unix/thread.cpp
source/core/variant.h
source/core/windows/process.cpp
source/core/windows/systemerror.cpp
source/core/windows/thread.cpp
source/debug/backtrace.h
source/debug/demangle.cpp
source/debug/errorreporter.cpp
source/debug/errorreporter.h
source/debug/exceptiontrace.cpp
source/debug/profiler.h
source/debug/profilingscope.h
source/fs/filemonitor.cpp
source/fs/filemonitor.h
source/fs/stat.cpp
source/fs/stat.h
source/fs/windows/dir.cpp
source/fs/windows/dir_location.cpp
source/fs/windows/stat.cpp
source/fs/windows/stat_platform.h
source/io/asset.h
source/io/base.h
source/io/buffered.h
source/io/eventreader.h
source/io/handle.h
source/io/memory.h
source/io/poll.h
source/io/windows/eventreader.cpp
source/io/windows/file.cpp
source/io/windows/handle.cpp
source/io/windows/pipe.cpp
source/io/windows/serial.cpp
source/io/zlibcompressed.cpp
source/io/zlibcompressed.h
source/stringcodec/iso2022jp.h
source/time/timer.cpp
source/time/timer.h
source/time/unix/utils.cpp

index d98392cfeaa92d18c102607ab171c3d1bed444d1..5f793c40cbdf08b68ac0316857ff8718856683da 100644 (file)
@@ -24,7 +24,7 @@ public:
 };
 
 Z::Z(int argc, char **argv):
-       input_file(0)
+       input_file(nullptr)
 {
        string input_fn;
        GetOpt getopt;
index a71d92f1c279d0ba43c24c62ea656024d726cdca..ff811c19dd4172ba51c98953b76f1976bb3cc8ac 100644 (file)
@@ -2,7 +2,7 @@
 
 extern "C" void ANativeActivity_onCreate(ANativeActivity *activity, void * /*saved_state*/, size_t /*state_size*/)
 {
-       static Msp::Android::MainThread *thread = 0;
+       static Msp::Android::MainThread *thread = nullptr;
        if(thread)
                thread->attach_to_activity(activity);
        else
index b816bf638c4543957b3a0a7814c2010ff0f561ec..6441c2059b8179066fc61336801940320dedad9a 100644 (file)
@@ -53,7 +53,7 @@ void MainThread::resume_startup()
 JavaVM *MainThread::get_java_vm() const
 {
        if(!activity)
-               return 0;
+               return nullptr;
 
        return activity->vm;
 }
@@ -68,7 +68,7 @@ void MainThread::main()
        /* I have no idea how dependable this is, but it seems to be the only way
        to get the package name aside from making a Java call through JNI */
        char *appname = strdup(int_data_path[-2].c_str());
-       char *argv[] = { appname, 0 };
+       char *argv[] = { appname, nullptr };
        Msp::Android::ErrorLogger err_logger;
        FS::chdir(FS::dirname(int_data_path));
        Msp::Application::run(1, argv, this, &app_created);
index 99a641b6e71084828d0c0b88364ff0425f697751..9ce9428568c5bada1529c762e6b2fa04fdeb3ca3 100644 (file)
@@ -20,8 +20,8 @@ public:
        sigc::signal<void, AInputQueue *> signal_input_queue_destroyed;
 
 private:
-       ANativeActivity *activity = 0;
-       AAssetManager *asset_manager = 0;
+       ANativeActivity *activity = nullptr;
+       AAssetManager *asset_manager = nullptr;
        FS::Path int_data_path;
        bool starting_up = true;
        Mutex startup_mutex;
index 1fbe15452fd8a13d39c3c0939d2c09419e5b6733..8447eed669d2b8f58c9b078b547b1543b0bab27f 100644 (file)
@@ -15,11 +15,11 @@ using namespace std;
 
 namespace Msp {
 
-Application *Application::_app = 0;
-Application::Starter *Application::_starter = 0;
-const char *Application::_argv0 = 0;
+Application *Application::_app = nullptr;
+Application::Starter *Application::_starter = nullptr;
+const char *Application::_argv0 = nullptr;
 string Application::_name;
-void *Application::_data = 0;
+void *Application::_data = nullptr;
 
 Application::Application(const string &n)
 {
@@ -59,7 +59,7 @@ int Application::run(int argc, char **argv, void *data, void (*created_callback)
 
                int result = _app->main();
                Application *a = _app;
-               _app = 0;
+               _app = nullptr;
                delete a;
                return result;
        }
@@ -85,7 +85,7 @@ int Application::run(int argc, char **argv, void *data, void (*created_callback)
                }
 
                delete _app;
-               _app = 0;
+               _app = nullptr;
 
                return 124;
        }
index c3c693d3052a2fb9808bc3018cdecd40218102d2..972f3b73b1f8d9767e1f72bcd4ccdf6529415a47 100644 (file)
@@ -44,7 +44,7 @@ public:
 
        This function can only be called once.  The global main() function provided
        by the library normally does it automatically at program startup. */
-       static int run(int, char **, void * = 0, void (*)(void *) = 0);
+       static int run(int, char **, void * = nullptr, void (*)(void *) = nullptr);
 
        /** Sets application startup info, including argv[0] value and platform-
        specific data.
index ed6cf86195d2419cf7e3b579e470b64e242bc0bd..ade620bf94d5c46bc2b6c36197a807a4b4edb986 100644 (file)
@@ -121,10 +121,10 @@ private:
                std::string lng;
                ArgType arg_type = NO_ARG;
                unsigned seen_count = 0;
-               unsigned *ext_seen_count = 0;
+               unsigned *ext_seen_count = nullptr;
                std::string help;
                std::string metavar = "ARG";
-               Store *store = 0;
+               Store *store = nullptr;
 
        public:
                OptionImpl(char, const std::string &, const Store &, ArgType);
@@ -149,7 +149,7 @@ private:
                std::string name;
                ArgType type = REQUIRED_ARG;
                std::string help;
-               Store *store = 0;
+               Store *store = nullptr;
 
        public:
                ArgumentImpl(const std::string &, const Store &, ArgType);
index 339af08e99b6fc2f31986179ed4c14f1082892bc..4b1e3e8dd983b6e306418c299d5d78b633ee187a 100644 (file)
@@ -11,7 +11,7 @@ class Module: private NonCopyable
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Module(const std::string &);
index dc9a2285be5919c519c7d67d7adfdee9ebea0711..6582074e182c988c3d813671b3cb92668c27ceeb 100644 (file)
@@ -17,7 +17,7 @@ class Mutex: private NonCopyable
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Mutex();
@@ -67,7 +67,7 @@ public:
 
        T &operator*() const { return *data; }
        T *operator->() const { return data; }
-       void clear() { mutex = 0; data = 0; }
+       void clear() { mutex = nullptr; data = nullptr; }
 };
 
 }
index e9a6fe273ddd6008ed28929640ec5b730102283b..4bb81c83c41c4380857e6f0d7b49497bb2fae65b 100644 (file)
@@ -3,7 +3,7 @@
 
 int main(int argc, char **argv)
 {
-       void *data = 0;
+       void *data = nullptr;
 
        /* Applications launched from Finder get a special argument, which would
        interfere with GetOpt.  Remove it from argv but pass it as data so it can
@@ -17,7 +17,7 @@ int main(int argc, char **argv)
                        argv[j++] = argv[i];
        }
        argc = j;
-       argv[j] = 0;
+       argv[j] = nullptr;
 
        return Msp::Application::run(argc, argv, data);
 }
index 92475d4286782642dac9da3e989544947741f282..43b7384a5a3d66d49fd708e45d7cd274795f04ac 100644 (file)
@@ -6,7 +6,7 @@ using namespace std;
 
 namespace Msp {
 
-Process *Process::_self = 0;
+Process *Process::_self = nullptr;
 
 Process::Process(const Private &p):
        priv(new Private(p))
index f21ecb337d76d5c8718b056478597968f04c0f9a..0d7faa6c82f96c0e1eb413e582eab6c5a10ff4f4 100644 (file)
@@ -30,12 +30,12 @@ public:
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
        FS::Path work_dir;
        bool redirect = false;
-       IO::Base *cin = 0;
-       IO::Base *cout = 0;
-       IO::Base *cerr = 0;
+       IO::Base *cin = nullptr;
+       IO::Base *cout = nullptr;
+       IO::Base *cerr = nullptr;
        bool running = false;
        bool finished = false;
        unsigned exit_code = 0;
index 70cb17607361364de990f8828643f80af8d8da00..34560ec0389beea43bbfb66fe2db1bd111bb954a 100644 (file)
@@ -31,14 +31,14 @@ class RefPtr
        template<typename U> friend class WeakPtr;
 
 private:
-       T *data = 0;
-       RefCounts *counts = 0;
+       T *data = nullptr;
+       RefCounts *counts = nullptr;
 
 public:
        RefPtr() = default;
-       RefPtr(T *d): data(d), counts(data ? new RefCounts : 0) { incref(); }
+       RefPtr(T *d): data(d), counts(data ? new RefCounts : nullptr) { incref(); }
 private:
-       RefPtr(T *d, RefCounts *c): data(d), counts(d ? c : 0) { incref(); }
+       RefPtr(T *d, RefCounts *c): data(d), counts(d ? c : nullptr) { incref(); }
 
 public:
        /* Must have this or the compiler will generate a default copy-c'tor despite
@@ -49,7 +49,7 @@ public:
        RefPtr(const RefPtr<U> &p): data(p.data), counts(p.counts) { incref(); }
 
        template<typename U>
-       RefPtr(const WeakPtr<U> &p): data(p.get()), counts(data ? p.counts : 0) { incref(); }
+       RefPtr(const WeakPtr<U> &p): data(p.get()), counts(data ? p.counts : nullptr) { incref(); }
 
        ~RefPtr() { decref(); }
 
@@ -81,7 +81,7 @@ public:
        T *get() const { return data; }
        T &operator*() const { return *data; }
        T *operator->() const { return data; }
-       explicit operator bool() const { return data!=0; }
+       explicit operator bool() const { return data; }
 
        unsigned refcount() const { return (data ? counts->count : 0); }
 
@@ -102,19 +102,19 @@ class WeakPtr
        template<typename U> friend class WeakPtr;
 
 private:
-       T *data = 0;
-       RefCounts *counts = 0;
+       T *data = nullptr;
+       RefCounts *counts = nullptr;
 
 public:
        WeakPtr() = default;
 private:
-       WeakPtr(T *d, RefCounts *c): data(d), counts(d ? c : 0) { incref(); }
+       WeakPtr(T *d, RefCounts *c): data(d), counts(d ? c : nullptr) { incref(); }
 
 public:
-       WeakPtr(const WeakPtr &p): data(p.get()), counts(data ? p.counts : 0) { incref(); }
+       WeakPtr(const WeakPtr &p): data(p.get()), counts(data ? p.counts : nullptr) { incref(); }
 
        template<typename U>
-       WeakPtr(const WeakPtr<U> &p): data(p.get()), counts(data ? p.counts : 0) { incref(); }
+       WeakPtr(const WeakPtr<U> &p): data(p.get()), counts(data ? p.counts : nullptr) { incref(); }
 
        template<typename U>
        WeakPtr(const RefPtr<U> &p): data(p.data), counts(p.counts) { incref(); }
@@ -131,7 +131,7 @@ private:
        template<typename U>
        WeakPtr &assign(const WeakPtr<U> &);
 
-       T *get() const { return (counts && counts->count ? data : 0); }
+       T *get() const { return (counts && counts->count ? data : nullptr); }
        void incref() { if(counts) ++counts->weak_count; }
        void decref();
 };
@@ -142,7 +142,7 @@ RefPtr<T> &RefPtr<T>::operator=(T *d)
 {
        decref();
        data = d;
-       counts = (d ? new RefCounts : 0);
+       counts = (d ? new RefCounts : nullptr);
        incref();
        return *this;
 }
@@ -162,9 +162,9 @@ template<typename T>
 T *RefPtr<T>::release()
 {
        T *d = data;
-       data = 0;
+       data = nullptr;
        decref();
-       counts = 0;
+       counts = nullptr;
        return d;
 }
 
@@ -176,17 +176,17 @@ void RefPtr<T>::decref()
        if(!counts->count)
        {
                delete data;
-               data = 0;
+               data = nullptr;
        }
        else if(counts->count==RefCounts::KEEP)
-               data = 0;
+               data = nullptr;
        else
                return;
 
        if(!counts->weak_count)
        {
                delete counts;
-               counts = 0;
+               counts = nullptr;
        }
 }
 
@@ -197,7 +197,7 @@ WeakPtr<T> &WeakPtr<T>::assign(const WeakPtr<U> &p)
 {
        decref();
        data = p.get();
-       counts = (data ? p.counts : 0);
+       counts = (data ? p.counts : nullptr);
        incref();
        return *this;
 }
@@ -210,8 +210,8 @@ void WeakPtr<T>::decref()
        if(!counts->weak_count && (!counts->count || counts->count==RefCounts::KEEP))
        {
                delete counts;
-               data = 0;
-               counts = 0;
+               data = nullptr;
+               counts = nullptr;
        }
 }
 
index 4b229450565aca9e637887b4662c7d1810165d76..28c3b3d72cb8f009fd4474cfa73ab586db1a1d02 100644 (file)
@@ -11,7 +11,7 @@ class Semaphore: private NonCopyable
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Semaphore(unsigned);
index 841cc3f48e8111a894dc9151268fce3858dcd4f0..e860d6758f9e048f070b67855e7d7810456e7c48 100644 (file)
@@ -51,7 +51,7 @@ ThreadReturn THREAD_CALL Thread::Private::main_wrapper(void *arg)
        thread->platform_setname();
        thread->main();
        thread->_state = FINISHED;
-       return 0;
+       return nullptr;
 }
 
 } // namespace Msp
index ae9a0dda832b716445ad81b9493b8a7c24ca6778..ef071cd43ffb070f8c2ea2646a514ac2f514f9a6 100644 (file)
@@ -27,7 +27,7 @@ private:
                JOINED
        };
 
-       Private *_priv = 0;
+       Private *_priv = nullptr;
        std::string _name;
        State _state = PENDING;
 
index 434dba1b30c1f25d017897bf6925480aeaf166e0..58c9fda45e812e362d9f0d18d29568db387cf068 100644 (file)
@@ -2,5 +2,5 @@
 
 int main(int argc, char **argv)
 {
-       return Msp::Application::run(argc, argv, 0);
+       return Msp::Application::run(argc, argv, nullptr);
 }
index 15e5c9a213dbce4893851d3641aa036b340be2ad..a23add577bb364c854499c976888663b961c5031 100644 (file)
@@ -9,7 +9,7 @@ namespace Msp {
 Mutex::Mutex():
        priv(new Private)
 {
-       pthread_mutex_init(&priv->mutex, 0);
+       pthread_mutex_init(&priv->mutex, nullptr);
 }
 
 Mutex::~Mutex()
index 99be2e1d75a592a87a07e926439add7a4a5bec17..7370b70803f94bff6c24c57a3adb453f5ea6682a 100644 (file)
@@ -35,7 +35,7 @@ void Process::execute(const string &command, bool path_search, const Arguments &
                        argv[0] = command.c_str();
                        for(unsigned i=0; i<args.size(); ++i)
                                argv[i+1] = args[i].c_str();
-                       argv[args.size()+1] = 0;
+                       argv[args.size()+1] = nullptr;
 
                        if(redirect)
                        {
index 6a4bacf9defddb911244ba44ced8fd82121e6d97..f19bdab92d4da8c6ad636a8e7c796c6234f889fe 100644 (file)
@@ -22,7 +22,7 @@ struct Semaphore::Private
 Semaphore::Semaphore(unsigned limit):
        priv(new Private)
 {
-       pthread_cond_init(&priv->cond, 0);
+       pthread_cond_init(&priv->cond, nullptr);
        priv->limit = limit;
 }
 
index 1ddcaaea4bcf947a50fb411f0991a86b8b47def9..42231934c00ed6c58b9e0ec766bee7cecf7f3ebf 100644 (file)
@@ -7,7 +7,7 @@ namespace Msp {
 
 void Thread::platform_join()
 {
-       pthread_join(_priv->handle, 0);
+       pthread_join(_priv->handle, nullptr);
 }
 
 void Thread::platform_kill()
@@ -17,7 +17,7 @@ void Thread::platform_kill()
 
 void Thread::platform_launch()
 {
-       pthread_create(&_priv->handle, 0, &Private::main_wrapper, this);
+       pthread_create(&_priv->handle, nullptr, &Private::main_wrapper, this);
 }
 
 void Thread::platform_setname()
index 2e9caaf9b79440bacff303975a208321f6cdcd22..443befb481620b4242e178a4b377192179af1adc 100644 (file)
@@ -50,13 +50,13 @@ private:
                { return false; }
        };
 
-       StoreBase *store = 0;
+       StoreBase *store = nullptr;
 
 public:
        Variant() = default;
        template<typename T>
        Variant(const T &v): store(new Store<typename std::remove_cv<T>::type>(v)) { }
-       Variant(const Variant &v): store(v.store ? v.store->clone() : 0) { }
+       Variant(const Variant &v): store(v.store ? v.store->clone() : nullptr) { }
        ~Variant() { delete store; }
 
        template<typename T>
@@ -70,7 +70,7 @@ public:
        Variant &operator=(const Variant &v)
        {
                delete store;
-               store = (v.store ? v.store->clone() : 0);
+               store = (v.store ? v.store->clone() : nullptr);
                return *this;
        }
 
@@ -101,7 +101,7 @@ public:
        template<typename T>
        bool check_type() const
        {
-               return dynamic_cast<Store<typename std::remove_cv<T>::type> *>(store)!=0;
+               return dynamic_cast<Store<typename std::remove_cv<T>::type> *>(store);
        }
 
        bool check_same_type(const Variant &v) const
index 829365088115289bcdedc0ebc315911f3bf3175c..3bd03fa3816dbefc3faa71726fa1632c5537cdcd 100644 (file)
@@ -48,7 +48,7 @@ Process::~Process()
 void Process::platform_get_self_info(Private &priv)
 {
        priv.info.hProcess = GetCurrentProcess();
-       priv.info.hThread = 0;
+       priv.info.hThread = nullptr;
        priv.info.dwProcessId = GetCurrentProcessId();
        priv.info.dwThreadId = 0;
 }
@@ -61,12 +61,12 @@ void Process::execute(const string &command, bool path_search, const Arguments &
 
        STARTUPINFO startup;
        startup.cb = sizeof(STARTUPINFO);
-       startup.lpReserved = 0;
-       startup.lpDesktop = 0;
-       startup.lpTitle = 0;
+       startup.lpReserved = nullptr;
+       startup.lpDesktop = nullptr;
+       startup.lpTitle = nullptr;
        startup.dwFlags = 0;
        startup.cbReserved2 = 0;
-       startup.lpReserved2 = 0;
+       startup.lpReserved2 = nullptr;
        if(redirect)
        {
                startup.dwFlags |= STARTF_USESTDHANDLES;
@@ -78,9 +78,9 @@ void Process::execute(const string &command, bool path_search, const Arguments &
                HANDLE cerr_handle = (cerr ? *cerr->get_handle(IO::M_WRITE) : GetStdHandle(STD_ERROR_HANDLE));
                DuplicateHandle(self_handle, cerr_handle, self_handle, &startup.hStdError, 0, true, DUPLICATE_SAME_ACCESS);
        }
-       const char *cmdptr = (path_search ? 0 : command.c_str());
-       const char *wd = (work_dir.empty() ? 0 : work_dir.c_str());
-       if(!CreateProcess(cmdptr, const_cast<char *>(cmdline.c_str()), 0, 0, true, 0, 0, wd, &startup, &priv->info))
+       const char *cmdptr = (path_search ? nullptr : command.c_str());
+       const char *wd = (work_dir.empty() ? nullptr : work_dir.c_str());
+       if(!CreateProcess(cmdptr, const_cast<char *>(cmdline.c_str()), nullptr, nullptr, true, 0, nullptr, wd, &startup, &priv->info))
                throw system_error("CreateProcess");
 
        if(redirect)
@@ -135,8 +135,8 @@ void Process::interrupt()
 
 Process::Private::Private()
 {
-       info.hProcess = 0;
-       info.hThread = 0;
+       info.hProcess = nullptr;
+       info.hThread = nullptr;
        info.dwProcessId = 0;
        info.dwThreadId = 0;
 }
index 98eb9ed221a3817052de50ffc7babb5797378ba8..93aa7bd5e89fa63fd96c6b303a1ea6b5aa1ce51c 100644 (file)
@@ -11,7 +11,7 @@ string system_error::get_message(int c)
                c = GetLastError();
 
        char msg[1024];
-       if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, c, 0, msg, sizeof(msg), 0))
+       if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, c, 0, msg, sizeof(msg), nullptr))
                return msg;
        else
                return lexical_cast<string>(c, Fmt().hex());
index 24830943e6f096c7985171a1b26eeb4077c1f3a5..8890a70fb1cbd0eaff8cf32cdea008950c92e43b 100644 (file)
@@ -17,7 +17,7 @@ void Thread::platform_kill()
 void Thread::platform_launch()
 {
        DWORD dummy;  // Win9x needs the lpTthreadId parameter
-       _priv->handle = CreateThread(0, 0, &Private::main_wrapper, this, 0, &dummy);
+       _priv->handle = CreateThread(nullptr, 0, &Private::main_wrapper, this, 0, &dummy);
 }
 
 void Thread::platform_setname()
index 67cf62fc9c70a8c5a3cefd4f125b5a35cc39d2da..98aa4d8cdd9736291253cecf403b10d75bf43b2a 100644 (file)
@@ -13,7 +13,7 @@ class Backtrace
 public:
        struct StackFrame
        {
-               void *address = 0;
+               void *address = nullptr;
                std::string file;
                std::string symbol;
        };
index e41eb9ad79f32152b92503d33168c6dd1a43d337..3ed3171960ff8decc29384d1216937c8042f35f4 100644 (file)
@@ -13,7 +13,7 @@ string demangle(const string &sym)
 {
 #ifdef __GNUC__
        int status;
-       char *dm = abi::__cxa_demangle(sym.c_str(), 0, 0, &status);
+       char *dm = abi::__cxa_demangle(sym.c_str(), nullptr, nullptr, &status);
        
        string result;
        if(status==0)
index 8f080a307c1dbebb64605d73ee92d33685d5d608..edfa0026d58a6b92c08f43c5138a3ccc4aca610f 100644 (file)
@@ -3,7 +3,7 @@
 namespace Msp {
 namespace Debug {
 
-ErrorReporter *ErrorReporter::_current = 0;
+ErrorReporter *ErrorReporter::_current = nullptr;
 
 ErrorReporter::ErrorReporter():
        _prev(_current)
index dca8f522ebeddf0113a74efa754c91f7026d7cff..9a60f85c0f41b8bbdc4244734302e0c47fabe1c3 100644 (file)
@@ -10,7 +10,7 @@ namespace Debug {
 class ErrorReporter: private NonCopyable
 {
 private:
-       ErrorReporter *_prev = 0;
+       ErrorReporter *_prev = nullptr;
 
        static ErrorReporter *_current;
 
index 8ffc9c81b988667cffa12d770c1a6e97e5244ba6..7a681c35010cee85277112cc2d5b9a5d7ec5fefa 100644 (file)
@@ -20,7 +20,7 @@ struct HookThrow
 
 HookThrow::HookThrow()
 {
-       void *handle = dlopen(0, RTLD_LAZY);
+       void *handle = dlopen(nullptr, RTLD_LAZY);
        orig_cxa_throw = reinterpret_cast<CxaThrowType *>(dlvsym(handle, "__cxa_throw", "CXXABI_1.3"));
        dlclose(handle);
 }
index 5018c7f2d654100b7a0de87901d1c0708f114eeb..22d2c9a82c9fcb7df8545d16e7545d9ebb0720a3 100644 (file)
@@ -51,7 +51,7 @@ public:
 private:
        unsigned period = 0;
        std::map<std::string, ScopeInfo> scopes;
-       ProfilingScope *inner = 0;
+       ProfilingScope *inner = nullptr;
 
 public:
        /** Sets the averaging period for timing data, measured in calls.  Previous
index 69d1c49baa346388638014c5dcc66b5387eb27d0..586efa31d53fbf062a175ae7a44fb1e31897ac3f 100644 (file)
@@ -18,7 +18,7 @@ class ProfilingScope: private NonCopyable
 private:
        Profiler &profiler;
        std::string name;
-       ProfilingScope *parent = 0;
+       ProfilingScope *parent = nullptr;
        Time::TimeStamp entry_time;
        Time::TimeDelta time_spent;
        Time::TimeDelta child_time;
index a1b713b4c0cc1359ad0700efc523718bc745dc2b..5ab3f49197a0169c18b0df5a786be1064df8f94f 100644 (file)
@@ -19,7 +19,7 @@ FileMonitor::~FileMonitor()
 void FileMonitor::use_event_dispatcher(IO::EventDispatcher &ed)
 {
        if(event_disp)
-               throw logic_error("event_disp!=0");
+               throw logic_error("event_disp!=nullptr");
 
        event_disp = &ed;
        platform_use_event_dispatcher();
index 9e72ad2570b05dd9c7d11006ae05962e49edc087..411cb21ab5dfb58ee1bfee3e4a3c3ffe92de112e 100644 (file)
@@ -25,8 +25,8 @@ public:
        sigc::signal<void, const FS::Path &> signal_file_modified;
 
 private:
-       Private *priv = 0;
-       IO::EventDispatcher *event_disp = 0;
+       Private *priv = nullptr;
+       IO::EventDispatcher *event_disp = nullptr;
        std::vector<MonitoredFile> files;
 
 public:
index ae9f803a9d16f1030da32d1c9e63f14cf7b48356..773cdefbf8743ce08b6815d6a5115030944b46d1 100644 (file)
@@ -14,7 +14,7 @@ Stat::Stat(const Stat &other):
        alloc_size(other.alloc_size),
        mtime(other.mtime),
        owner_info(other.owner_info),
-       priv(other.priv ? new Private(*other.priv) : 0)
+       priv(other.priv ? new Private(*other.priv) : nullptr)
 { }
 
 Stat &Stat::operator=(const Stat &other)
@@ -26,7 +26,7 @@ Stat &Stat::operator=(const Stat &other)
        mtime = other.mtime;
        owner_info = other.owner_info;
        delete priv;
-       priv = (other.priv ? new Private(*other.priv) : 0);
+       priv = (other.priv ? new Private(*other.priv) : nullptr);
 
        return *this;
 }
index d23a8e82ef6376c520211c16e0828dd42ecd7b73..c32e8798162787b40b47a4ff41d9c7603689e806 100644 (file)
@@ -39,7 +39,7 @@ private:
        FileSize alloc_size = 0;
        Time::TimeStamp mtime;
        mutable OwnerInfo owner_info;
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Stat() = default;
index c6f6b9b6bd29893535ca64dd5b4423b5a39a8ad0..fde0200d029708eccd7476911e5d8dd3fa18c285 100644 (file)
@@ -28,7 +28,7 @@ vector<string> list_filtered(const Path &path, const string &filter)
        vector<string> result;
        WIN32_FIND_DATA entry;
        string pattern = path.str()+"\\*";
-       HANDLE search_handle = FindFirstFileEx(pattern.c_str(), FindExInfoBasic, &entry, FindExSearchNameMatch, 0, 0);
+       HANDLE search_handle = FindFirstFileEx(pattern.c_str(), FindExInfoBasic, &entry, FindExSearchNameMatch, nullptr, 0);
        if(search_handle==INVALID_HANDLE_VALUE)
        {
                DWORD err = GetLastError();
index 4c3b8668438d52d09c1b4816e745563b544dd75e..4f9b8f643b723b9317af370a84dbc8b7e6529b8e 100644 (file)
@@ -10,7 +10,7 @@ namespace FS {
 Path get_home_dir()
 {
        char home[MAX_PATH];
-       if(SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, home)==S_OK)
+       if(SHGetFolderPath(nullptr, CSIDL_PERSONAL, nullptr, 0, home)==S_OK)
                return home;
        return ".";
 }
@@ -22,7 +22,7 @@ Path get_user_data_dir()
                throw logic_error("no application name");
 
        char datadir[MAX_PATH];
-       if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
+       if(SHGetFolderPath(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, datadir)==S_OK)
                return Path(datadir)/appname;
        return ".";
 }
index 36f28a0de3413ba489fbfea524ed9cad9ee999b6..8331e6068c5e28606226e0a26e2d456591c9920c 100644 (file)
@@ -13,7 +13,7 @@ namespace {
 PSID copy_sid(PSID sid)
 {
        if(!sid || !IsValidSid(sid))
-               return 0;
+               return nullptr;
        DWORD len = GetLengthSid(sid);
        PSID copy = reinterpret_cast<PSID>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len));
        if(!CopySid(len, copy, sid))
@@ -32,7 +32,7 @@ string get_account_name(PSID sid)
        char domain[1024];
        DWORD dlen = sizeof(domain);
        SID_NAME_USE use;
-       if(!LookupAccountSid(0, sid, name, &nlen, domain, &dlen, &use))
+       if(!LookupAccountSid(nullptr, sid, name, &nlen, domain, &dlen, &use))
                throw Msp::system_error("LookupAccountSid");
        return Msp::format("%s/%s", name, domain);
 }
@@ -73,7 +73,7 @@ void Stat::Private::fill_owner_info(Stat::OwnerInfo &result)
 Stat Stat::stat(const Path &path)
 {
        HANDLE handle;
-       handle = CreateFile(path.str().c_str(), READ_CONTROL, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, 0);
+       handle = CreateFile(path.str().c_str(), READ_CONTROL, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, nullptr);
        if(handle==INVALID_HANDLE_VALUE)
        {
                DWORD err = GetLastError();
@@ -102,10 +102,10 @@ Stat Stat::stat(const Path &path)
        result.mtime = Time::TimeStamp(Time::filetime_to_rawtime(info.ftLastWriteTime));
 
        PSECURITY_DESCRIPTOR sec_desc;
-       PSID owner = 0;
-       PSID group = 0;
+       PSID owner = nullptr;
+       PSID group = nullptr;
        const SECURITY_INFORMATION sec_info = OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION;
-       DWORD err = GetSecurityInfo(handle, SE_FILE_OBJECT, sec_info, &owner, &group, 0, 0, &sec_desc);
+       DWORD err = GetSecurityInfo(handle, SE_FILE_OBJECT, sec_info, &owner, &group, nullptr, nullptr, &sec_desc);
        if(err)
        {
                CloseHandle(handle);
index c193accd186b6452410e16fbc0fe0cf75f1d50ff..6440aca8bae7d06bf298493077cebea2f5b7dc26 100644 (file)
@@ -9,8 +9,8 @@ namespace FS {
 typedef PSID UserID;
 typedef PSID GroupID;
 
-const UserID INVALID_UID = 0;
-const GroupID INVALID_GID = 0;
+const UserID INVALID_UID = nullptr;
+const GroupID INVALID_GID = nullptr;
 
 } // namespace FS
 } // namespace Msp
index 23a110e8c3b084a1d37242beda4ee032b2ac2285..d59db94d84fd99e07a474157038a793aa7132ffb 100644 (file)
@@ -16,7 +16,7 @@ class Asset: public Seekable
 private:
        struct Private;
 
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Asset(const std::string &);
index 1a1485efc67d752a6e893d6cdb6dd605f78b362f..aadc6acd48db7c49430e4823c74423a354168535 100644 (file)
@@ -44,7 +44,7 @@ public:
 protected:
        Mode mode = M_READ;
        bool eof_flag = false;
-       Mutex *mutex = 0;
+       Mutex *mutex = nullptr;
 
        Base();
 public:
index 39c8159ff18c7fa091b8f91c4ab898d0bd36b880..a5f6348591304712335d6654a183eed518ee9e62 100644 (file)
@@ -12,9 +12,9 @@ class Buffered: public Base, public sigc::trackable
 private:
        Base &below;
        std::size_t buf_size = 0;
-       char *buf = 0;
-       char *begin = 0;
-       char *end = 0;
+       char *buf = nullptr;
+       char *begin = nullptr;
+       char *end = nullptr;
        Mode cur_op = M_NONE;
 
 public:
index 51785b0b5d7010c771b95add2c68b4540e86ef3b..c4ae56b1de75567201a4215b4e47da61fa3a4368 100644 (file)
@@ -25,7 +25,7 @@ private:
        struct Private;
 
        Handle &handle;
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        EventReader(Handle &, unsigned);
index 561d710e457e77c73e7766f23d5bfd77f9b82310..6140e116d74fb497d83085d921e11b515084616a 100644 (file)
@@ -12,7 +12,7 @@ public:
        struct Private;
 
 private:
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        Handle();
index 048656793d47c33a56de5b1142bb5edbb3c2e4ba..c24d3f78e6ec3c123b7f99736fb858533f66de94 100644 (file)
@@ -9,9 +9,9 @@ namespace IO {
 class Memory: public Seekable
 {
 private:
-       char *begin = 0;
-       char *end = 0;
-       char *pos = 0;
+       char *begin = nullptr;
+       char *end = nullptr;
+       char *pos = nullptr;
 
 public:
        Memory(char *d, std::size_t s, Mode m = M_RDWR): Memory(d, d+s, m) { }
index ca0b0b7d88f46ccc6b82e8219e70d3bcbd74a97b..c8739239d960f4f801d1f1bd22846ddcd3a9989e 100644 (file)
@@ -36,7 +36,7 @@ class Poller: private NonCopyable
 public:
        struct PolledObject
        {
-               EventObject *object = 0;
+               EventObject *object = nullptr;
                PollEvent events = P_NONE;
 
                PolledObject(EventObject *o, PollEvent e): object(o), events(e) { }
@@ -46,7 +46,7 @@ private:
        struct Private;
 
        std::vector<PolledObject> objects;
-       Private *priv = 0;
+       Private *priv = nullptr;
        bool events_changed = false;
        bool objs_changed = false;
        std::vector<PolledObject> poll_result;
index 8c4102067854eb0c9096ff92ab4277c1e3cf6441..4a0640f5395f799fc1aacb992cc107ec20214e54 100644 (file)
@@ -14,9 +14,9 @@ struct EventReader::Private
        OVERLAPPED overlapped;
        Handle event;
        size_t buf_size = 0;
-       char *buffer = 0;
+       char *buffer = nullptr;
        size_t buf_avail = 0;
-       char *buf_next = 0;
+       char *buf_next = nullptr;
        bool pending = false;
        bool eof = false;
 };
@@ -27,7 +27,7 @@ EventReader::EventReader(Handle &h, unsigned size):
        priv(new Private)
 {
        memset(&priv->overlapped, 0, sizeof(OVERLAPPED));
-       *priv->event = CreateEvent(0, true, false, 0);
+       *priv->event = CreateEvent(nullptr, true, false, nullptr);
        priv->overlapped.hEvent = *priv->event;
        priv->buf_size = size;
        priv->buffer = new char[priv->buf_size];
index 3cbdc4a8ddaf5c6b4c91672479ebf4b1a1383c21..90c5bb5e6b50bdd840ee3482dd4ee8c585c04582 100644 (file)
@@ -35,10 +35,10 @@ void File::platform_init(const string &fn, CreateMode cm)
 
        SECURITY_ATTRIBUTES sec_attr;
        sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
-       sec_attr.lpSecurityDescriptor = 0;
+       sec_attr.lpSecurityDescriptor = nullptr;
        sec_attr.bInheritHandle = !!(mode&M_INHERIT);
 
-       *handle = CreateFile(fn.c_str(), flags, share_flags, 0, create_flags, FILE_ATTRIBUTE_NORMAL, &sec_attr);
+       *handle = CreateFile(fn.c_str(), flags, share_flags, nullptr, create_flags, FILE_ATTRIBUTE_NORMAL, &sec_attr);
        if(!handle)
        {
                int err = GetLastError();
index 1cdf8ce208ed881d0d5510bc0efb3a93122640ca..6d1219a24859e7757e9b1ba9e114ffbffa3793d7 100644 (file)
@@ -23,7 +23,7 @@ size_t sys_read(Handle &handle, char *buf, size_t size)
                throw invalid_argument("read");
 
        DWORD ret;
-       if(ReadFile(*handle, buf, size, &ret, 0)==0)
+       if(ReadFile(*handle, buf, size, &ret, nullptr)==0)
                throw system_error("ReadFile");
 
        return ret;
@@ -35,7 +35,7 @@ size_t sys_write(Handle &handle, const char *buf, size_t size)
                throw invalid_argument("write");
 
        DWORD ret;
-       if(WriteFile(*handle, buf, size, &ret, 0)==0)
+       if(WriteFile(*handle, buf, size, &ret, nullptr)==0)
                throw system_error("WriteFile");
 
        return ret;
index 02d7f339f6485186b87c5311ef9241f6d0623a5b..70d256ceacc55e906e2b7adbdf93f613ee2cc569 100644 (file)
@@ -11,11 +11,11 @@ namespace IO {
 void Pipe::platform_init()
 {
        string name = format("\\\\.\\pipe\\%u.%p", GetCurrentProcessId(), this);
-       *read_handle = CreateNamedPipe(name.c_str(), PIPE_ACCESS_INBOUND|FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 1024, 1024, 0, 0);
+       *read_handle = CreateNamedPipe(name.c_str(), PIPE_ACCESS_INBOUND|FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE, 1, 1024, 1024, 0, nullptr);
        if(!read_handle)
                throw system_error("CreateNamedPipe");
 
-       *write_handle = CreateFile(name.c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
+       *write_handle = CreateFile(name.c_str(), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);
        if(!write_handle)
        {
                unsigned err = GetLastError();
index 84a3175f875c4b0b774f1b5e1c1004db1d6bd351..bd086dd4d88e0985d6ab292f0bebeed92f5453f2 100644 (file)
@@ -13,7 +13,7 @@ void Serial::platform_init(const string &port)
 {
        string name = "\\\\.\\"+port;
 
-       *handle = CreateFile(name.c_str(), GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);
+       *handle = CreateFile(name.c_str(), GENERIC_READ|GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, nullptr);
        if(!handle)
                throw system_error(format("CreateFile(%s)", port));
        mode = M_READ|M_WRITE;
index 6c06cf3fd952870dc243817a6d3f786ac8434f92..fba71eb06d5e8b9ced1df0e2e1ce1e8ba743c889 100644 (file)
@@ -30,9 +30,9 @@ struct ZlibCompressed::Private
 ZlibCompressed::Private::Private()
 {
 #ifdef WITH_ZLIB
-       stream.zalloc = 0;
-       stream.zfree = 0;
-       stream.opaque = 0;
+       stream.zalloc = nullptr;
+       stream.zfree = nullptr;
+       stream.opaque = nullptr;
 #endif
 }
 
index da7313b4c42a62a3838045b0737eefbb919f7044..7a7973425bdcc573f48b65b838b062adf416b6d5 100644 (file)
@@ -35,10 +35,10 @@ private:
 
        Base &below;
        std::size_t buffer_size = 1024;
-       unsigned char *in_buffer = 0;
-       unsigned char *out_buffer = 0;
+       unsigned char *in_buffer = nullptr;
+       unsigned char *out_buffer = nullptr;
        bool stream_end = false;
-       Private *priv = 0;
+       Private *priv = nullptr;
 
 public:
        /** Creates a zlib de/compression object.  The underlying object must be
index dd850144f9d876fef967c10351440b9273437640..a304c5646308be67ec44a95ad880fd8028df7f7f 100644 (file)
@@ -36,7 +36,7 @@ public:
        {
        private:
                Mode mode = ASCII;
-               Codec::Decoder *dec = 0;
+               Codec::Decoder *dec = nullptr;
 
        public:
                Decoder(ErrorMode = DEFAULT);
index d35d12743ece9cb4ca89906f0fd97a3eff793a2c..04c3074494e921d39f3edb54e53e378c8623e826 100644 (file)
@@ -71,7 +71,7 @@ void Timer::do_tick(const TimeDelta &timeout)
        if(timeout>=zero)
                deadline = now()+timeout;
 
-       Slot *next = 0;
+       Slot *next = nullptr;
        {
                MutexLock l(mutex);
                while(1)
index 91acda9d49281373ade15beb162db9f7789c6f99..33257319eba3466d89f28c650efcd26dde0a996d 100644 (file)
@@ -41,7 +41,7 @@ public:
 private:
        struct SlotProxy
        {
-               Slot *slot = 0;
+               Slot *slot = nullptr;
 
                SlotProxy(Slot *);
                bool operator<(const SlotProxy &) const;
index 029c75bc3cb26e0bf5bc6929b81fb26d58cb5d93..f25f61c17c03f6ea09c06f4d495ab8c5d021fcaa 100644 (file)
@@ -13,7 +13,7 @@ namespace Time {
 TimeStamp now()
 {
        timeval tv;
-       gettimeofday(&tv, 0);
+       gettimeofday(&tv, nullptr);
        return TimeStamp(timeval_to_rawtime(tv));
 }
 
@@ -27,7 +27,7 @@ TimeDelta get_cpu_time()
 void sleep(const TimeDelta &d)
 {
        timespec ts = rawtime_to_timespec(d.raw());
-       while(nanosleep(&ts, 0)==-1)
+       while(nanosleep(&ts, nullptr)==-1)
                if(errno!=EINTR)
                        throw system_error("nanosleep");
 }