sal_Int32 SAL_CALL MemoryInputStream::readSomeBytes( Sequence<sal_Int8>& aData, sal_Int32 nMaxBytesToRead )
{ // all data is available at once return readBytes(aData, nMaxBytesToRead);
}
// ensure the sequence has enough space left if (m_nSize + _rData.getLength() > m_rSequence.getLength())
{
sal_Int32 nCurrentLength = m_rSequence.getLength();
sal_Int32 nNewLength = static_cast< sal_Int32 >(
nCurrentLength * m_nResizeFactor);
if (m_nMinimumResize > nNewLength - nCurrentLength) // we have a minimum so it's not too inefficient for small sequences and small write requests
nNewLength = nCurrentLength + m_nMinimumResize;
if (nNewLength < m_nSize + _rData.getLength())
{ // it's not enough... the data would not fit
// let's take the double amount of the length of the data to be written, as the next write // request could be as large as this one
sal_Int32 nNewGrowth = _rData.getLength() * 2;
nNewLength = nCurrentLength + nNewGrowth;
}
// round it off to the next multiple of 4...
nNewLength = (nNewLength + 3) / 4 * 4;
m_rSequence.realloc(nNewLength);
}
OSL_ENSURE(m_rSequence.getLength() >= m_nSize + _rData.getLength(), "ooops ... the realloc algorithm seems to be wrong :( !");
// cut the sequence to the real size
m_rSequence.realloc(m_nSize);
}
void OSequenceOutputStream::finalizeOutput()
{ // cut the sequence to the real size
m_rSequence.realloc(m_nSize); // and don't allow any further accesses
m_bConnected = false;
}
void SAL_CALL OSequenceOutputStream::closeOutput()
{
std::scoped_lock aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.