large array changes

This commit is contained in:
Jeff Hill
2001-05-22 02:02:10 +00:00
parent fa87c186fe
commit 70de17474b
56 changed files with 3459 additions and 2833 deletions

View File

@@ -59,27 +59,47 @@ unsigned comQueRecv::occupiedBytes () const
return nBytes;
}
bool comQueRecv::copyOutBytes ( void *pBuf, unsigned nBytes )
unsigned comQueRecv::copyOutBytes ( void *pBuf, unsigned nBytes )
{
char *pCharBuf = static_cast < char * > ( pBuf );
// dont return partial message
if ( nBytes > this->occupiedBytes () ) {
return false;
}
unsigned bytesLeft = nBytes;
while ( bytesLeft ) {
unsigned totalBytes = 0u;
do {
comBuf * pComBuf = this->bufs.first ();
assert ( pComBuf );
bytesLeft -= pComBuf->copyOutBytes ( &pCharBuf[nBytes-bytesLeft], bytesLeft );
if ( ! pComBuf ) {
return totalBytes;
}
totalBytes += pComBuf->copyOutBytes ( &pCharBuf[totalBytes], nBytes - totalBytes );
if ( pComBuf->occupiedBytes () == 0u ) {
this->bufs.remove ( *pComBuf );
pComBuf->destroy ();
}
}
while ( totalBytes < nBytes );
return totalBytes;
}
return true;
unsigned comQueRecv::removeBytes ( unsigned nBytes )
{
unsigned totalBytes = 0u;
unsigned bytesLeft = nBytes;
while ( bytesLeft ) {
comBuf * pComBuf = this->bufs.first ();
if ( ! pComBuf ) {
return totalBytes;
}
unsigned nBytes = pComBuf->removeBytes ( bytesLeft );
if ( pComBuf->occupiedBytes () == 0u ) {
this->bufs.remove ( *pComBuf );
pComBuf->destroy ();
}
if ( nBytes == 0u) {
return totalBytes;
}
totalBytes += nBytes;
bytesLeft = nBytes - totalBytes;
}
return nBytes;
}
void comQueRecv::pushLastComBufReceived ( comBuf & bufIn )
@@ -98,3 +118,19 @@ void comQueRecv::pushLastComBufReceived ( comBuf & bufIn )
}
}
epicsUInt8 comQueRecv::popUInt8 ()
{
comBuf *pComBuf = this->bufs.first ();
if ( pComBuf ) {
epicsUInt8 tmp = pComBuf->getByte ();
if ( pComBuf->occupiedBytes() == 0u ) {
this->bufs.remove ( *pComBuf );
pComBuf->destroy ();
}
return tmp;
}
throw insufficentBytesAvailable ();
}