Skip to content

Commit

Permalink
CHEWY: Plug memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Nov 13, 2016
1 parent a22e3bc commit 43438fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions backends/graphics/surfacesdl/surfacesdl-graphics.cpp
Expand Up @@ -345,7 +345,7 @@ OSystem::TransactionError SurfaceSdlGraphicsManager::endGFXTransaction() {
#if SDL_VERSION_ATLEAST(2, 0, 0)
} else if (_videoMode.filtering != _oldVideoMode.filtering) {
errors |= OSystem::kTransactionFilteringFailed;

_videoMode.filtering = _oldVideoMode.filtering;
#endif
#ifdef USE_RGB_COLOR
Expand Down Expand Up @@ -2350,7 +2350,7 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
internUpdateScreen();
return true;
}

#if SDL_VERSION_ATLEAST(2, 0, 0)
// Ctrl-Alt-f toggles filtering
if (key == 'f') {
Expand Down Expand Up @@ -2595,7 +2595,7 @@ void SurfaceSdlGraphicsManager::recreateScreenTexture() {
return;

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, _videoMode.filtering ? "linear" : "nearest");

SDL_Texture *oldTexture = _screenTexture;
_screenTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, _videoMode.hardwareWidth, _videoMode.hardwareHeight);
if (_screenTexture)
Expand Down Expand Up @@ -2627,7 +2627,7 @@ SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height,

SDL_GetWindowSize(_window->getSDLWindow(), &_windowWidth, &_windowHeight);
setWindowResolution(_windowWidth, _windowHeight);

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, _videoMode.filtering ? "linear" : "nearest");

_screenTexture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height);
Expand Down
3 changes: 3 additions & 0 deletions engines/chewy/graphics.cpp
Expand Up @@ -140,6 +140,9 @@ void Graphics::playVideo(uint num) {

g_system->getPaletteManager()->setPalette(curPalette, 0, 256);
_vm->_cursor->showCursor();

delete videoResource;
delete cfoDecoder;
}

} // End of namespace Chewy
4 changes: 3 additions & 1 deletion engines/chewy/sound.cpp
Expand Up @@ -100,7 +100,7 @@ void Sound::playMusic(int num, bool loop) {
uint32 musicNum = _soundRes->getChunkCount() - 1 - num;
Chunk *chunk = _soundRes->getChunk(musicNum);
byte *data = _soundRes->getChunkData(musicNum);

playMusic(data, chunk->size, loop);

delete[] data;
Expand Down Expand Up @@ -252,6 +252,8 @@ void Sound::convertTMFToMod(byte *tmfData, uint32 tmfSize, byte *modData, uint32
// TODO: 31 bytes instrument positions

// TODO: notes

free(modData);
}

} // End of namespace Chewy

0 comments on commit 43438fb

Please sign in to comment.