diff --git a/src/kits/game/GameSoundDevice.cpp b/src/kits/game/GameSoundDevice.cpp index abf9158a13..99a6be4c06 100644 --- a/src/kits/game/GameSoundDevice.cpp +++ b/src/kits/game/GameSoundDevice.cpp @@ -211,19 +211,12 @@ BGameSoundDevice::ReleaseBuffer(gs_id sound) status_t -BGameSoundDevice::Buffer(gs_id sound, - gs_audio_format * format, - void * data) +BGameSoundDevice::Buffer(gs_id sound, gs_audio_format* format, void *& data) { if (!format || sound <= 0) return B_BAD_VALUE; memcpy(format, &fSounds[sound-1]->Format(), sizeof(gs_audio_format)); - - // TODO: This is broken!!! - // here we leak the memory allocated by malloc, since data - // is not a reference nor a pointer to a pointer. - // The caller will never have the chance to access the allocated memory. if (fSounds[sound-1]->Data()) { data = malloc(format->buffer_size); memcpy(data, fSounds[sound-1]->Data(), format->buffer_size); diff --git a/src/kits/game/GameSoundDevice.h b/src/kits/game/GameSoundDevice.h index b768be8975..3a5d3c9410 100644 --- a/src/kits/game/GameSoundDevice.h +++ b/src/kits/game/GameSoundDevice.h @@ -29,27 +29,16 @@ #ifndef _GAMESOUNDDEVICE_H #define _GAMESOUNDDEVICE_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include -// Project Includes ------------------------------------------------------------ -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- class BMediaNode; class GameSoundBuffer; struct Connection; -// BGameSoundDevice ------------------------------------------------------------ -class BGameSoundDevice -{ +class BGameSoundDevice { public: - BGameSoundDevice(); + BGameSoundDevice(); virtual ~BGameSoundDevice(); status_t InitCheck() const; @@ -67,7 +56,7 @@ public: virtual status_t Buffer(gs_id sound, gs_audio_format * format, - void * data); + void *& data); virtual bool IsPlaying(gs_id sound); virtual status_t StartPlaying(gs_id sound);