diff --git a/source/channel/MD5.c b/source/channel/MD5.c index 21092629..95aee2c3 100644 --- a/source/channel/MD5.c +++ b/source/channel/MD5.c @@ -81,7 +81,6 @@ #include #include #include -#include #include #include "MD5.h" diff --git a/source/channel/banner.cpp b/source/channel/banner.cpp index 2acfcbcd..ece22d36 100644 --- a/source/channel/banner.cpp +++ b/source/channel/banner.cpp @@ -26,7 +26,6 @@ * for wiiflow 2010 ***************************************************************************/ -#include #include #include #include diff --git a/source/channel/lz77.c b/source/channel/lz77.c index 951fbf02..7bc0f255 100644 --- a/source/channel/lz77.c +++ b/source/channel/lz77.c @@ -14,7 +14,6 @@ ******************************************************************************/ #include -#include #include #include #include diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 5050fec3..d68d9607 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/source/channel/nand.hpp b/source/channel/nand.hpp index daf9c910..2456a0b3 100644 --- a/source/channel/nand.hpp +++ b/source/channel/nand.hpp @@ -2,7 +2,6 @@ #define _NAND_H_ #include -#include #include #include #include diff --git a/source/devicemounter/DeviceHandler.cpp b/source/devicemounter/DeviceHandler.cpp index a36705e7..0b561cbf 100644 --- a/source/devicemounter/DeviceHandler.cpp +++ b/source/devicemounter/DeviceHandler.cpp @@ -23,7 +23,7 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include + #include #include #include diff --git a/source/gui/WiiMovie.cpp b/source/gui/WiiMovie.cpp index 7019b0ab..3cfcfb6a 100644 --- a/source/gui/WiiMovie.cpp +++ b/source/gui/WiiMovie.cpp @@ -32,6 +32,7 @@ #include "WiiMovie.hpp" #include "musicplayer.h" #include "gecko.h" +#include "mem2.hpp" #define SND_BUFFERS 8 #define FRAME_BUFFERS 8 @@ -75,7 +76,7 @@ WiiMovie::WiiMovie(const char * filepath) } PlayThreadStack = NULL; - ThreadStack = (u8 *) memalign(32, 32768); + ThreadStack = (u8 *)MEM2_alloc(32768); if (!ThreadStack) return; @@ -111,7 +112,7 @@ WiiMovie::~WiiMovie() } if (ThreadStack != NULL) { - SAFE_FREE(ThreadStack); + MEM2_free(ThreadStack); ThreadStack = NULL; } @@ -129,7 +130,7 @@ bool WiiMovie::Play(bool loop) gprintf("Start playing video\n"); - PlayThreadStack = (u8 *) memalign(32, 32768); + PlayThreadStack = (u8 *)MEM2_alloc(32768); if (PlayThreadStack == NULL) return false; Playing = true; @@ -156,7 +157,7 @@ void WiiMovie::Stop() PlayThread = LWP_THREAD_NULL; gprintf("Playing thread stopped\n"); - SAFE_FREE(PlayThreadStack); + MEM2_free(PlayThreadStack); } void WiiMovie::SetVolume(int vol) diff --git a/source/gui/pngu.c b/source/gui/pngu.c index 483e6a04..102081f1 100644 --- a/source/gui/pngu.c +++ b/source/gui/pngu.c @@ -9,7 +9,6 @@ More info : http://frontier-dev.net ********************************************************************************************/ #include #include -#include #include "pngu.h" #include "png.h" diff --git a/source/loader/alt_ios.cpp b/source/loader/alt_ios.cpp index a64e4fd2..86b796ed 100644 --- a/source/loader/alt_ios.cpp +++ b/source/loader/alt_ios.cpp @@ -1,3 +1,6 @@ + +#include + #include "DeviceHandler.hpp" #include "wdvd.h" #include "disc.h" @@ -6,10 +9,6 @@ #include "alt_ios.h" #include "sys.h" #include "wbfs.h" - -#include -#include - #include "gecko.h" extern "C" {extern u8 currentPartition;} @@ -77,37 +76,18 @@ bool loadIOS(int ios, bool launch_game) WDVD_Close(); USBStorage_Deinit(); - //gprintf("AHBPROT state before reloading: %s\n", HAVE_AHBPROT ? "enabled" : "disabled"); - //IOSPATCH_AHBPROT(); - -/* void *backup = MEM1_alloc(0x200000); // 0x126CA0 bytes were needed last time i checked. But take more just in case. - if (backup != 0) - { - memcpy(backup, &__Arena2Lo, 0x200000); - DCFlushRange(backup, 0x200000); - } */ - bool iosOK = IOS_ReloadIOS(ios) == 0; -/* if (backup != 0) - { - memcpy(&__Arena2Lo, backup, 0x200000); - DCFlushRange(&__Arena2Lo, 0x200000); - free(backup); - } */ - gprintf("%s, Current IOS: %i\n", iosOK ? "OK" : "FAILED!", IOS_GetVersion()); - //IOSPATCH_AHBPROT(); - //gprintf("Current AHBPROT state: %s\n", HAVE_AHBPROT ? "enabled" : "disabled"); - - if (launch_game) + if(launch_game) { DeviceHandler::Instance()->MountAll(); DeviceHandler::Instance()->Open_WBFS(currentPartition); Disc_Init(); } - else Open_Inputs(); + else + Open_Inputs(); return iosOK; -} \ No newline at end of file +} diff --git a/source/loader/cios.cpp b/source/loader/cios.cpp index a1b70413..908bd850 100644 --- a/source/loader/cios.cpp +++ b/source/loader/cios.cpp @@ -24,7 +24,6 @@ * distribution. ***************************************************************************/ - #include #include #include @@ -100,4 +99,4 @@ iosinfo_t *cIOSInfo::GetInfo(u8 ios) SAFE_FREE(buffer); return iosinfo; -} \ No newline at end of file +} diff --git a/source/loader/frag.c b/source/loader/frag.c index c6926f6f..f56b603f 100644 --- a/source/loader/frag.c +++ b/source/loader/frag.c @@ -277,7 +277,8 @@ out: int set_frag_list(u8 *id) { - if (frag_list == NULL) return -2; + if (frag_list == NULL) + return -2; // (+1 for header which is same size as fragment) int size = sizeof(Fragment) * (frag_list->num + 1); @@ -289,10 +290,11 @@ int set_frag_list(u8 *id) int ret = WDVD_SetFragList(wbfsDev, frag_list, size); - free(frag_list); + MEM2_free(frag_list); frag_list = NULL; - if (ret) return ret; + if(ret) + return ret; // verify id matches char discid[32] ATTRIBUTE_ALIGN(32); diff --git a/source/loader/wbfs.c b/source/loader/wbfs.c index a157de61..495cc323 100644 --- a/source/loader/wbfs.c +++ b/source/loader/wbfs.c @@ -1,7 +1,6 @@ #include #include -#include #include #include #include diff --git a/source/loader/wbfs_ext.c b/source/loader/wbfs_ext.c index e3be493f..027aa8bc 100644 --- a/source/loader/wbfs_ext.c +++ b/source/loader/wbfs_ext.c @@ -3,7 +3,6 @@ #include #include -#include #include #include #include diff --git a/source/loader/wip.c b/source/loader/wip.c index ee3706fe..19ff418c 100644 --- a/source/loader/wip.c +++ b/source/loader/wip.c @@ -1,7 +1,9 @@ + #include #include #include #include +#include "mem2.hpp" #include "utils.h" //SAFE_CLOSE #include "gecko.h" @@ -106,12 +108,13 @@ int load_wip_patches(u8 *dir, u8 *gameid) u32 srcaddress = (u32) strtoul(line+9, NULL, 16); u32 dstaddress = (u32) strtoul(line+18, NULL, 16); - if(!CodeList) CodeList = malloc(sizeof(WIP_Code)); + if(!CodeList) + CodeList = MEM2_alloc(sizeof(WIP_Code)); - WIP_Code * tmp = realloc(CodeList, (CodesCount+1)*sizeof(WIP_Code)); + WIP_Code *tmp = MEM2_realloc(CodeList, (CodesCount+1)*sizeof(WIP_Code)); if(!tmp) { - SAFE_FREE(CodeList); + MEM2_free(CodeList); SAFE_CLOSE(fp); return -1; } diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index d84331ef..b68323ce 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -1039,7 +1039,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) struct gc_discHdr *gcHeader = (struct gc_discHdr *)MEM2_alloc(sizeof(struct gc_discHdr)); Disc_ReadGCHeader(gcHeader); memcpy(hdr->hdr.id, gcHeader->id, 6); - SAFE_FREE(gcHeader); + MEM2_free(gcHeader); /* Launching GC Game */ _launchGC(hdr, false); } @@ -1050,7 +1050,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) Disc_ReadHeader(header); for (int i = 0;i < 6; i++) id[i] = header->id[i]; - SAFE_FREE(header); + MEM2_free(header); } bool vipatch = m_gcfg2.testOptBool(id, "vipatch", m_cfg.getBool("GENERAL", "vipatch", false)); bool cheat = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool("GAMES", "cheat", false)); diff --git a/source/music/BufferCircle.cpp b/source/music/BufferCircle.cpp index caf20053..da0ec5a4 100644 --- a/source/music/BufferCircle.cpp +++ b/source/music/BufferCircle.cpp @@ -23,9 +23,8 @@ * * for WiiXplorer 2010 ***************************************************************************/ -#include +#include "mem2.hpp" #include "BufferCircle.hpp" -#include "utils.h" BufferCircle::BufferCircle() { @@ -50,9 +49,9 @@ void BufferCircle::SetBufferBlockSize(int size) for(int i = 0; i < Size(); i++) { - SAFE_FREE(SoundBuffer[i]); + MEM1_free(SoundBuffer[i]); - SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize)); + SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize); BufferSize[i] = 0; BufferReady[i] = false; } @@ -72,7 +71,7 @@ void BufferCircle::Resize(int size) for(int i = oldSize; i < Size(); i++) { if(BufferBlockSize > 0) - SoundBuffer[i] = (u8 *) memalign(32, ALIGN32(BufferBlockSize)); + SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize); else SoundBuffer[i] = NULL; BufferSize[i] = 0; @@ -85,7 +84,7 @@ void BufferCircle::RemoveBuffer(int pos) if(!Valid(pos)) return; - SAFE_FREE(SoundBuffer[pos]); + MEM1_free(SoundBuffer[pos]); SoundBuffer.erase(SoundBuffer.begin()+pos); BufferSize.erase(BufferSize.begin()+pos); @@ -106,7 +105,7 @@ void BufferCircle::FreeBuffer() { for(int i = 0; i < Size(); i++) { - SAFE_FREE(SoundBuffer[i]); + MEM1_free(SoundBuffer[i]); BufferSize[i] = 0; BufferReady[i] = false; } diff --git a/source/music/Mp3Decoder.cpp b/source/music/Mp3Decoder.cpp index 03a8d0a6..8edf90fb 100644 --- a/source/music/Mp3Decoder.cpp +++ b/source/music/Mp3Decoder.cpp @@ -27,9 +27,10 @@ #include #include #include -#include #include + #include "Mp3Decoder.hpp" +#include "mem2.hpp" Mp3Decoder::Mp3Decoder(const char * filepath) : SoundDecoder(filepath) @@ -73,13 +74,13 @@ Mp3Decoder::~Mp3Decoder() mad_frame_finish(&Frame); mad_stream_finish(&Stream); - SAFE_FREE(ReadBuffer); + MEM2_free(ReadBuffer); } void Mp3Decoder::OpenFile() { GuardPtr = NULL; - ReadBuffer = (u8 *) memalign(32, SoundBlockSize*SoundBlocks); + ReadBuffer = (u8 *)MEM2_alloc(SoundBlockSize * SoundBlocks); if(!ReadBuffer) { if(file_fd) diff --git a/source/music/OggDecoder.cpp b/source/music/OggDecoder.cpp index d0ae1abe..bbcec771 100644 --- a/source/music/OggDecoder.cpp +++ b/source/music/OggDecoder.cpp @@ -24,7 +24,6 @@ * for WiiXplorer 2010 ***************************************************************************/ #include -#include #include "OggDecoder.hpp" extern "C" int ogg_read(void * punt, int bytes, int blocks, int *f) diff --git a/source/music/SoundDecoder.cpp b/source/music/SoundDecoder.cpp index ccb53a07..91b65b10 100644 --- a/source/music/SoundDecoder.cpp +++ b/source/music/SoundDecoder.cpp @@ -26,7 +26,6 @@ * for WiiXplorer 2010 ***************************************************************************/ #include -#include #include #include #include "SoundDecoder.hpp" diff --git a/source/music/SoundHandler.cpp b/source/music/SoundHandler.cpp index 3531a201..517e77c3 100644 --- a/source/music/SoundHandler.cpp +++ b/source/music/SoundHandler.cpp @@ -24,7 +24,6 @@ * for WiiXplorer 2010 ***************************************************************************/ #include -#include #include "SoundHandler.hpp" #include "Mp3Decoder.hpp" #include "OggDecoder.hpp" @@ -33,6 +32,7 @@ #include "BNSDecoder.hpp" #include "gecko/gecko.h" +#include "mem2.hpp" SoundHandler * SoundHandler::instance = NULL; @@ -43,7 +43,7 @@ SoundHandler::SoundHandler() for(u32 i = 0; i < MAX_DECODERS; ++i) DecoderList[i] = NULL; - ThreadStack = (u8 *) memalign(32, 32768); + ThreadStack = (u8 *)MEM1_memalign(32, 32768); if(!ThreadStack) return; @@ -59,7 +59,7 @@ SoundHandler::~SoundHandler() ThreadSignal(); LWP_JoinThread(SoundThread, NULL); SoundThread = LWP_THREAD_NULL; - SAFE_FREE(ThreadStack); + MEM1_free(ThreadStack); ClearDecoderList(); gprintf("SHND: Stopped sound thread\n"); diff --git a/source/music/gui_sound.cpp b/source/music/gui_sound.cpp index 4fd4fbd6..4de4994e 100644 --- a/source/music/gui_sound.cpp +++ b/source/music/gui_sound.cpp @@ -245,7 +245,7 @@ bool GuiSound::LoadSoundEffect(const u8 * snd, u32 len) u8 * tmpsnd = (u8 *)MEM2_realloc(sound, done+4096); if(!tmpsnd) { - SAFE_FREE(sound); + MEM2_free(sound); return false; } @@ -479,8 +479,8 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated) if(isallocated) { - void *p = (void *) snd; - SAFE_FREE(p); + void *p = (void *)snd; + MEM2_free(p); } allocated = true; diff --git a/source/unzip/ZipFile.cpp b/source/unzip/ZipFile.cpp index 9c8abc55..e7c2bbd3 100644 --- a/source/unzip/ZipFile.cpp +++ b/source/unzip/ZipFile.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include "ZipFile.h" #include "miniunz.h"