diff --git a/common/include/Utilities/Assertions.h b/common/include/Utilities/Assertions.h index 371dc58d7d..2353073a08 100644 --- a/common/include/Utilities/Assertions.h +++ b/common/include/Utilities/Assertions.h @@ -158,6 +158,12 @@ extern pxDoAssertFnType* pxDoAssert; #define IndexBoundsCheckDev( objname, idx, sze ) pxAssertDev( (uint)(idx) < (uint)(sze), \ wxsFormat( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) ) +#define IndexBoundsAssume( objname, idx, sze ) pxAssumeMsg( (uint)(idx) < (uint)(sze), \ + wxsFormat( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) ) + +#define IndexBoundsAssumeDev( objname, idx, sze ) pxAssumeDev( (uint)(idx) < (uint)(sze), \ + wxsFormat( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) ) + extern void pxOnAssert( const DiagnosticOrigin& origin, const wxChar* msg=NULL ); extern void pxOnAssert( const DiagnosticOrigin& origin, const char* msg ); diff --git a/common/include/Utilities/SafeArray.h b/common/include/Utilities/SafeArray.h index 4df00cddc0..2c90d955b8 100644 --- a/common/include/Utilities/SafeArray.h +++ b/common/include/Utilities/SafeArray.h @@ -78,7 +78,7 @@ protected: // builds only -- no bounds checking is done in release builds). T* _getPtr( uint i ) const { - IndexBoundsCheckDev( Name.c_str(), i, m_size ); + IndexBoundsAssumeDev( Name.c_str(), i, m_size ); return &m_ptr[i]; } @@ -156,7 +156,7 @@ protected: T* _getPtr( uint i ) const { - IndexBoundsCheckDev( Name.c_str(), i, m_length ); + IndexBoundsAssumeDev( Name.c_str(), i, m_length ); return &m_ptr[i]; } diff --git a/common/include/Utilities/SafeArray.inl b/common/include/Utilities/SafeArray.inl index bae14e6f16..d0ea200d06 100644 --- a/common/include/Utilities/SafeArray.inl +++ b/common/include/Utilities/SafeArray.inl @@ -255,7 +255,7 @@ T& SafeList::AddNew( const T& src ) template< typename T > void SafeList::Remove( int index ) { - IndexBoundsCheckDev( Name.c_str(), index, m_length ); + IndexBoundsAssumeDev( Name.c_str(), index, m_length ); int copylen = m_length - index; if( copylen > 0 ) diff --git a/common/src/Utilities/FastFormatString.cpp b/common/src/Utilities/FastFormatString.cpp index 91bd946fd6..ca968b49a1 100644 --- a/common/src/Utilities/FastFormatString.cpp +++ b/common/src/Utilities/FastFormatString.cpp @@ -20,6 +20,17 @@ using namespace Threading; +// Implement some very commonly used SafeArray types here +// (done here for lack of a better place) + +template class SafeArray; +template class SafeArray; +template class SafeArray; + +template class SafeAlignedArray; +template class SafeAlignedArray; +template class SafeAlignedArray; + // Sanity check: truncate strings if they exceed 512k in length. Anything like that // is either a bug or really horrible code that needs to be stopped before it causes // system deadlock. @@ -50,7 +61,6 @@ public: for (uint i=0; iGetPtr(); } + diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index b2ceab8aa4..8e32e74b08 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -326,8 +326,8 @@ namespace FilenameDefs } }; - IndexBoundsCheckDev( L"FilenameDefs::Memcard", port, 2 ); - IndexBoundsCheckDev( L"FilenameDefs::Memcard", slot, 4 ); + IndexBoundsAssumeDev( L"FilenameDefs::Memcard", port, 2 ); + IndexBoundsAssumeDev( L"FilenameDefs::Memcard", slot, 4 ); return retval[port][slot]; } @@ -620,7 +620,7 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini ) // ------------------------------------------------------------------------ const wxFileName& AppConfig::FilenameOptions::operator[]( PluginsEnum_t pluginidx ) const { - IndexBoundsCheckDev( L"Filename[Plugin]", pluginidx, PluginId_Count ); + IndexBoundsAssumeDev( L"Filename[Plugin]", pluginidx, PluginId_Count ); return Plugins[pluginidx]; }