summaryrefslogtreecommitdiff
path: root/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-19 09:11:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-19 11:28:41 +0000
commit968f6a7f0293c08a73807603f3cb294e4b50bad8 (patch)
treeace3fb5c260c8bbdc3f97c48499b5466f660a68c /xmlhelp/source/cxxhelp/provider/urlparameter.cxx
parentd3ff66999d924e832f8219c65ced0526f1a67f82 (diff)
new loplugin: useuniqueptr: unotools..xmlscript
Change-Id: I6966d44cff644112dd837adfe7d9c4f459457271 Reviewed-on: https://gerrit.libreoffice.org/33298 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp/source/cxxhelp/provider/urlparameter.cxx')
-rw-r--r--xmlhelp/source/cxxhelp/provider/urlparameter.cxx31
1 files changed, 12 insertions, 19 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 8d9cd65c06b0..4a6f13d2c6f4 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -47,6 +47,8 @@
#include "urlparameter.hxx"
#include "databases.hxx"
+#include <memory>
+
using namespace cppu;
using namespace com::sun::star::io;
using namespace com::sun::star::uno;
@@ -303,8 +305,6 @@ public:
Databases* pDatatabases,
bool isRoot );
- virtual ~InputStreamTransformer() override;
-
virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException, std::exception ) override;
virtual void SAL_CALL acquire() throw() override;
virtual void SAL_CALL release() throw() override;
@@ -344,7 +344,7 @@ public:
void addToBuffer( const char* buffer,int len );
- sal_Int8 const * getData() const { return reinterpret_cast<sal_Int8 const *>(buffer); }
+ sal_Int8 const * getData() const { return reinterpret_cast<sal_Int8 const *>(buffer.get()); }
sal_Int32 getLen() const { return sal_Int32( len ); }
@@ -353,7 +353,7 @@ private:
osl::Mutex m_aMutex;
int len,pos;
- char *buffer;
+ std::unique_ptr<char[]> buffer;
};
@@ -739,18 +739,18 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
{
if( isRoot )
{
- delete[] buffer;
+ buffer.reset();
pDatabases->cascadingStylesheet( urlParam->get_language(),
- &buffer,
+ buffer,
&len );
}
else if( urlParam->isActive() )
{
- delete[] buffer;
+ buffer.reset();
pDatabases->setActiveText( urlParam->get_module(),
urlParam->get_language(),
urlParam->get_id(),
- &buffer,
+ buffer,
&len );
}
else
@@ -909,12 +909,6 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
}
-InputStreamTransformer::~InputStreamTransformer()
-{
- delete[] buffer;
-}
-
-
Any SAL_CALL InputStreamTransformer::queryInterface( const Type& rType ) throw( RuntimeException, std::exception )
{
Any aRet = ::cppu::queryInterface( rType,
@@ -1032,11 +1026,10 @@ void InputStreamTransformer::addToBuffer( const char* buffer_,int len_ )
{
osl::MutexGuard aGuard( m_aMutex );
- char* tmp = buffer;
- buffer = new char[ len+len_ ];
- memcpy( static_cast<void*>(buffer),static_cast<void*>(tmp),sal_uInt32( len ) );
- memcpy( static_cast<void*>(buffer+len),static_cast<void const *>(buffer_),sal_uInt32( len_ ) );
- delete[] tmp;
+ std::unique_ptr<char[]> tmp(buffer.release());
+ buffer.reset( new char[ len+len_ ] );
+ memcpy( static_cast<void*>(buffer.get()),static_cast<void*>(tmp.get()),sal_uInt32( len ) );
+ memcpy( static_cast<void*>(buffer.get()+len),static_cast<void const *>(buffer_),sal_uInt32( len_ ) );
len += len_;
}