botsense/bsProxy/bsProxyMod.c
int ModCbRsrcAdd(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn, void *pRsrc)
{
  int  index;

  // bad handle
  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
  {
    return -BS_ECODE_BAD_VCONN_HND;
  }

  // no more resources available  
  else if( pRsrcTbl->m_uInUseCount >= pRsrcTbl->m_uMaxResources )
  {
    return -BS_ECODE_NO_RSRC;
  }

  // find empty slot in resource table
  for(index=0; index<pRsrcTbl->m_uMaxResources; ++index)
  {
    if( pRsrcTbl->m_vecRsrc[index] == NULL )
    {
      break;
    }
  }

  // internal error - log these
  if( (uint_t)index >= pRsrcTbl->m_uMaxResources )
  {
    LOGERROR("Internal module data corruption.");
    return -BS_ECODE_INTERNAL;
  }

  // add resource to resource table
  pRsrcTbl->m_vecRsrc[index]     = pRsrc;
  pRsrcTbl->m_vecIndex[hndVConn] = (byte_t)index;
  pRsrcTbl->m_uInUseCount++;

  return index;
}
/*!
 * \brief Add a new resource to the resource table.
 *
 * \param pRsrcTbl  Pointer to resource table.
 * \param hndVConn  Virtual connection handle.
 * \param pRsrc     Pointer to allocated resource associated with handle.
 *
 * \copydoc doc_return_std
 */
\brief Add a new resource to the resource table.
\param pRsrcTbl  Pointer to resource table.
\param hndVConn  Virtual connection handle.
\param pRsrc     Pointer to allocated resource associated with handle.


\ brief Add a new resource to the resource table . \ param pRsrcTbl Pointer to resource table . \ param hndVConn Virtual connection handle . \ param pRsrc Pointer to allocated resource associated with handle .
int ModCbRsrcAdd(BsModRsrcTbl_T *pRsrcTbl, BsVConnHnd_T hndVConn, void *pRsrc)
{
  int  index;
  if( !BSMOD_IS_VCONN_HANDLE(hndVConn) )
  {
    return -BS_ECODE_BAD_VCONN_HND;
  }
  else if( pRsrcTbl->m_uInUseCount >= pRsrcTbl->m_uMaxResources )
  {
    return -BS_ECODE_NO_RSRC;
  }
  for(index=0; index<pRsrcTbl->m_uMaxResources; ++index)
  {
    if( pRsrcTbl->m_vecRsrc[index] == NULL )
    {
      break;
    }
  }
  if( (uint_t)index >= pRsrcTbl->m_uMaxResources )
  {
    LOGERROR("Internal module data corruption.");
    return -BS_ECODE_INTERNAL;
  }
  pRsrcTbl->m_vecRsrc[index]     = pRsrc;
  pRsrcTbl->m_vecIndex[hndVConn] = (byte_t)index;
  pRsrcTbl->m_uInUseCount++;
  return index;
}
int ModCbRsrcAdd ( BsModRsrcTbl_T * pRsrcTbl , BsVConnHnd_T hndVConn , void * pRsrc ) { int index ; if ( ! BSMOD_IS_VCONN_HANDLE ( hndVConn ) ) { return - BS_ECODE_BAD_VCONN_HND ; } else if ( pRsrcTbl -> m_uInUseCount >= pRsrcTbl -> m_uMaxResources ) { return - BS_ECODE_NO_RSRC ; } for ( index = 0 ; index < pRsrcTbl -> m_uMaxResources ; ++ index ) { if ( pRsrcTbl -> m_vecRsrc [ index ] == NULL ) { break ; } } if ( ( uint_t ) index >= pRsrcTbl -> m_uMaxResources ) { LOGERROR ( " " ) ; return - BS_ECODE_INTERNAL ; } pRsrcTbl -> m_vecRsrc [ index ] = pRsrc ; pRsrcTbl -> m_vecIndex [ hndVConn ] = ( byte_t ) index ; pRsrcTbl -> m_uInUseCount ++ ; return index ; }
\brief Add a new resource to the resource table.
\ brief Add a new resource to the resource table .
// bad handle // no more resources available   // find empty slot in resource table // internal error - log these // add resource to resource table