Kaydet (Commit) 5e9db55d authored tarafından Caolán McNamara's avatar Caolán McNamara

cppcheck: allocaCalled

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