[Libreoffice-commits] core.git: 2 commits - cppu/source sw/inc sw/source

Caolán McNamara caolanm at redhat.com
Sun Jan 3 12:40:16 PST 2016


 cppu/source/typelib/typelib.cxx |   11 ++++------
 cppu/source/uno/lbenv.cxx       |   42 +++++++++++++++++++---------------------
 sw/inc/splargs.hxx              |    4 ++-
 sw/source/core/edit/edlingu.cxx |    4 +--
 4 files changed, 30 insertions(+), 31 deletions(-)

New commits:
commit 6cf667cc94262b563869e851b01c3c49fe98c6c8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 3 20:24:38 2016 +0000

    cppcheck: passedByValue
    
    Change-Id: Id8b2db3b824ea40345aba99a5f24f2579c0ad630

diff --git a/sw/inc/splargs.hxx b/sw/inc/splargs.hxx
index 7010e6a..9b1457d 100644
--- a/sw/inc/splargs.hxx
+++ b/sw/inc/splargs.hxx
@@ -155,8 +155,10 @@ public:
 
 namespace sw {
 
+typedef std::function<SwTextFrame*()> Creator;
+
 SwTextFrame *
-SwHyphIterCacheLastTextFrame(SwTextNode *, std::function<SwTextFrame * ()>);
+SwHyphIterCacheLastTextFrame(SwTextNode *, const Creator& rCreator);
 
 }
 
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index a92705e..6433dd8 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -158,7 +158,7 @@ class SwHyphIter : public SwLinguIter
     // With that we save a GetFrame() in Hyphenate //TODO: does it actually matter?
     const SwTextNode *m_pLastNode;
     SwTextFrame  *m_pLastFrame;
-    friend SwTextFrame * sw::SwHyphIterCacheLastTextFrame(SwTextNode *, std::function<SwTextFrame * ()>);
+    friend SwTextFrame * sw::SwHyphIterCacheLastTextFrame(SwTextNode* pNode, const sw::Creator& rCreator);
 
     bool bOldIdle;
     static void DelSoftHyph( SwPaM &rPam );
@@ -573,7 +573,7 @@ namespace sw {
 
 SwTextFrame *
 SwHyphIterCacheLastTextFrame(SwTextNode *const pNode,
-        std::function<SwTextFrame * ()> const create)
+        const sw::Creator& create)
 {
     assert(g_pHyphIter);
     if (pNode != g_pHyphIter->m_pLastNode || !g_pHyphIter->m_pLastFrame)
commit 5e9db55defd89a963891c690511160e1ff663a88
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Jan 3 20:20:14 2016 +0000

    cppcheck: allocaCalled
    
    Change-Id: I4e2345cdf9fd8d088f3522d563263b65abedb7c9

diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index ee7ca0d..e105bfe 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -31,7 +31,6 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sal/alloca.h>
 #include <new>
 #include <osl/interlck.h>
 #include <osl/mutex.hxx>
@@ -384,10 +383,10 @@ static inline void typelib_typedescription_initTables(
 {
     typelib_InterfaceTypeDescription * pITD = reinterpret_cast<typelib_InterfaceTypeDescription *>(pTD);
 
-    sal_Bool * pReadWriteAttributes = static_cast<sal_Bool *>(alloca( pITD->nAllMembers ));
+    std::vector<sal_Bool> aReadWriteAttributes(pITD->nAllMembers);
     for ( sal_Int32 i = pITD->nAllMembers; i--; )
     {
-        pReadWriteAttributes[i] = sal_False;
+        aReadWriteAttributes[i] = sal_False;
         if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pITD->ppAllMembers[i]->eTypeClass )
         {
             typelib_TypeDescription * pM = nullptr;
@@ -395,7 +394,7 @@ static inline void typelib_typedescription_initTables(
             OSL_ASSERT( pM );
             if (pM)
             {
-                pReadWriteAttributes[i] = !reinterpret_cast<typelib_InterfaceAttributeTypeDescription *>(pM)->bReadOnly;
+                aReadWriteAttributes[i] = !reinterpret_cast<typelib_InterfaceAttributeTypeDescription *>(pM)->bReadOnly;
                 TYPELIB_DANGER_RELEASE( pM );
             }
 #if OSL_DEBUG_LEVEL > 1
@@ -420,7 +419,7 @@ static inline void typelib_typedescription_initTables(
             // index to the get method of the attribute
             pITD->pMapMemberIndexToFunctionIndex[i] = i + nAdditionalOffset;
             // extra offset if it is a read/write attribute?
-            if( pReadWriteAttributes[i] )
+            if (aReadWriteAttributes[i])
             {
                 // a read/write attribute
                 nAdditionalOffset++;
@@ -435,7 +434,7 @@ static inline void typelib_typedescription_initTables(
             // index to the get method of the attribute
             pITD->pMapFunctionIndexToMemberIndex[i + nAdditionalOffset] = i;
             // extra offset if it is a read/write attribute?
-            if( pReadWriteAttributes[i] )
+            if (aReadWriteAttributes[i])
             {
                 // a read/write attribute
                 pITD->pMapFunctionIndexToMemberIndex[i + ++nAdditionalOffset] = i;
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx
index 07ca065..b9e964da 100644
--- a/cppu/source/uno/lbenv.cxx
+++ b/cppu/source/uno/lbenv.cxx
@@ -21,7 +21,6 @@
 
 #include "cppu/EnvDcp.hxx"
 
-#include "sal/alloca.h"
 #include "sal/log.hxx"
 #include "osl/diagnose.h"
 #include "osl/interlck.h"
@@ -79,7 +78,7 @@ struct ObjectEntry
 {
     OUString oid;
     sal_Int32 nRef;
-    ::std::vector< InterfaceEntry > aInterfaces;
+    std::vector< InterfaceEntry > aInterfaces;
     bool mixedObject;
 
     explicit inline ObjectEntry( const OUString & rOId_ );
@@ -90,15 +89,15 @@ struct ObjectEntry
         uno_freeProxyFunc fpFreeProxy );
     inline InterfaceEntry * find(
         typelib_InterfaceTypeDescription * pTypeDescr );
-    inline sal_Int32 find( void * iface_ptr, ::std::size_t pos );
+    inline sal_Int32 find( void * iface_ptr, std::size_t pos );
 };
 
 
 struct FctPtrHash :
-    public ::std::unary_function< const void *, ::std::size_t >
+    public std::unary_function< const void *, std::size_t >
 {
-    ::std::size_t operator () ( const void * pKey ) const
-        { return reinterpret_cast< ::std::size_t>( pKey ); }
+    std::size_t operator () ( const void * pKey ) const
+        { return reinterpret_cast< std::size_t>( pKey ); }
 };
 
 
@@ -109,7 +108,7 @@ typedef std::unordered_map<
 // mapping from ptr to object entry
 typedef std::unordered_map<
     void *, ObjectEntry *, FctPtrHash,
-    ::std::equal_to< void * > > Ptr2ObjectMap;
+    std::equal_to< void * > > Ptr2ObjectMap;
 // mapping from oid to object entry
 typedef std::unordered_map<
     OUString, ObjectEntry *, OUStringHash > OId2ObjectMap;
@@ -172,7 +171,7 @@ inline void ObjectEntry::append(
     typelib_typedescription_acquire( &pTypeDescr->aBase );
     aNewEntry.pTypeDescr = pTypeDescr;
 
-    ::std::pair< Ptr2ObjectMap::iterator, bool > i(
+    std::pair< Ptr2ObjectMap::iterator, bool > i(
         pEnv->aPtr2ObjectMap.insert( Ptr2ObjectMap::value_type(
                                          pInterface, this ) ) );
     SAL_WARN_IF(
@@ -199,8 +198,8 @@ inline InterfaceEntry * ObjectEntry::find(
         return &aInterfaces[ 0 ];
     }
 
-    ::std::size_t nSize = aInterfaces.size();
-    for ( ::std::size_t nPos = 0; nPos < nSize; ++nPos )
+    std::size_t nSize = aInterfaces.size();
+    for ( std::size_t nPos = 0; nPos < nSize; ++nPos )
     {
         typelib_InterfaceTypeDescription * pITD =
             aInterfaces[ nPos ].pTypeDescr;
@@ -216,9 +215,9 @@ inline InterfaceEntry * ObjectEntry::find(
 
 
 inline sal_Int32 ObjectEntry::find(
-    void * iface_ptr, ::std::size_t pos )
+    void * iface_ptr, std::size_t pos )
 {
-    ::std::size_t size = aInterfaces.size();
+    std::size_t size = aInterfaces.size();
     for ( ; pos < size; ++pos )
     {
         if (aInterfaces[ pos ].pInterface == iface_ptr)
@@ -408,7 +407,7 @@ static void SAL_CALL s_stub_defenv_revokeInterface(va_list * pParam)
                     {
                         // proxy ptr not registered for another interface:
                         // remove from ptr map
-                        ::std::size_t erased =
+                        std::size_t erased =
                               that->aPtr2ObjectMap.erase( pInterface );
                         OSL_ASSERT( erased == 1 );
                     }
@@ -733,7 +732,7 @@ extern "C" void SAL_CALL uno_dumpEnvironment(
         buf.append( '\"' );
         writeLine( stream, buf.makeStringAndClear(), pFilter );
 
-        for ( ::std::size_t nPos = 0;
+        for ( std::size_t nPos = 0;
               nPos < pOEntry->aInterfaces.size(); ++nPos )
         {
             const InterfaceEntry & rIEntry = pOEntry->aInterfaces[nPos];
@@ -756,7 +755,7 @@ extern "C" void SAL_CALL uno_dumpEnvironment(
 
             if (pOEntry->find( rIEntry.pInterface, nPos + 1 ) < 0)
             {
-                ::std::size_t erased = ptr2obj.erase( rIEntry.pInterface );
+                std::size_t erased = ptr2obj.erase( rIEntry.pInterface );
                 if (erased != 1)
                 {
                     buf.append( " (ptr not found in map!)" );
@@ -959,7 +958,7 @@ inline void EnvironmentsData::registerEnvironment( uno_Environment ** ppEnv )
     if (iFind == aName2EnvMap.end())
     {
         (*pEnv->acquireWeak)( pEnv );
-        ::std::pair< OUString2EnvironmentMap::iterator, bool > insertion (
+        std::pair< OUString2EnvironmentMap::iterator, bool > insertion (
             aName2EnvMap.insert(
                 OUString2EnvironmentMap::value_type( aKey, pEnv ) ) );
         SAL_WARN_IF( !insertion.second, "cppu", "key " << aKey << " already in env map" );
@@ -991,8 +990,7 @@ inline void EnvironmentsData::getRegisteredEnvironments(
     assert(pppEnvs && pnLen && memAlloc && "### null ptr!");
 
     // max size
-    uno_Environment ** ppFound = static_cast<uno_Environment **>(alloca(
-        sizeof(uno_Environment *) * aName2EnvMap.size() ));
+    std::vector<uno_Environment*> aFounds(aName2EnvMap.size());
     sal_Int32 nSize = 0;
 
     // find matching environment
@@ -1003,9 +1001,9 @@ inline void EnvironmentsData::getRegisteredEnvironments(
         if (rEnvDcp.isEmpty() ||
             rEnvDcp.equals( pWeak->pTypeName ))
         {
-            ppFound[nSize] = nullptr;
-            (*pWeak->harden)( &ppFound[nSize], pWeak );
-            if (ppFound[nSize])
+            aFounds[nSize] = nullptr;
+            (*pWeak->harden)( &aFounds[nSize], pWeak );
+            if (aFounds[nSize])
                 ++nSize;
         }
     }
@@ -1018,7 +1016,7 @@ inline void EnvironmentsData::getRegisteredEnvironments(
         OSL_ASSERT( *pppEnvs );
         while (nSize--)
         {
-            (*pppEnvs)[nSize] = ppFound[nSize];
+            (*pppEnvs)[nSize] = aFounds[nSize];
         }
     }
     else


More information about the Libreoffice-commits mailing list