Skip to content

Commit

Permalink
Use nullptr instead 0 for ace/SString.*
Browse files Browse the repository at this point in the history
  • Loading branch information
likema committed Jul 27, 2024
1 parent 3e9c616 commit 725e4de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions ACE/ace/SString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_OSTREAM_TYPE &
operator<< (ACE_OSTREAM_TYPE &os, const ACE_CString &cs)
{
if (cs.fast_rep () != 0)
if (cs.fast_rep ())
os << cs.fast_rep ();
return os;
}
Expand Down Expand Up @@ -59,7 +59,7 @@ ACE_NS_WString::char_rep () const
return 0;
else
{
char *t = 0;
char *t = nullptr;

#if defined (ACE_HAS_ALLOC_HOOKS)
ACE_ALLOCATOR_RETURN (t,
Expand Down Expand Up @@ -89,7 +89,7 @@ ACE_NS_WString::ushort_rep () const
return 0;
else
{
ACE_UINT16 *t = 0;
ACE_UINT16 *t = nullptr;

#if defined (ACE_HAS_ALLOC_HOOKS)
ACE_ALLOCATOR_RETURN (t,
Expand Down
4 changes: 2 additions & 2 deletions ACE/ace/SString.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ typedef ACE_CString ACE_TString;
class ACE_Export ACE_Auto_String_Free
{
public:
explicit ACE_Auto_String_Free (char* p = 0);
explicit ACE_Auto_String_Free (char* p = nullptr);
ACE_Auto_String_Free (ACE_Auto_String_Free &rhs);
ACE_Auto_String_Free& operator= (ACE_Auto_String_Free &rhs);
~ACE_Auto_String_Free ();
Expand All @@ -285,7 +285,7 @@ class ACE_Export ACE_Auto_String_Free
explicit operator bool () const;
char* get () const;
char* release ();
void reset (char* p = 0);
void reset (char* p = nullptr);

private:
char* p_;
Expand Down
8 changes: 4 additions & 4 deletions ACE/ace/SString.inl
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ACE_INLINE
ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs)
: p_ (rhs.p_)
{
rhs.p_ = 0;
rhs.p_ = nullptr;
}

ACE_INLINE void
Expand All @@ -251,7 +251,7 @@ ACE_Auto_String_Free::operator= (ACE_Auto_String_Free& rhs)
if (this != &rhs)
{
this->reset (rhs.p_);
rhs.p_ = 0;
rhs.p_ = nullptr;
}
return *this;
}
Expand All @@ -277,7 +277,7 @@ ACE_Auto_String_Free::operator[] (size_t i) const
ACE_INLINE
ACE_Auto_String_Free::operator bool (void) const
{
return this->p_ != 0;
return this->p_ != nullptr;
}

ACE_INLINE char*
Expand All @@ -290,7 +290,7 @@ ACE_INLINE char*
ACE_Auto_String_Free::release ()
{
char* p = this->p_;
this->p_ = 0;
this->p_ = nullptr;
return p;
}

Expand Down
13 changes: 13 additions & 0 deletions ACE/tests/SString_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ int testConstIterator()
return 0;
}

int testAutoStringFree()
{
char* s = ACE_OS::strdup("Hello, World");
const ACE_Auto_String_Free s1(s);
if (!s1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("ACE_Auto_String_Free is nullptr")),
1);

return 0;
}


int
run_main (int, ACE_TCHAR *[])
Expand Down Expand Up @@ -425,6 +437,7 @@ run_main (int, ACE_TCHAR *[])
int err = testConcatenation ();
err += testIterator ();
err += testConstIterator ();
err += testAutoStringFree ();

ACE_END_TEST;
return err;
Expand Down

0 comments on commit 725e4de

Please sign in to comment.