// RollingBuffer_p.cpp (c) 2011 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 10 November 2011 (DB)
+// Last modified: 8 December 2011 (DB)
// ---------------------------------------------------------------------------
// Provides a dynamic I/O FIFO byte queue, which removes bytes as they are
// read from the front of the buffer and grows to accept bytes being written
size_t RollingBuffer::IndexOf(char c) const {
+ // skip processing if empty buffer
+ if ( IsEmpty() )
+ return string::npos;
+
size_t index(0);
// iterate over byte arrays
bytesReadSoFar += bytesToRead;
Free(bytesToRead);
- if ( !((bytesReadSoFar < index+1)&&(bytesReadSoFar < max-1)) )
+ if ( !((bytesReadSoFar < index+1) && (bytesReadSoFar < max-1)) )
finished = true;
}
if ( (m_tail + n) <= m_data.at(m_tailBufferIndex).Size() ) {
// fetch write pointer at current 'tail', increment tail by @n & return
- char* ptr = m_data[m_tailBufferIndex].Data() + m_tail;
+ char* ptr = m_data[m_tailBufferIndex].Data(); //+ m_tail;
m_tail += n;
return ptr;
}
m_data[m_tailBufferIndex].Resize(m_tail + n);
// fetch write pointer at current 'tail', increment tail by @n & return
- char* ptr = m_data[m_tailBufferIndex].Data() + m_tail;
+ char* ptr = m_data[m_tailBufferIndex].Data(); //+ m_tail;
m_tail += n;
return ptr;
}