Use nullptr instead of NULL in the code and documentation

This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
This commit is contained in:
Vadim Zeitlin 2022-10-16 01:24:34 +02:00
parent 39ea524943
commit 4f4c5fcfdf
1844 changed files with 13721 additions and 13734 deletions

View file

@ -133,7 +133,7 @@ public:
CharType *release() const
{
if ( m_data == GetNullData() )
return NULL;
return nullptr;
wxASSERT_MSG( m_data->m_owned, wxT("can't release non-owned buffer") );
wxASSERT_MSG( m_data->m_ref == 1, wxT("can't release shared buffer") );
@ -141,7 +141,7 @@ public:
CharType * const p = m_data->Get();
wxScopedCharTypeBuffer *self = const_cast<wxScopedCharTypeBuffer*>(this);
self->m_data->Set(NULL, 0);
self->m_data->Set(nullptr, 0);
self->DecRef();
return p;
@ -176,7 +176,7 @@ protected:
}
};
// placeholder for NULL string, to simplify this code
// placeholder for null string, to simplify this code
static Data *GetNullData()
{
return static_cast<Data *>(wxPrivate::GetUntypedNullData());
@ -252,7 +252,7 @@ protected:
public:
typedef T CharType;
wxCharTypeBuffer(const CharType *str = NULL, size_t len = wxNO_LEN)
wxCharTypeBuffer(const CharType *str = nullptr, size_t len = wxNO_LEN)
{
if ( str )
{
@ -365,7 +365,7 @@ public:
wxCharBuffer(const wxScopedCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxCharBuffer(const CharType *str = nullptr) : wxCharTypeBufferBase(str) {}
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
wxCharBuffer(const wxCStrData& cstr);
@ -382,7 +382,7 @@ public:
wxWCharBuffer(const wxScopedCharTypeBufferBase& buf)
: wxCharTypeBufferBase(buf) {}
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxWCharBuffer(const CharType *str = nullptr) : wxCharTypeBufferBase(str) {}
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
wxWCharBuffer(const wxCStrData& cstr);
@ -401,7 +401,7 @@ public:
// always return a buffer
// + we should derive this class from wxScopedCharTypeBuffer
// then
wxWritableCharTypeBuffer(const CharType *str = NULL)
wxWritableCharTypeBuffer(const CharType *str = nullptr)
: wxCharTypeBuffer<T>(str) {}
operator CharType*() { return this->data(); }
@ -448,7 +448,7 @@ public:
// everything is private as it can only be used by wxMemoryBuffer
private:
wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize)
: m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0)
: m_data(size ? malloc(size) : nullptr), m_size(size), m_len(0), m_ref(0)
{
}
~wxMemoryBufferData() { free(m_data); }
@ -483,13 +483,13 @@ private:
void *release()
{
if ( m_data == NULL )
return NULL;
if ( m_data == nullptr )
return nullptr;
wxASSERT_MSG( m_ref == 1, "can't release shared buffer" );
void *p = m_data;
m_data = NULL;
m_data = nullptr;
m_len =
m_size = 0;