/* Find and return the next buffer that is not in use by anything else.  */
static unsigned char * prvGetFreeBuffer(void)
/* Find and return the next buffer that is not in use by anything else.  */
static unsigned char * prvGetFreeBuffer(void)
{
portBASE_TYPE x;
unsigned char *pucReturn = NULL;
unsigned long ulAttempts = 0;
	while( pucReturn == NULL )
	{
		for( x = 0; x < fecNUM_BUFFERS; x++ )
		{
			if( ucBufferInUse[ x ] == pdFALSE )
			{
				ucBufferInUse[ x ] = pdTRUE;
				pucReturn = pucAlignedBufferStartAddresses[ x ];
				break;
			}
		}
		if( pucReturn == NULL )
		{
			ulAttempts++;
			if( ulAttempts >= uipBUFFER_WAIT_ATTEMPTS )
			{
				break;
			}
			vTaskDelay( fecMINIMAL_DELAY );
		}
	}
	return pucReturn;
}