libcsdbg  1.28
C++ exception (and generic) stack trace debug library
template<class T>
node< T > * csdbg::chain< T >::node_with ( const T *  d) const
protectedvirtual

Get the node with m_data == d.

Parameters
[in]dthe data pointer searched
Returns
the node with m_data == d or NULL if there's no such node

Definition at line 137 of file chain.hpp.

References __D_ASSERT, likely, csdbg::node< T >::link(), csdbg::node< T >::m_data, and unlikely.

Referenced by csdbg::chain< T >::operator=().

138 {
139  __D_ASSERT(d != NULL);
140  if ( unlikely(d == NULL) )
141  return NULL;
142 
143  node<T> *cur = m_head, *prev = NULL, *next;
144  while ( likely(cur != NULL) ) {
145  if ( unlikely(cur->m_data == d) )
146  return cur;
147 
148  next = cur->link(prev);
149  prev = cur;
150  cur = next;
151  }
152 
153  return NULL;
154 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
node< T > * m_head
Chain head.
Definition: chain.hpp:39
#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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: