From 433827c2de1bde02b47b661e66c969fdad463838 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 15 Oct 2004 21:44:23 +0000 Subject: [PATCH] remove ProtAllocator hack --- stepmania/src/RageSoundManager.cpp | 27 ------------- stepmania/src/RageSoundManager.h | 63 +----------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 22612e78a3..acdbe10196 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -12,26 +12,6 @@ #include "arch/arch.h" #include "arch/Sound/RageSoundDriver.h" -#if defined(_MSC_VER) && _MSC_VER >= 1300 -set g_ProtectedPages; -void EnableWrites() -{ - DWORD ignore; - for( set::iterator it = g_ProtectedPages.begin(); it != g_ProtectedPages.end(); ++it ) - VirtualProtect( *it, 4096, PAGE_READWRITE, &ignore ); -} - -void DisableWrites() -{ - DWORD ignore; - for( set::iterator it = g_ProtectedPages.begin(); it != g_ProtectedPages.end(); ++it ) - VirtualProtect( *it, 4096, PAGE_READONLY, &ignore ); -} -#else -void EnableWrites() { } -void DisableWrites() { } -#endif - /* * This mutex is locked before Update() deletes old sounds from owned_sounds. Lock * this mutex if you want to ensure that sounds remain valid. (Other threads may @@ -56,7 +36,6 @@ RageSoundManager::RageSoundManager() { pos_map_queue.reserve( 1024 ); MixVolume = 1.0f; - DisableWrites(); } void RageSoundManager::Init( CString drivers ) @@ -79,8 +58,6 @@ RageSoundManager::~RageSoundManager() /* Don't lock while deleting the driver (the decoder thread might deadlock). */ delete driver; - - EnableWrites(); /* for dtor */ } void RageSoundManager::StartMixing( RageSoundBase *snd ) @@ -144,18 +121,14 @@ void RageSoundManager::Update(float delta) void RageSoundManager::RegisterSound( RageSound *p ) { g_SoundManMutex.Lock(); /* lock for access to all_sounds */ - EnableWrites(); all_sounds.insert( p ); - DisableWrites(); g_SoundManMutex.Unlock(); /* finished with all_sounds */ } void RageSoundManager::UnregisterSound( RageSound *p ) { g_SoundManMutex.Lock(); /* lock for access to all_sounds */ - EnableWrites(); all_sounds.erase( p ); - DisableWrites(); g_SoundManMutex.Unlock(); /* finished with all_sounds */ } diff --git a/stepmania/src/RageSoundManager.h b/stepmania/src/RageSoundManager.h index f918f3788f..4f71057840 100644 --- a/stepmania/src/RageSoundManager.h +++ b/stepmania/src/RageSoundManager.h @@ -10,67 +10,6 @@ class RageSoundBase; class RageSoundDriver; struct RageSoundParams; -/* This is a temporary hack, to try to track down an obscure crash. */ -#if defined(_WINDOWS) && _MSC_VER >= 1300 -#include - -extern set g_ProtectedPages; -template -class ProtAllocator -{ -public: - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - template struct rebind - { - typedef ProtAllocator other; - }; - - explicit ProtAllocator() {} - ~ProtAllocator() {} - ProtAllocator( ProtAllocator const & ) {} - template ProtAllocator( ProtAllocator const& ) {} - - pointer address( reference r ) { return &r; } - const_pointer address( const_reference r ) { return &r; } - - pointer allocate( size_type cnt, typename std::allocator::const_pointer = 0 ) - { - cnt *= sizeof (T); - void *p = VirtualAlloc( NULL, cnt, MEM_COMMIT, PAGE_READWRITE ); - g_ProtectedPages.insert( p ); - - return reinterpret_cast( p ); - } - void deallocate( pointer p, size_type s ) - { - VirtualFree( p, 0, MEM_RELEASE ); - g_ProtectedPages.erase( p ); - } - - size_type max_size() const - { - return 2147483648 / sizeof(T); - } - - void construct( pointer p, const T& t ) { new(p) T(t); } - void destroy( pointer p ) { p->~T(); } - - bool operator==( ProtAllocator const& ) { return true; } - bool operator!=( ProtAllocator const& a ) { return !operator==(a); } -}; - -#else -#define ProtAllocator allocator -#endif - - class RageSoundManager { /* Set of sounds that we've taken over (and are responsible for deleting @@ -79,7 +18,7 @@ class RageSoundManager set playing_sounds; /* A list of all sounds that currently exist. */ - typedef set, ProtAllocator > all_sounds_type; + typedef set > all_sounds_type; all_sounds_type all_sounds; RageSoundDriver *driver;