medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 4ea87b3494ef8f043189f5e6b0944e5c34b1a217
parent 66f19612ada06f252536dcf4b8b04b2bc36116da
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Feb 10 19:39:02 +0200

Remove zero_struct as it's easy to misuse

Diffstat:
intrinsics.h | 5-----
launcher/main.cc | 2+-
win32_audio_output.cc | 6++----
3 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/intrinsics.h b/intrinsics.h @@ -171,11 +171,6 @@ inline To checked_cast( const From & from ) { } template< typename T > -inline void zero_struct( T * x ) { - memset( x, 0, sizeof( T ) ); -} - -template< typename T > inline bool is_aligned( const T * ptr ) { return checked_cast< size_t >( ptr ) % alignof( T ) == 0; } diff --git a/launcher/main.cc b/launcher/main.cc @@ -86,7 +86,7 @@ static bool operator!=( const Version & a, const Version & b ) { static bool parse_version( Version * v, const char * str ) { int fields = sscanf( str, "%u.%u.%u.%u", &v->a, &v->b, &v->c, &v->d ); if( fields != 4 ) { - zero_struct( v ); + v = { }; return false; } return true; diff --git a/win32_audio_output.cc b/win32_audio_output.cc @@ -84,8 +84,7 @@ static THREAD( audio_output_thread ) { device->callback( buffers[ buffer_idx ], ARRAY_COUNT( buffers[ buffer_idx ] ) ); - XAUDIO2_BUFFER buf; - zero_struct( &buf ); + XAUDIO2_BUFFER buf = { }; buf.AudioBytes = sizeof( buffers[ buffer_idx ] ); buf.pAudioData = ( const BYTE * ) buffers[ buffer_idx ]; buf.pContext = device->event; @@ -101,8 +100,7 @@ static THREAD( audio_output_thread ) { } void audio_output_open( AudioOutputDevice * device, AudioOutputCallback callback ) { - WAVEFORMATEX format; - zero_struct( &format ); + WAVEFORMATEX format = { }; format.wFormatTag = WAVE_FORMAT_PCM; format.nChannels = 1; format.nSamplesPerSec = 44100;