[Libreoffice-commits] core.git: include/svtools svtools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 3 07:11:27 UTC 2018


 include/svtools/svparser.hxx      |    2 +-
 svtools/source/svrtf/svparser.cxx |   14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 5d746e198b1a59742ac6c0da6b23b273f335f31c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 2 12:48:37 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 3 09:11:01 2018 +0200

    loplugin:useuniqueptr in SvParser
    
    Change-Id: I1850fc979394120be8aa0540140da13cda86bccb
    Reviewed-on: https://gerrit.libreoffice.org/58487
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svtools/svparser.hxx b/include/svtools/svparser.hxx
index bb046d8083f4..68c6ee772666 100644
--- a/include/svtools/svparser.hxx
+++ b/include/svtools/svparser.hxx
@@ -97,7 +97,7 @@ protected:
     void ClearTxtConvContext();
 
 private:
-    TokenStackType* pTokenStack;
+    std::unique_ptr<TokenStackType[]> pTokenStack;
     TokenStackType *pTokenStackPos;
     sal_uInt8 nTokenStackSize, nTokenStackPos;
 
diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 0208635b1860..32d64bc5b9dc 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -93,8 +93,8 @@ SvParser<T>::SvParser( SvStream& rIn, sal_uInt8 nStackSize )
     eState = SvParserState::NotStarted;
     if( nTokenStackSize < 3 )
         nTokenStackSize = 3;
-    pTokenStack = new TokenStackType[ nTokenStackSize ];
-    pTokenStackPos = pTokenStack;
+    pTokenStack.reset(new TokenStackType[ nTokenStackSize ]);
+    pTokenStackPos = pTokenStack.get();
 }
 
 template<typename T>
@@ -107,7 +107,7 @@ SvParser<T>::~SvParser()
         rtl_destroyTextToUnicodeConverter( pImplData->hConv );
     }
 
-    delete [] pTokenStack;
+    pTokenStack.reset();
 }
 
 template<typename T> SvParserState SvParser<T>::GetStatus() const { return eState; }
@@ -466,8 +466,8 @@ T SvParser<T>::GetNextToken()
     }
 
     ++pTokenStackPos;
-    if( pTokenStackPos == pTokenStack + nTokenStackSize )
-        pTokenStackPos = pTokenStack;
+    if( pTokenStackPos == pTokenStack.get() + nTokenStackSize )
+        pTokenStackPos = pTokenStack.get();
 
     // pop from stack ??
     if( nTokenStackPos )
@@ -518,7 +518,7 @@ T SvParser<T>::SkipToken( short nCnt )       // "skip" n Tokens backward
 template<typename T>
 typename SvParser<T>::TokenStackType* SvParser<T>::GetStackPtr( short nCnt )
 {
-    sal_uInt8 nCurrentPos = sal_uInt8(pTokenStackPos - pTokenStack );
+    sal_uInt8 nCurrentPos = sal_uInt8(pTokenStackPos - pTokenStack.get());
     if( nCnt > 0 )
     {
         if( nCnt >= nTokenStackSize )
@@ -539,7 +539,7 @@ typename SvParser<T>::TokenStackType* SvParser<T>::GetStackPtr( short nCnt )
             nCurrentPos = sal::static_int_cast< sal_uInt8 >(
                 nCurrentPos + (nCnt + nTokenStackSize));
     }
-    return pTokenStack + nCurrentPos;
+    return pTokenStack.get() + nCurrentPos;
 }
 
 // to read asynchronous from SvStream


More information about the Libreoffice-commits mailing list