* Set the PCSX2 event handler queues to use the wxObject allocator (reduces heap fragmentation, multithread performance, etc) [MSW/Win32 only]

* SafeFree() macro changed: Remove null check on calls to free(); should be 100% safe as according to wx gurus.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3102 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-05-28 16:50:49 +00:00
parent 6282570b9c
commit 9e7394afff
3 changed files with 31 additions and 23 deletions

View File

@ -38,12 +38,11 @@ extern void pcsx2_aligned_free(void* pmem);
#define safe_delete_array( ptr ) \
((void) (delete[] (ptr)), (ptr) = NULL)
// fixme: I'm pretty sure modern libc implementations under gcc and msvc check null status
// inside free(), meaning we shouldn't have to do it ourselves. But legacy implementations
// didn't always check, so best to be cautious unless absolutely certain it's being covered on
// all ported platforms.
// No checks for NULL -- wxWidgets says it's safe to skip NULL checks and it runs on
// just about every compiler and libc implementation of any recentness.
#define safe_free( ptr ) \
((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL))
( (void) (free( ptr ), !!0), (ptr) = NULL )
//((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL))
#define safe_fclose( ptr ) \
((void) (( ( (ptr) != NULL ) && (fclose( ptr ), !!0) ), (ptr) = NULL))
@ -86,12 +85,13 @@ protected:
// use its own memory allocation (with an aligned memory, for example).
// Throws:
// Exception::OutOfMemory if the allocated_mem pointer is NULL.
explicit SafeArray( const wxChar* name, T* allocated_mem, int initSize ) :
Name( name )
, ChunkSize( DefaultChunkSize )
, m_ptr( allocated_mem )
, m_size( initSize )
explicit SafeArray( const wxChar* name, T* allocated_mem, int initSize )
: Name( name )
{
ChunkSize = DefaultChunkSize;
m_ptr = allocated_mem;
m_size = initSize;
if( m_ptr == NULL )
throw Exception::OutOfMemory();
}
@ -110,20 +110,21 @@ public:
safe_free( m_ptr );
}
explicit SafeArray( const wxChar* name=L"Unnamed" ) :
Name( name )
, ChunkSize( DefaultChunkSize )
, m_ptr( NULL )
, m_size( 0 )
explicit SafeArray( const wxChar* name=L"Unnamed" )
: Name( name )
{
ChunkSize = DefaultChunkSize;
m_ptr = NULL;
m_size = 0;
}
explicit SafeArray( int initialSize, const wxChar* name=L"Unnamed" ) :
Name( name )
, ChunkSize( DefaultChunkSize )
, m_ptr( (initialSize==0) ? NULL : (T*)malloc( initialSize * sizeof(T) ) )
, m_size( initialSize )
explicit SafeArray( int initialSize, const wxChar* name=L"Unnamed" )
: Name( name )
{
ChunkSize = DefaultChunkSize;
m_ptr = (initialSize==0) ? NULL : (T*)malloc( initialSize * sizeof(T) );
m_size = initialSize;
if( (initialSize != 0) && (m_ptr == NULL) )
throw Exception::OutOfMemory();
}

View File

@ -41,7 +41,11 @@ public:
virtual void OnActionButtonClicked( wxCommandEvent& evt );
};
typedef std::list<wxEvent*> wxEventList;
#ifdef _MSC_VER
typedef std::list< wxEvent*, wxObjectAllocator<wxEvent*> > wxEventList;
#else
typedef std::list< wxEvent* > wxEventList;
#endif
// --------------------------------------------------------------------------------------
// wxAppWithHelpers

View File

@ -126,8 +126,11 @@ protected:
}
};
typedef std::list<SysExecEvent*> pxEvtList;
#ifdef _MSC_VER
typedef std::list< SysExecEvent*, wxObjectAllocator<SysExecEvent*> > pxEvtList;
#else
typedef std::list<SysExecEvent*> pxEvtList;
#endif
// --------------------------------------------------------------------------------------
// pxEvtHandler