diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-09-29 16:31:24 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-23 11:53:19 +0200 |
commit | d45607c4be485952158c58b1ebb83f7632f1a057 (patch) | |
tree | 8a04c9167452f7a12520b5534b0f58390ff660b0 /comphelper | |
parent | ea052e766a67c2ae74d0960782c4d5fb335c25e6 (diff) |
Revert recent changes to comphelper::OSequenceOutputStream
Some of the changes could be wrong and we don't need them.
This reverts commit 784d4bea86d8cbb3a855e557c465ce50a049cefc.
This reverts commit 8524d5aba59148eef94859289f00ab6477e0e821.
This reverts commit 018f1deae884febbbe639c7ee46b45ce4807e9d3.
This reverts commit 8124fddc5803b4e104d4fc2456cb92cb030d9436.
We use our own helper cache class in FastSaxSerializer
since f736eba5a9df8645849a37b08d2764a5f495ab45.
Change-Id: Iaca6b5b11cb32595db4420a02fa72b0007cf6286
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/streaming/seqstream.cxx | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/comphelper/source/streaming/seqstream.cxx b/comphelper/source/streaming/seqstream.cxx index 91fdc7d73378..5bc44a52e877 100644 --- a/comphelper/source/streaming/seqstream.cxx +++ b/comphelper/source/streaming/seqstream.cxx @@ -156,19 +156,15 @@ OSequenceOutputStream::OSequenceOutputStream(Sequence< sal_Int8 >& _rSeq, double // this heuristic is as good as any other ... supply better parameters if you don't like it :) } -void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rData ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception) -{ - writeBytes(_rData.getConstArray(), _rData.getLength()); -} -void SAL_CALL OSequenceOutputStream::writeBytes( const sal_Int8* pStr, sal_Int32 nLen ) - throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception) +void SAL_CALL OSequenceOutputStream::writeBytes( const Sequence< sal_Int8 >& _rData ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception) { + MutexGuard aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException(); // ensure the sequence has enough space left - if (m_nSize + nLen > m_rSequence.getLength()) + if (m_nSize + _rData.getLength() > m_rSequence.getLength()) { sal_Int32 nCurrentLength = m_rSequence.getLength(); sal_Int32 nNewLength = static_cast< sal_Int32 >( @@ -182,18 +178,18 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const sal_Int8* pStr, sal_Int32 // such a large step is not allowed nNewLength = nCurrentLength + m_nMaximumResize; - if (nNewLength < m_nSize + nLen) + 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 = nLen * 2; + sal_Int32 nNewGrowth = _rData.getLength() * 2; if ((m_nMaximumResize > 0) && (nNewGrowth > m_nMaximumResize)) { // we came to the limit, again ... nNewGrowth = m_nMaximumResize; - if (nNewGrowth + nCurrentLength < m_nSize + nLen) + if (nNewGrowth + nCurrentLength < m_nSize + _rData.getLength()) // but it would not fit if we respect the limit - nNewGrowth = m_nSize + nLen - nCurrentLength; + nNewGrowth = m_nSize + _rData.getLength() - nCurrentLength; } nNewLength = nCurrentLength + nNewGrowth; } @@ -204,29 +200,33 @@ void SAL_CALL OSequenceOutputStream::writeBytes( const sal_Int8* pStr, sal_Int32 m_rSequence.realloc(nNewLength); } - OSL_ENSURE(m_rSequence.getLength() >= m_nSize + nLen, + OSL_ENSURE(m_rSequence.getLength() >= m_nSize + _rData.getLength(), "ooops ... the realloc algorithm seems to be wrong :( !"); - memcpy(m_rSequence.getArray() + m_nSize, pStr, nLen); - m_nSize += nLen; + memcpy(m_rSequence.getArray() + m_nSize, _rData.getConstArray(), _rData.getLength()); + m_nSize += _rData.getLength(); } void SAL_CALL OSequenceOutputStream::flush( ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception) { + MutexGuard aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException(); // cut the sequence to the real size m_rSequence.realloc(m_nSize); - // and next time write to the beginning - m_nSize = 0; } void SAL_CALL OSequenceOutputStream::closeOutput( ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException, std::exception) { - flush(); + MutexGuard aGuard(m_aMutex); + if (!m_bConnected) + throw NotConnectedException(); + + // cut the sequence to the real size + m_rSequence.realloc(m_nSize); // and don't allow any further accesses m_bConnected = false; } |