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

Get the node at a stack offset.

Parameters
[in]ithe offset
Returns
the i-th node
Exceptions
csdbg::exception

Definition at line 94 of file stack.hpp.

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

95 {
96  if ( unlikely(i >= m_size) )
97  throw exception("offset out of stack bounds (%d >= %d)", i, m_size);
98 
99  node<T> *n = m_top;
100  while ( likely(i-- > 0) )
101  n = n->m_link;
102 
103  return n;
104 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
u32 m_size
Node count.
Definition: stack.hpp:36
node< T > * m_top
Stack top.
Definition: stack.hpp:34
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349