librnr/dlistvoid.c
void *DListVoidGetNodeAt(DListVoid_T *pHead, int iIndex)
{
  int       nCnt;
  dnode_t  *p, *q, *head;

  LOGDIAG4CALL(_TPTR(pHead), _TINT(iIndex));

  CHKPTR(pHead, NULL);

  nCnt = pHead->m_nNumNodes;

  if( iIndex == DLIST_INSERT_AT_END )
  {
    iIndex = nCnt - 1;
  }

  if( (iIndex < 0) || (iIndex >= nCnt) )
  {
    LOGERROR("%d index is out of range", iIndex);
  }

  head = &(pHead->m_dnodeHead);

  dlist_for_each_safe(p, q, head)
  {
    if( iIndex-- == 0 )
    {
      return DLISTVOID_ENTRY(p);
    }
  }

  return NULL;
}
/*!
 * \brief Get the node at the given dlist index.
 *
 * \param pHead   Pointer to dlist (head).
 * \param iIndex  Index to dlist entry to find.
 *
 * \return Returns node at index on success, NULL on failure.
 */
\brief Get the node at the given dlist index.
\param pHead   Pointer to dlist (head).
\param iIndex  Index to dlist entry to find.

\return Returns node at index on success, NULL on failure.
\ brief Get the node at the given dlist index . \ param pHead Pointer to dlist ( head ) . \ param iIndex Index to dlist entry to find . \ return Returns node at index on success NULL on failure .
void *DListVoidGetNodeAt(DListVoid_T *pHead, int iIndex)
{
  int       nCnt;
  dnode_t  *p, *q, *head;
  LOGDIAG4CALL(_TPTR(pHead), _TINT(iIndex));
  CHKPTR(pHead, NULL);
  nCnt = pHead->m_nNumNodes;
  if( iIndex == DLIST_INSERT_AT_END )
  {
    iIndex = nCnt - 1;
  }
  if( (iIndex < 0) || (iIndex >= nCnt) )
  {
    LOGERROR("%d index is out of range", iIndex);
  }
  head = &(pHead->m_dnodeHead);
  dlist_for_each_safe(p, q, head)
  {
    if( iIndex-- == 0 )
    {
      return DLISTVOID_ENTRY(p);
    }
  }
  return NULL;
}
void * DListVoidGetNodeAt ( DListVoid_T * pHead , int iIndex ) { int nCnt ; dnode_t * p , * q , * head ; LOGDIAG4CALL ( _TPTR ( pHead ) , _TINT ( iIndex ) ) ; CHKPTR ( pHead , NULL ) ; nCnt = pHead -> m_nNumNodes ; if ( iIndex == DLIST_INSERT_AT_END ) { iIndex = nCnt - 1 ; } if ( ( iIndex < 0 ) || ( iIndex >= nCnt ) ) { LOGERROR ( " " , iIndex ) ; } head = & ( pHead -> m_dnodeHead ) ; dlist_for_each_safe ( p , q , head ) { if ( iIndex -- == 0 ) { return DLISTVOID_ENTRY ( p ) ; } } return NULL ; }
\brief Get the node at the given dlist index.
\ brief Get the node at the given dlist index .