libcsdbg  1.28
C++ exception (and generic) stack trace debug library
template<class T>
stack< T > & csdbg::stack< T >::push ( T *  d)
virtual

Push a node on the stack.

Parameters
[in]dthe new node data pointer
Returns
*this
Exceptions
std::bad_alloc
csdbg::exception

Definition at line 266 of file stack.hpp.

References csdbg::node< T >::m_link, and unlikely.

267 {
268  if ( unlikely(d == NULL) )
269  throw exception("invalid argument: d (=%p)", d);
270 
271  /* If the data pointer already exists in the stack */
272  if ( unlikely(node_with(d) != NULL) )
273  throw exception("stack @ %p has a node with data @ %p", this, d);
274 
275  node<T> *n = new node<T>(d);
276  n->m_link = m_top;
277  m_top = n;
278  m_size++;
279 
280  return *this;
281 }
u32 m_size
Node count.
Definition: stack.hpp:36
node< T > * m_top
Stack top.
Definition: stack.hpp:34
virtual node< T > * node_with(const T *) const
Get the node with m_data == d.
Definition: stack.hpp:115
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349