libcsdbg  1.28
C++ exception (and generic) stack trace debug library
exception & csdbg::exception::operator= ( const exception rval)
virtual

Assignment operator.

Parameters
[in]rvalthe assigned object
Returns
*this

Definition at line 136 of file exception.cpp.

References __D_ASSERT, likely, m_msg, and unlikely.

137 {
138  if ( unlikely(this == &rval) )
139  return *this;
140 
141  i8 *buf = rval.m_msg;
142  if ( unlikely(buf == NULL) ) {
143  delete[] m_msg;
144  m_msg = NULL;
145  return *this;
146  }
147 
148  u32 len = strlen(buf);
149  if ( likely(m_msg == NULL || len > strlen(m_msg)) ) {
150  delete[] m_msg;
151  m_msg = NULL;
152  m_msg = new (std::nothrow) i8[len + 1];
153  }
154 
155  __D_ASSERT(m_msg != NULL);
156  if ( likely(m_msg != NULL) )
157  strcpy(m_msg, buf);
158 
159  return *this;
160 }
char i8
8-bit signed integer
Definition: config.hpp:72
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
i8 * m_msg
Error description message.
Definition: exception.hpp:32
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268