From 3171a9716012b5f548a49ab26a55fa217c4c77f7 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 22 Feb 2021 20:21:12 -0800 Subject: [PATCH] Replace all SDL_RWFromMem() with SDL_RWFromConstMem() Since we're not going to be writing to any of these RWops, we might as well just ensure that we don't by using SDL_RWFromConstMem(). --- desktop_version/src/Music.cpp | 6 +++--- desktop_version/src/SoundSystem.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 8823aef1..7121b676 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -92,7 +92,7 @@ void musicclass::init(void) index = blob.getIndex(track_name); \ if (index >= 0 && index < blob.max_headers) \ { \ - rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \ + rw = SDL_RWFromConstMem(blob.getAddress(index), blob.getSize(index)); \ if (rw == NULL) \ { \ printf("Unable to read music file header: %s\n", SDL_GetError()); \ @@ -110,7 +110,7 @@ void musicclass::init(void) size_t index_ = 0; while (mmmmmm_blob.nextExtra(&index_)) { - rw = SDL_RWFromMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_)); + rw = SDL_RWFromConstMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_)); musicTracks.push_back(MusicTrack( rw )); num_mmmmmm_tracks++; @@ -133,7 +133,7 @@ void musicclass::init(void) size_t index_ = 0; while (pppppp_blob.nextExtra(&index_)) { - rw = SDL_RWFromMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_)); + rw = SDL_RWFromConstMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_)); musicTracks.push_back(MusicTrack( rw )); num_pppppp_tracks++; diff --git a/desktop_version/src/SoundSystem.cpp b/desktop_version/src/SoundSystem.cpp index f3ad5f5b..7459b650 100644 --- a/desktop_version/src/SoundSystem.cpp +++ b/desktop_version/src/SoundSystem.cpp @@ -38,7 +38,7 @@ SoundTrack::SoundTrack(const char* fileName) fprintf(stderr, "Unable to load WAV file %s\n", fileName); return; } - SDL_RWops *fileIn = SDL_RWFromMem(mem, length); + SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length); sound = Mix_LoadWAV_RW(fileIn, 1); FILESYSTEM_freeMemory(&mem);