summaryrefslogtreecommitdiff
path: root/ucb/source/ucp
diff options
context:
space:
mode:
authorStephan Bergmann <sb@openoffice.org>2001-03-08 14:05:21 +0000
committerStephan Bergmann <sb@openoffice.org>2001-03-08 14:05:21 +0000
commit5d1e9d5bc77d6247f6c7fd62ce1ef236e8494705 (patch)
tree8e900c88c045265be1b48da29906e0054af88362 /ucb/source/ucp
parent4181cd0e2d17c7ce4be02a75496b8e2458389845 (diff)
#84734# Made XInputStream_impl::readBytes() more space efficient.
Diffstat (limited to 'ucb/source/ucp')
-rw-r--r--ucb/source/ucp/file/shell.cxx26
1 files changed, 11 insertions, 15 deletions
diff --git a/ucb/source/ucp/file/shell.cxx b/ucb/source/ucp/file/shell.cxx
index 8426096eb9ef..ca5c2300bd1e 100644
--- a/ucb/source/ucp/file/shell.cxx
+++ b/ucb/source/ucp/file/shell.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: shell.cxx,v $
*
- * $Revision: 1.25 $
+ * $Revision: 1.26 $
*
- * last change: $Author: armin $ $Date: 2001-03-08 12:06:52 $
+ * last change: $Author: sb $ $Date: 2001-03-08 15:05:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -818,22 +818,18 @@ XInputStream_impl::readBytes(
{
if( ! m_nIsOpen ) throw io::IOException();
- sal_Int8 * buffer;
- try
- {
- buffer = new sal_Int8[nBytesToRead];
- }
- catch( std::bad_alloc )
- {
- if( m_nIsOpen ) m_aFile.close();
- throw io::BufferSizeExceededException();
- }
+ aData.realloc(nBytesToRead);
+ //TODO! translate memory exhaustion (if it were detectable...) into
+ // io::BufferSizeExceededException
sal_uInt64 nrc;
- m_aFile.read( (void* )buffer,sal_uInt64(nBytesToRead),nrc );
+ m_aFile.read( aData.getArray(),sal_uInt64(nBytesToRead),nrc );
- aData = uno::Sequence< sal_Int8 > ( buffer,nrc );
- delete[] buffer;
+ // Shrink aData in case we read less than nBytesToRead (XInputStream
+ // documentation does not tell whether this is required, and I do not know
+ // if any code relies on this, so be conservative---SB):
+ if (nrc != nBytesToRead)
+ aData.realloc(sal_Int32(nrc));
return ( sal_Int32 ) nrc;
}