From 03ce23e9eaec88132e69004f8ca28a1687b76889 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 18 Sep 2006 23:27:09 +0000 Subject: [PATCH] ARRAYLEN --- .../InputHandler_MonkeyKeyboard.cpp | 2 +- .../InputHandler/InputHandler_Win32_Pump.cpp | 2 +- .../arch/InputHandler/InputHandler_X11.cpp | 2 +- .../arch/InputHandler/InputHandler_Xbox.cpp | 6 ++--- .../src/arch/Sound/RageSoundDriver_ALSA9.cpp | 2 +- .../RageSoundDriver_Generic_Software.cpp | 22 +++++++++---------- .../src/archutils/Unix/EmergencyShutdown.cpp | 2 +- .../src/archutils/Win32/CrashHandlerChild.cpp | 2 +- stepmania/src/archutils/Win32/DialogUtil.cpp | 4 ++-- stepmania/src/crypto/CryptRSA.cpp | 2 +- stepmania/src/tests/test_audio_readers.cpp | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/stepmania/src/arch/InputHandler/InputHandler_MonkeyKeyboard.cpp b/stepmania/src/arch/InputHandler/InputHandler_MonkeyKeyboard.cpp index 4a3011366a..5b3292bfc7 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_MonkeyKeyboard.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_MonkeyKeyboard.cpp @@ -50,7 +50,7 @@ static const DeviceButton g_keys[] = static DeviceButton GetRandomKeyboardKey() { - int index = RandomInt( ARRAYSIZE(g_keys) ); + int index = RandomInt( ARRAYLEN(g_keys) ); return g_keys[index]; } diff --git a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp index 6cad3c276f..41149df4ea 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp @@ -56,7 +56,7 @@ void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent ) InputDevice id = InputDevice( DEVICE_PUMP1 + iDevice ); - for( int iButton = 0; iButton < ARRAYSIZE(bits); ++iButton ) + for( int iButton = 0; iButton < ARRAYLEN(bits); ++iButton ) { DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton) ); diff --git a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp index 9ec943ef6e..ca969d7eb0 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_X11.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_X11.cpp @@ -46,7 +46,7 @@ static DeviceButton XSymToDeviceButton( int key ) return ASCIIKeySyms[key & 0xFF]; /* 32...127: */ - if( key < int(ARRAYSIZE(ASCIIKeySyms))) + if( key < int(ARRAYLEN(ASCIIKeySyms))) return ASCIIKeySyms[key]; /* XK_KP_0 ... XK_KP_9 to KEY_KP_C0 ... KEY_KP_C9 */ diff --git a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp index a64d74b404..2ab790153d 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp @@ -96,7 +96,7 @@ void InputHandler_Xbox::Update() XInputGetState( joysticks[i], &xis ); // check buttons - for(int j = 0; j < ARRAYSIZE(buttonMasks); j++) + for(int j = 0; j < ARRAYLEN(buttonMasks); j++) { DWORD nowPressed = xis.Gamepad.wButtons & buttonMasks[j]; DWORD wasPressed = lastState[i].wButtons & buttonMasks[j]; @@ -116,7 +116,7 @@ void InputHandler_Xbox::Update() } // check analog buttons - for(int j = 0; j < ARRAYSIZE(xis.Gamepad.bAnalogButtons); j++) + for(int j = 0; j < ARRAYLEN(xis.Gamepad.bAnalogButtons); j++) { bool nowPressed = xis.Gamepad.bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK; bool wasPressed = lastState[i].bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK; @@ -138,7 +138,7 @@ void InputHandler_Xbox::Update() // check thumbsticks SHORT axes[] = { xis.Gamepad.sThumbLX, xis.Gamepad.sThumbLY, xis.Gamepad.sThumbRX, xis.Gamepad.sThumbRY}; - for(int j = 0; j < ARRAYSIZE(axes); j++) + for(int j = 0; j < ARRAYLEN(axes); j++) { if(axes[j] != 0) { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp index baa9790409..ca503a965f 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp @@ -301,7 +301,7 @@ static RString CheckMixingBlacklist() /* ALSA Driver: 0: Aureal Vortex au8830 [au8830], device 0: AU88x0 ADB [adb], 32/32 subdevices avail * ALSA segfaults after creating about ten subdevices. */ "au8830", - }, *blacklist_end = blacklist+ARRAYSIZE(blacklist); + }, *blacklist_end = blacklist+ARRAYLEN(blacklist); if( find( &blacklist[0], blacklist_end, sID ) != blacklist_end ) return ssprintf( "ALSA driver \"%s\" not using hardware mixing", sID.c_str() ); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp index b90193dd54..3dfbb27740 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_Generic_Software.cpp @@ -63,7 +63,7 @@ void RageSound_Generic_Software::Mix( int16_t *buf, int frames, int64_t frameno, static RageSoundMixBuffer mix; - for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i ) + for( unsigned i = 0; i < ARRAYLEN(sounds); ++i ) { /* s.snd can not safely be accessed from here. */ sound &s = sounds[i]; @@ -174,7 +174,7 @@ void RageSound_Generic_Software::DecodeThread() LockMut( m_Mutex ); // LOG->Trace("begin mix"); - for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i ) + for( unsigned i = 0; i < ARRAYLEN(sounds); ++i ) { /* The volume can change while the sound is playing; update it. */ /* XXX: We can't access snd when in STOPPING; it doesn't exist anymore. */ @@ -195,7 +195,7 @@ void RageSound_Generic_Software::DecodeThread() * causing major CPU bursts when the stream starts or underruns. (Filling 32k * takes more CPU than filling 4k frames, and may cause a gameplay skip.) */ - for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i ) + for( unsigned i = 0; i < ARRAYLEN(sounds); ++i ) { if( sounds[i].state != sound::PLAYING ) continue; @@ -245,7 +245,7 @@ int RageSound_Generic_Software::GetDataForSound( sound &s ) ASSERT( psize[0] > 0 ); sound_block *b = p[0]; - int size = ARRAYSIZE(b->buf)/channels; + int size = ARRAYLEN(b->buf)/channels; bool eof = !s.snd->GetDataToPlay( b->buf, size, b->position, b->frames_in_buffer ); b->p = b->buf; @@ -263,7 +263,7 @@ void RageSound_Generic_Software::Update() /* We must not lock here, since the decoder thread might hold the lock for a * while at a time. This is threadsafe, because once a sound is in STOPPING, * this is the only place it'll be changed (to STOPPED). */ - for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i ) + for( unsigned i = 0; i < ARRAYLEN(sounds); ++i ) { switch( sounds[i].state ) { @@ -316,10 +316,10 @@ void RageSound_Generic_Software::StartMixing( RageSoundBase *snd ) m_SoundListMutex.Lock(); unsigned i; - for( i = 0; i < ARRAYSIZE(sounds); ++i ) + for( i = 0; i < ARRAYLEN(sounds); ++i ) if( sounds[i].state == sound::AVAILABLE ) break; - if( i == ARRAYSIZE(sounds) ) + if( i == ARRAYLEN(sounds) ) { m_SoundListMutex.Unlock(); return; @@ -381,10 +381,10 @@ void RageSound_Generic_Software::StopMixing( RageSoundBase *snd ) /* Find the sound. */ unsigned i; - for( i = 0; i < ARRAYSIZE(sounds); ++i ) + for( i = 0; i < ARRAYLEN(sounds); ++i ) if( sounds[i].state != sound::AVAILABLE && sounds[i].snd == snd ) break; - if( i == ARRAYSIZE(sounds) ) + if( i == ARRAYLEN(sounds) ) { LOG->Trace( "not stopping a sound because it's not playing" ); return; @@ -416,14 +416,14 @@ bool RageSound_Generic_Software::PauseMixing( RageSoundBase *snd, bool bStop ) /* Find the sound. */ unsigned i; - for( i = 0; i < ARRAYSIZE(sounds); ++i ) + for( i = 0; i < ARRAYLEN(sounds); ++i ) if( sounds[i].state != sound::AVAILABLE && sounds[i].snd == snd ) break; /* A sound can be paused in PLAYING or STOPPING. (STOPPING means the sound * has been decoded to the end, and we're waiting for that data to finish, so * externally it looks and acts like PLAYING.) */ - if( i == ARRAYSIZE(sounds) || + if( i == ARRAYLEN(sounds) || (sounds[i].state != sound::PLAYING && sounds[i].state != sound::STOPPING) ) { LOG->Trace( "not pausing a sound because it's not playing" ); diff --git a/stepmania/src/archutils/Unix/EmergencyShutdown.cpp b/stepmania/src/archutils/Unix/EmergencyShutdown.cpp index 6d8689a9f5..48c46ab982 100644 --- a/stepmania/src/archutils/Unix/EmergencyShutdown.cpp +++ b/stepmania/src/archutils/Unix/EmergencyShutdown.cpp @@ -8,7 +8,7 @@ static unsigned g_iNumEmergencyFuncs = 0; void RegisterEmergencyShutdownCallback( void (*pFunc)() ) { - ASSERT( g_iNumEmergencyFuncs+1 < ARRAYSIZE(g_pEmergencyFunc) ); + ASSERT( g_iNumEmergencyFuncs+1 < ARRAYLEN(g_pEmergencyFunc) ); g_pEmergencyFunc[ g_iNumEmergencyFuncs++ ] = pFunc; } diff --git a/stepmania/src/archutils/Win32/CrashHandlerChild.cpp b/stepmania/src/archutils/Win32/CrashHandlerChild.cpp index bf1c0078ec..b3b9531b6c 100644 --- a/stepmania/src/archutils/Win32/CrashHandlerChild.cpp +++ b/stepmania/src/archutils/Win32/CrashHandlerChild.cpp @@ -118,7 +118,7 @@ namespace VDDebugInfo pctx->sRawBlock = RString(); pctx->pRVAHeap = NULL; - GetVDIPath( pctx->sFilename, ARRAYSIZE(pctx->sFilename) ); + GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) ); pctx->sError = RString(); HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); diff --git a/stepmania/src/archutils/Win32/DialogUtil.cpp b/stepmania/src/archutils/Win32/DialogUtil.cpp index 74ae4b9ce7..478a10f490 100644 --- a/stepmania/src/archutils/Win32/DialogUtil.cpp +++ b/stepmania/src/archutils/Win32/DialogUtil.cpp @@ -63,7 +63,7 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg ) RString sGroup; { - ::GetWindowText( hdlg, szTemp, ARRAYSIZE(szTemp) ); + ::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) ); RString s = szTemp; sGroup = "Dialog-"+s; s = THEME->GetString( sGroup, s ); @@ -72,7 +72,7 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg ) for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != NULL; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) ) { - ::GetWindowText( hwndChild, szTemp, ARRAYSIZE(szTemp) ); + ::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) ); RString s = szTemp; if( s.empty() ) continue; diff --git a/stepmania/src/crypto/CryptRSA.cpp b/stepmania/src/crypto/CryptRSA.cpp index 42e8c8a38d..0f48335078 100644 --- a/stepmania/src/crypto/CryptRSA.cpp +++ b/stepmania/src/crypto/CryptRSA.cpp @@ -122,7 +122,7 @@ static Bignum rsa_privkey_op(Bignum input, const RSAKey *key) SHA512_State ss; unsigned char digest512[64]; - unsigned digestused = ARRAYSIZE(digest512); + unsigned digestused = ARRAYLEN(digest512); int hashseq = 0; /* diff --git a/stepmania/src/tests/test_audio_readers.cpp b/stepmania/src/tests/test_audio_readers.cpp index 0cb0ea9cde..9ca8b97f38 100644 --- a/stepmania/src/tests/test_audio_readers.cpp +++ b/stepmania/src/tests/test_audio_readers.cpp @@ -344,7 +344,7 @@ bool RunTests( SoundReader *snd, const TestFile &tf ) if( !Identical ) { LOG->Trace("Expected data:"); - dump( tf.initial, ARRAYSIZE(tf.initial) ); + dump( tf.initial, ARRAYLEN(tf.initial) ); LOG->Trace(" "); Failed = true; } @@ -362,7 +362,7 @@ bool RunTests( SoundReader *snd, const TestFile &tf ) if( !Identical ) { LOG->Trace("Expected half second data:"); - dump( tf.later, ARRAYSIZE(tf.later) ); + dump( tf.later, ARRAYLEN(tf.later) ); LOG->Trace("Got half second data:"); dump( LaterData, 16 ); Failed = true;