-cleaned up code more, set clear priority to alloc in which

memory region
This commit is contained in:
fix94.1 2012-05-12 21:08:43 +00:00
parent d669a1a17e
commit 49a31c4f25
22 changed files with 43 additions and 69 deletions

View File

@ -81,7 +81,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <ctype.h>
#include "MD5.h"

View File

@ -26,7 +26,6 @@
* for wiiflow 2010
***************************************************************************/
#include <malloc.h>
#include <ogcsys.h>
#include <string.h>
#include <stdio.h>

View File

@ -14,7 +14,6 @@
******************************************************************************/
#include <gccore.h>
#include <malloc.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

View File

@ -29,7 +29,6 @@
#include <stdio.h>
#include <ogcsys.h>
#include <malloc.h>
#include <string.h>
#include <cstdlib>
#include <stdarg.h>

View File

@ -2,7 +2,6 @@
#define _NAND_H_
#include <gccore.h>
#include <malloc.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

View File

@ -23,7 +23,7 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <malloc.h>
#include <unistd.h>
#include <string.h>
#include <ogc/mutex.h>

View File

@ -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)

View File

@ -9,7 +9,6 @@ More info : http://frontier-dev.net
********************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "pngu.h"
#include "png.h"

View File

@ -1,3 +1,6 @@
#include <ogc/machine/processor.h>
#include "DeviceHandler.hpp"
#include "wdvd.h"
#include "disc.h"
@ -6,10 +9,6 @@
#include "alt_ios.h"
#include "sys.h"
#include "wbfs.h"
#include <malloc.h>
#include <ogc/machine/processor.h>
#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)
{
DeviceHandler::Instance()->MountAll();
DeviceHandler::Instance()->Open_WBFS(currentPartition);
Disc_Init();
}
else Open_Inputs();
else
Open_Inputs();
return iosOK;
}

View File

@ -24,7 +24,6 @@
* distribution.
***************************************************************************/
#include <gctypes.h>
#include <malloc.h>
#include <cstdio>

View File

@ -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);

View File

@ -1,7 +1,6 @@
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <ogcsys.h>
#include <dirent.h>
#include <sys/types.h>

View File

@ -3,7 +3,6 @@
#include <stdio.h>
#include <unistd.h>
#include <malloc.h>
#include <ogcsys.h>
#include <dirent.h>
#include <sys/types.h>

View File

@ -1,7 +1,9 @@
#include <gccore.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#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;
}

View File

@ -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));

View File

@ -23,9 +23,8 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <malloc.h>
#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;
}

View File

@ -27,9 +27,10 @@
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <malloc.h>
#include <math.h>
#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)

View File

@ -24,7 +24,6 @@
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#include "OggDecoder.hpp"
extern "C" int ogg_read(void * punt, int bytes, int blocks, int *f)

View File

@ -26,7 +26,6 @@
* for WiiXplorer 2010
***************************************************************************/
#include <gccore.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include "SoundDecoder.hpp"

View File

@ -24,7 +24,6 @@
* for WiiXplorer 2010
***************************************************************************/
#include <unistd.h>
#include <malloc.h>
#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");

View File

@ -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;
}
@ -480,7 +480,7 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
if(isallocated)
{
void *p = (void *)snd;
SAFE_FREE(p);
MEM2_free(p);
}
allocated = true;

View File

@ -32,7 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include "ZipFile.h"
#include "miniunz.h"