[Libreoffice-commits] core.git: 2 commits - include/tools include/unotools tools/source unotools/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Apr 10 06:52:46 UTC 2017


 include/tools/inetstrm.hxx                   |    4 +--
 include/unotools/readwritemutexguard.hxx     |   11 +-------
 tools/source/inet/inetstrm.cxx               |   20 ++++++---------
 unotools/source/i18n/readwritemutexguard.cxx |   36 +++++++++++++--------------
 4 files changed, 31 insertions(+), 40 deletions(-)

New commits:
commit 2841cf6c9f733c2c26e90b8494b5b076cc9d507d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 7 15:12:52 2017 +0200

    loplugin:inlinefields in utl::ReadWriteMutex
    
    Change-Id: Ibd31d1c0ec154be886f9fd4d2e7a439b2d7f5f4a
    Reviewed-on: https://gerrit.libreoffice.org/36267
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/unotools/readwritemutexguard.hxx b/include/unotools/readwritemutexguard.hxx
index 01a022c26217..94767024a911 100644
--- a/include/unotools/readwritemutexguard.hxx
+++ b/include/unotools/readwritemutexguard.hxx
@@ -31,21 +31,14 @@ class ReadWriteMutex
 
             sal_uInt32          nReadCount;
             sal_uInt32          nBlockCriticalCount;
-            ::osl::Mutex*       pMutex;
-            ::osl::Mutex*       pWriteMutex;
+            ::osl::Mutex        maMutex;
+            ::osl::Mutex        maWriteMutex;
 
 public:
                                 ReadWriteMutex()
                                     : nReadCount(0)
                                     , nBlockCriticalCount(0)
-                                    , pMutex( new ::osl::Mutex )
-                                    , pWriteMutex( new ::osl::Mutex )
                                     {}
-                                ~ReadWriteMutex()
-                                    {
-                                        delete pMutex;
-                                        delete pWriteMutex;
-                                    }
 };
 
 namespace ReadWriteGuardMode {
diff --git a/unotools/source/i18n/readwritemutexguard.cxx b/unotools/source/i18n/readwritemutexguard.cxx
index 904dba39c0c7..2932212d3c12 100644
--- a/unotools/source/i18n/readwritemutexguard.cxx
+++ b/unotools/source/i18n/readwritemutexguard.cxx
@@ -28,52 +28,52 @@ ReadWriteGuard::ReadWriteGuard( ReadWriteMutex& rMutexP,
 {
     // don't do anything until a pending write completed (or another
     // ReadWriteGuard leaves the ctor phase)
-    ::osl::MutexGuard aGuard( rMutex.pWriteMutex );
+    ::osl::MutexGuard aGuard( rMutex.maWriteMutex );
     nMode = nRequestMode;
     if ( nMode & ReadWriteGuardMode::nWrite )
     {
-        rMutex.pWriteMutex->acquire();
+        rMutex.maWriteMutex.acquire();
         // wait for any read to complete
 // TODO: set up a waiting thread instead of a loop
         bool bWait = true;
         do
         {
-            rMutex.pMutex->acquire();
+            rMutex.maMutex.acquire();
             bWait = (rMutex.nReadCount != 0);
             if ( nMode & ReadWriteGuardMode::nCriticalChange )
                 bWait |= (rMutex.nBlockCriticalCount != 0);
-            rMutex.pMutex->release();
+            rMutex.maMutex.release();
         } while ( bWait );
     }
     else if ( nMode & ReadWriteGuardMode::nBlockCritical )
     {
-        rMutex.pMutex->acquire();
+        rMutex.maMutex.acquire();
         ++rMutex.nBlockCriticalCount;
-        rMutex.pMutex->release();
+        rMutex.maMutex.release();
     }
     else
     {
-        rMutex.pMutex->acquire();
+        rMutex.maMutex.acquire();
         ++rMutex.nReadCount;
-        rMutex.pMutex->release();
+        rMutex.maMutex.release();
     }
 }
 
 ReadWriteGuard::~ReadWriteGuard()
 {
     if ( nMode & ReadWriteGuardMode::nWrite )
-        rMutex.pWriteMutex->release();
+        rMutex.maWriteMutex.release();
     else if ( nMode & ReadWriteGuardMode::nBlockCritical )
     {
-        rMutex.pMutex->acquire();
+        rMutex.maMutex.acquire();
         --rMutex.nBlockCriticalCount;
-        rMutex.pMutex->release();
+        rMutex.maMutex.release();
     }
     else
     {
-        rMutex.pMutex->acquire();
+        rMutex.maMutex.acquire();
         --rMutex.nReadCount;
-        rMutex.pMutex->release();
+        rMutex.maMutex.release();
     }
 }
 
@@ -86,20 +86,20 @@ void ReadWriteGuard::changeReadToWrite()
         // MUST release read before acquiring write mutex or dead lock would
         // occur if there was a write in another thread waiting for this read
         // to complete.
-        rMutex.pMutex->acquire();
+        rMutex.maMutex.acquire();
         --rMutex.nReadCount;
-        rMutex.pMutex->release();
+        rMutex.maMutex.release();
 
-        rMutex.pWriteMutex->acquire();
+        rMutex.maWriteMutex.acquire();
         nMode |= ReadWriteGuardMode::nWrite;
         // wait for any other read to complete
 // TODO: set up a waiting thread instead of a loop
         bool bWait = true;
         do
         {
-            rMutex.pMutex->acquire();
+            rMutex.maMutex.acquire();
             bWait = (rMutex.nReadCount != 0);
-            rMutex.pMutex->release();
+            rMutex.maMutex.release();
         } while ( bWait );
     }
 }
commit 52117bb8c337c98c200b6846c8d9fa2d1831ac51
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 7 15:09:29 2017 +0200

    loplugin:inlinefields in INetMIMEMessageStream
    
    Change-Id: I675b53a55e02899f0cf325245cedb298f6903281
    Reviewed-on: https://gerrit.libreoffice.org/36266
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index 8d6353b632b6..d09aa94fb4d3 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -20,10 +20,10 @@
 #define INCLUDED_TOOLS_INETSTRM_HXX
 
 #include <tools/toolsdllapi.h>
+#include <tools/stream.hxx>
 #include <sal/types.h>
 
 class INetMIMEMessage;
-class SvMemoryStream;
 class SvStream;
 
 class TOOLS_DLLPUBLIC INetMIMEMessageStream
@@ -36,7 +36,7 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
     sal_Char       *pWrite;
 
     SvStream       *pMsgStrm;
-    SvMemoryStream *pMsgBuffer;
+    SvMemoryStream  maMsgBuffer;
     sal_Char       *pMsgRead;
     sal_Char       *pMsgWrite;
 
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 99716a13f5e9..156a24599190 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -34,7 +34,7 @@ int INetMIMEMessageStream::GetHeaderLine(sal_Char* pData, sal_uIntPtr nSize)
 
     sal_uIntPtr i, n;
 
-    if (pMsgBuffer->Tell() == 0)
+    if (maMsgBuffer.Tell() == 0)
     {
         // Insert formatted header into buffer.
         n = pSourceMsg->GetHeaderCount();
@@ -44,15 +44,15 @@ int INetMIMEMessageStream::GetHeaderLine(sal_Char* pData, sal_uIntPtr nSize)
             if (aHeader.GetValue().getLength())
             {
                 // NYI: Folding long lines.
-                pMsgBuffer->WriteCharPtr( aHeader.GetName().getStr() );
-                pMsgBuffer->WriteCharPtr( ": " );
-                pMsgBuffer->WriteCharPtr( aHeader.GetValue().getStr() );
-                pMsgBuffer->WriteCharPtr( "\r\n" );
+                maMsgBuffer.WriteCharPtr( aHeader.GetName().getStr() );
+                maMsgBuffer.WriteCharPtr( ": " );
+                maMsgBuffer.WriteCharPtr( aHeader.GetValue().getStr() );
+                maMsgBuffer.WriteCharPtr( "\r\n" );
             }
         }
 
-        pMsgWrite = const_cast<char *>(static_cast<sal_Char const *>(pMsgBuffer->GetData()));
-        pMsgRead  = pMsgWrite + pMsgBuffer->Tell();
+        pMsgWrite = const_cast<char *>(static_cast<sal_Char const *>(maMsgBuffer.GetData()));
+        pMsgRead  = pMsgWrite + maMsgBuffer.Tell();
     }
 
     n = pMsgRead - pMsgWrite;
@@ -65,7 +65,7 @@ int INetMIMEMessageStream::GetHeaderLine(sal_Char* pData, sal_uIntPtr nSize)
     else
     {
         // Reset buffer.
-        pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN);
+        maMsgBuffer.Seek(STREAM_SEEK_TO_BEGIN);
     }
 
     return (pWBuf - pData);
@@ -234,7 +234,6 @@ INetMIMEMessageStream::INetMIMEMessageStream(
     pSourceMsg(pMsg),
     bHeaderGenerated(headerGenerated),
     pMsgStrm(nullptr),
-    pMsgBuffer(new SvMemoryStream),
     pMsgRead(nullptr),
     pMsgWrite(nullptr),
     done(false),
@@ -242,7 +241,7 @@ INetMIMEMessageStream::INetMIMEMessageStream(
     pChildStrm(nullptr)
 {
     assert(pMsg != nullptr);
-    pMsgBuffer->SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
+    maMsgBuffer.SetStreamCharSet(RTL_TEXTENCODING_ASCII_US);
     pBuffer = new sal_Char[BUFFER_SIZE];
     pRead = pWrite = pBuffer;
 }
@@ -251,7 +250,6 @@ INetMIMEMessageStream::~INetMIMEMessageStream()
 {
     delete pChildStrm;
     delete [] pBuffer;
-    delete pMsgBuffer;
     delete pMsgStrm;
 }
 


More information about the Libreoffice-commits mailing list