basic/inc/sbxbase.hxx            |    4 +++-
 basic/source/comp/symtbl.cxx     |    9 ++++-----
 basic/source/inc/runtime.hxx     |    4 ++--
 basic/source/inc/symtbl.hxx      |    2 +-
 basic/source/runtime/methods.cxx |   14 ++++++--------
 basic/source/runtime/runtime.cxx |    5 -----
 basic/source/sbx/sbxbase.cxx     |    2 +-
 basic/source/sbx/sbxscan.cxx     |    8 +++++---
 8 files changed, 22 insertions(+), 26 deletions(-)

New commits:
commit cb3a00514a6baa9fe7c0660a743b95e1baed7bb8
Author: Arnaud Versini <arnaud.vers...@gmail.com>
Date:   Sun Aug 7 12:24:28 2016 +0200

    BASIC: Use more often std::unique_ptr
    
    Change-Id: I37f3b35afcf3b4dba30a6ba841a59e0d851f1ebb
    Reviewed-on: https://gerrit.libreoffice.org/27930
    Reviewed-by: Noel Grandin <noelgran...@gmail.com>
    Tested-by: Noel Grandin <noelgran...@gmail.com>

diff --git a/basic/inc/sbxbase.hxx b/basic/inc/sbxbase.hxx
index 39d0227..12ea126 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 578d035..be8ac76 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 78b39a8..8278f76 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 e51a846..1fff808 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 420298a..562c797 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 88e38fd..fb8b79b 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 87696f85..6157083 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 de98ad1..1dd949e 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 );
             }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to