summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2016-08-07 12:24:28 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-08-13 11:47:50 +0000
commitcb3a00514a6baa9fe7c0660a743b95e1baed7bb8 (patch)
tree9240dcb129cc7c82d41eb780f7ed1cc637c15931 /basic
parentf8b734a4e2b235c12e86d84c7691e39d05786032 (diff)
BASIC: Use more often std::unique_ptr
Change-Id: I37f3b35afcf3b4dba30a6ba841a59e0d851f1ebb Reviewed-on: https://gerrit.libreoffice.org/27930 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/inc/sbxbase.hxx4
-rw-r--r--basic/source/comp/symtbl.cxx9
-rw-r--r--basic/source/inc/runtime.hxx4
-rw-r--r--basic/source/inc/symtbl.hxx2
-rw-r--r--basic/source/runtime/methods.cxx14
-rw-r--r--basic/source/runtime/runtime.cxx5
-rw-r--r--basic/source/sbx/sbxbase.cxx2
-rw-r--r--basic/source/sbx/sbxscan.cxx8
8 files changed, 22 insertions, 26 deletions
diff --git a/basic/inc/sbxbase.hxx b/basic/inc/sbxbase.hxx
index 39d02272b34c..12ea1267d05c 100644
--- a/basic/inc/sbxbase.hxx
+++ b/basic/inc/sbxbase.hxx
@@ -37,7 +37,9 @@ struct SbxAppData
SbxError eSbxError; // Error code
std::vector<std::unique_ptr<SbxFactory>>
m_Factories;
- SbxBasicFormater *pBasicFormater; // Pointer to Format()-Command helper class
+
+ // Pointer to Format()-Command helper class
+ std::unique_ptr<SbxBasicFormater> pBasicFormater;
LanguageType eBasicFormaterLangType;
// It might be useful to store this class 'global' because some string resources are saved here
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 578d035042fd..be8ac764768f 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -26,6 +26,7 @@
#include <string.h>
#include <ctype.h>
#include <rtl/character.hxx>
+#include <o3tl/make_unique.hxx>
// All symbol names are laid down int the symbol-pool's stringpool, so that
// all symbols are handled in the same case. On saving the code-image, the
@@ -281,15 +282,13 @@ SbiSymDef::SbiSymDef( const OUString& rName ) : aName( rName )
bByVal =
bChained =
bGlobal = false;
- pIn =
- pPool = nullptr;
+ pIn = nullptr;
nDefaultId = 0;
nFixedStringLength = -1;
}
SbiSymDef::~SbiSymDef()
{
- delete pPool;
}
SbiProcDef* SbiSymDef::GetProcDef()
@@ -371,7 +370,7 @@ SbiSymPool& SbiSymDef::GetPool()
{
if( !pPool )
{
- pPool = new SbiSymPool( pIn->pParser->aGblStrings, SbLOCAL, pIn->pParser ); // is dumped
+ pPool = o3tl::make_unique<SbiSymPool>( pIn->pParser->aGblStrings, SbLOCAL, pIn->pParser );// is dumped
}
return *pPool;
}
@@ -397,7 +396,7 @@ SbiProcDef::SbiProcDef( SbiParser* pParser, const OUString& rName,
, mbProcDecl( bProcDecl )
{
aParams.SetParent( &pParser->aPublics );
- pPool = new SbiSymPool( pParser->aGblStrings, SbLOCAL, pParser );
+ pPool = o3tl::make_unique<SbiSymPool>( pParser->aGblStrings, SbLOCAL, pParser );
pPool->SetParent( &aParams );
nLine1 =
nLine2 = 0;
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 78b39a80bb01..8278f76cbd7f 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -107,12 +107,12 @@ class SbiRTLData
{
public:
- ::osl::Directory* pDir;
+ std::unique_ptr<osl::Directory> pDir;
SbAttributes nDirFlags;
short nCurDirPos;
OUString sFullNameToBeChecked;
- WildCard* pWildCard;
+ std::unique_ptr<WildCard> pWildCard;
css::uno::Sequence< OUString > aDirSeq;
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index e51a846a2d02..1fff808467cb 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -88,7 +88,7 @@ protected:
OUString aName;
SbxDataType eType;
SbiSymPool* pIn; // parent pool
- SbiSymPool* pPool; // pool for sub-elements
+ std::unique_ptr<SbiSymPool> pPool; // pool for sub-elements
short nLen; // string length for STRING*n
short nDims;
sal_uInt16 nId;
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 420298ab2940..562c79765f84 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -59,6 +59,7 @@
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
#include <memory>
#include <random>
+#include <o3tl/make_unique.hxx>
using namespace comphelper;
using namespace osl;
@@ -2720,8 +2721,7 @@ OUString implSetupWildcard( const OUString& rFileParam, SbiRTLData* pRTLData )
static sal_Char cWild1 = '*';
static sal_Char cWild2 = '?';
- delete pRTLData->pWildCard;
- pRTLData->pWildCard = nullptr;
+ pRTLData->pWildCard.reset();
pRTLData->sFullNameToBeChecked.clear();
OUString aFileParam = rFileParam;
@@ -2775,7 +2775,7 @@ OUString implSetupWildcard( const OUString& rFileParam, SbiRTLData* pRTLData )
// invalid anyway because it was not accepted by OSL before
if (aPureFileName != "*")
{
- pRTLData->pWildCard = new WildCard( aPureFileName );
+ pRTLData->pWildCard = o3tl::make_unique<WildCard>( aPureFileName );
}
return aPathStr;
}
@@ -3012,12 +3012,11 @@ RTLFUNC(Dir)
// Read directory
bool bIncludeFolders = bool(nFlags & SbAttributes::DIRECTORY);
- pRTLData->pDir = new Directory( aDirURL );
+ pRTLData->pDir = o3tl::make_unique<Directory>( aDirURL );
FileBase::RC nRet = pRTLData->pDir->open();
if( nRet != FileBase::E_None )
{
- delete pRTLData->pDir;
- pRTLData->pDir = nullptr;
+ pRTLData->pDir.reset();
rPar.Get(0)->PutString( OUString() );
return;
}
@@ -3063,8 +3062,7 @@ RTLFUNC(Dir)
FileBase::RC nRet = pRTLData->pDir->getNextItem( aItem );
if( nRet != FileBase::E_None )
{
- delete pRTLData->pDir;
- pRTLData->pDir = nullptr;
+ pRTLData->pDir.reset();
aPath.clear();
break;
}
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 88e38fd6d62a..fb8b79b337d1 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -264,17 +264,12 @@ SbiRuntime::pStep2 SbiRuntime::aStep2[] = {// all opcodes with two operands
SbiRTLData::SbiRTLData()
{
- pDir = nullptr;
nDirFlags = SbAttributes::NONE;
nCurDirPos = 0;
- pWildCard = nullptr;
}
SbiRTLData::~SbiRTLData()
{
- delete pDir;
- pDir = nullptr;
- delete pWildCard;
}
// SbiInstance
diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx
index 87696f8528bc..615708328180 100644
--- a/basic/source/sbx/sbxbase.cxx
+++ b/basic/source/sbx/sbxbase.cxx
@@ -43,7 +43,7 @@ SbxAppData::~SbxAppData()
{
SolarMutexGuard g;
- delete pBasicFormater;
+ pBasicFormater.reset();
m_Factories.clear();
}
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index de98ad1b08ec..1dd949e8525b 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -49,6 +49,8 @@
#include <svl/zforlist.hxx>
#include <comphelper/processfactory.hxx>
+#include <o3tl/make_unique.hxx>
+
void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep )
{
@@ -812,8 +814,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
{
if( rAppData.eBasicFormaterLangType != eLangType )
{
- delete rAppData.pBasicFormater;
- rAppData.pBasicFormater = nullptr;
+ rAppData.pBasicFormater.reset();
}
}
rAppData.eBasicFormaterLangType = eLangType;
@@ -838,7 +839,8 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
OUString aFalseStrg = SbxValueFormatResId(STR_BASICKEY_FORMAT_FALSE).toString();
OUString aCurrencyFormatStrg = SbxValueFormatResId(STR_BASICKEY_FORMAT_CURRENCY).toString();
- rAppData.pBasicFormater = new SbxBasicFormater( cComma,c1000,aOnStrg,aOffStrg,
+ rAppData.pBasicFormater = o3tl::make_unique<SbxBasicFormater>(
+ cComma,c1000,aOnStrg,aOffStrg,
aYesStrg,aNoStrg,aTrueStrg,aFalseStrg,
aCurrencyStrg,aCurrencyFormatStrg );
}