Fix/workaround at least one class of buffer underruns in the GL plugin. Fix some bad deletes (instead of delete []). etc.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@404 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-08-31 13:36:52 +00:00
parent d9e129ae99
commit 09406d76c4
25 changed files with 117 additions and 69 deletions
-1
View File
@@ -60,7 +60,6 @@ bool CBoot::Boot_BIN(const std::string& _rFilename)
}
delete pFile;
return true;
}
+2 -1
View File
@@ -186,9 +186,9 @@ void Stop() // - Hammertime!
#endif
delete g_pThread; //Wait for emuthread to close
g_pThread = 0;
Core::StopTrace();
LogManager::Shutdown();
g_pThread = 0;
Host_SetWaitCursor(false);
}
@@ -360,6 +360,7 @@ THREAD_RETURN EmuThread(void *pArg)
if( g_pUpdateFPSDisplay != NULL )
g_pUpdateFPSDisplay("Stopping...");
delete cpuThread;
cpuThread = NULL;
// Returns after game exited
g_bHwInit = false;
@@ -106,6 +106,7 @@ CEXIMemoryCard::~CEXIMemoryCard()
{
Flush(true);
delete [] memory_card_content;
memory_card_content = NULL;
}
bool CEXIMemoryCard::IsPresent()
+2 -2
View File
@@ -354,7 +354,7 @@ void CCodeView::OnPaint(wxPaintEvent& event)
wxBrush rowBrush(wxColor(col >> 16, col >> 8, col));
dc.SetBrush(nullBrush);
dc.SetPen(nullPen);
dc.DrawRectangle(0, rowY1, 16, rowY2);
dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);
if (selecting && (address == selection))
{
@@ -374,7 +374,7 @@ void CCodeView::OnPaint(wxPaintEvent& event)
dc.SetBrush(rowBrush);
}
dc.DrawRectangle(16, rowY1, width, rowY2 - 1);
dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
dc.SetBrush(currentBrush);
dc.SetTextForeground(_T("#600000"));
dc.DrawText(temp, 17, rowY1);
+2 -1
View File
@@ -55,7 +55,8 @@ CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem)
CBannerLoaderGC::~CBannerLoaderGC()
{
delete[] m_pBannerFile;
delete [] m_pBannerFile;
m_pBannerFile = NULL;
}
+2 -1
View File
@@ -70,7 +70,8 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem)
CBannerLoaderWii::~CBannerLoaderWii()
{
delete m_pBuffer;
delete [] m_pBuffer;
m_pBuffer = NULL;
}
+1 -1
View File
@@ -42,7 +42,7 @@ CARCFile::CARCFile(const u8* _pBuffer, size_t _BufferSize)
CARCFile::~CARCFile()
{
delete m_pBuffer;
delete [] m_pBuffer;
}
@@ -36,7 +36,9 @@ CVolumeWiiCrypted::CVolumeWiiCrypted(IBlobReader* _pReader, u64 _VolumeOffset, c
CVolumeWiiCrypted::~CVolumeWiiCrypted()
{
delete m_pReader; // is this really our responsibility?
m_pReader = NULL;
delete[] m_pBuffer;
m_pBuffer = NULL;
}
+8 -2
View File
@@ -39,8 +39,14 @@ CMemcardManager::CMemcardManager(wxWindow* parent, wxWindowID id, const wxString
CMemcardManager::~CMemcardManager()
{
if(memoryCard[0]) delete memoryCard[0];
if(memoryCard[1]) delete memoryCard[1];
if (memoryCard[0]) {
delete memoryCard[0];
memoryCard[0] = NULL;
}
if (memoryCard[1]) {
delete memoryCard[1];
memoryCard[1] = NULL;
}
}
void CMemcardManager::CreateGUIControls()
@@ -117,8 +117,8 @@ bool GCMemcard::RemoveFile(u32 index) //index in the directory array
bat.LastAllocated[0] = u8(firstFree>>8);
bat.LastAllocated[1] = u8(firstFree);
delete mc_data;
mc_data=mc_data2;
delete [] mc_data;
mc_data = mc_data2;
//--
//update freespace counter
@@ -366,7 +366,7 @@ u32 GCMemcard::CopyFrom(GCMemcard& source, u32 index)
if(!source.GetFileData(index,t)) return 0;
u32 ret = ImportFile(d,t);
delete t;
delete[] t;
return ret;
}
+5
View File
@@ -78,6 +78,11 @@ u8 FAKE_ReadFifo8()
return videoBuffer[readptr++];
}
int FAKE_GetPosition()
{
return readptr;
}
u16 FAKE_ReadFifo16()
{
u16 val = Common::swap16(*(u16*)(videoBuffer+readptr));
@@ -43,7 +43,7 @@ void Mixer(short *buffer, int numSamples, int bits, int rate, int channels)
// silence
memset(buffer, 0, numSamples * 2 * sizeof(short));
// first get th DTK Music
// first get the DTK Music
if (g_Config.m_EnableDTKMusic)
{
g_dspInitialize.pGetAudioStreaming(buffer, numSamples);
@@ -111,6 +111,7 @@ CReBarSettings::~CReBarSettings()
if (m_pBands != NULL)
{
delete[] m_pBands;
m_pBands = NULL;
}
}
@@ -120,6 +121,7 @@ bool CReBarSettings::Load(LPCTSTR szRegKey, LPCTSTR szPrefix, HKEY hkRootKey /*
if (m_pBands != NULL)
{
delete[] m_pBands;
m_pBands = NULL;
}
m_pBands = NULL;
@@ -22,13 +22,13 @@ void DecodedVArray::Zero()
posMtxInds = 0;
for (int i=0; i<3; i++)
normals[i] = 0;
for (int i=0; i<2; i++)
colors[i] = 0;
for (int i=0; i<8; i++)
{
texMtxInds[i] = 0;
uvs[i] = 0;
}
for (int i=0; i<2; i++)
colors[i] = 0;
}
void DecodedVArray::Destroy()
@@ -97,9 +97,9 @@ bool FifoCommandRunnable(void)
{
u32 iBufferSize = FAKE_GetFifoSize();
if (iBufferSize == 0)
return false;
return false; // can't peek
u8 Cmd = PeekFifo8(0);
u8 Cmd = PeekFifo8(0);
u32 iCommandSize = 0;
switch(Cmd)
@@ -362,12 +362,6 @@ void OpcodeDecoder_Shutdown()
void OpcodeDecoder_Run()
{
// just a small check
if (g_pDataReader != &g_fifoReader)
{
MessageBox(NULL, "very strange", "video-plugin", MB_OK);
}
DVSTARTPROFILE();
while (FifoCommandRunnable())
@@ -51,12 +51,7 @@ void VertexLoader::SetVArray(DecodedVArray *_varray)
{
varray = _varray;
}
/*
inline u8 ReadBuffer8() { return fifo.Read8(); }
inline u16 ReadBuffer16() { return fifo.Read16(); }
inline u32 ReadBuffer32() { return fifo.Read32(); }
inline float ReadBuffer32F() { return fifo.Read32F(); }
*/
inline u8 ReadBuffer8()
{
return g_pDataReader->Read8();
@@ -120,7 +115,7 @@ void VertexLoader::Setup()
{
m_PipelineStates[m_numPipelineStates++] = PosMtx_ReadDirect_UByte;
m_VertexSize += 1;
m_components |= VB_HAS_POSMTXIDX;
m_components |= VB_HAS_POSMTXIDX;
}
// Texture matrix indices
@@ -195,7 +190,7 @@ void VertexLoader::Setup()
}
WriteCall(pFunc);
m_VertexSize += uSize;
int m_numNormals = (m_VtxAttr.NormalElements==1) ? NRM_THREE : NRM_ONE;
int m_numNormals = (m_VtxAttr.NormalElements == 1) ? NRM_THREE : NRM_ONE;
m_components |= VB_HAS_NRM0;
if (m_numNormals == NRM_THREE)
m_components |= VB_HAS_NRM1 | VB_HAS_NRM2;
@@ -135,7 +135,7 @@ public:
void SetVAT_group0(u32 _group0)
{
if (!m_AttrDirty && m_group0.Hex == _group0)
if (m_group0.Hex == _group0)
return;
m_AttrDirty = true;
m_group0.Hex = _group0;
@@ -59,6 +59,7 @@ void _SetCol565(u16 val)
col |= lut5to8[(val )&0x1f] << BSHIFT;
_SetCol(col | (0xFF<<ASHIFT));
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
inline u32 _Read24(u32 iAddress)
@@ -112,7 +113,7 @@ void LOADERDECL Color_ReadDirect_24b_6666(void* _p)
_SetCol6666(val);
}
// F|RES: i am not 100 percent show, but the colElements seems to be important for rendering only
// F|RES: i am not 100 percent sure, but the colElements seems to be important for rendering only
// at least it fixes mario party 4
//
// if (colElements[colIndex])
@@ -128,7 +129,7 @@ void LOADERDECL Color_ReadDirect_32b_8888(void* _p)
// "kill" the alpha
if (!colElements[colIndex])
col |= 0xFF<<ASHIFT;
col |= 0xFF << ASHIFT;
_SetCol(col);
}
@@ -26,6 +26,7 @@ IDataReader* g_pDataReader = NULL;
extern u8 FAKE_ReadFifo8();
extern u16 FAKE_ReadFifo16();
extern u32 FAKE_ReadFifo32();
extern int FAKE_GetPosition();
extern void FAKE_SkipFifo(u32 skip);
CDataReader_Fifo::CDataReader_Fifo(void)
@@ -53,6 +54,12 @@ void CDataReader_Fifo::Skip(u32 skip)
return FAKE_SkipFifo(skip);
}
int CDataReader_Fifo::GetPosition()
{
return FAKE_GetPosition();
}
// =================================================================================================
// CDataReader_Memory
// =================================================================================================
@@ -64,26 +71,31 @@ CDataReader_Memory::CDataReader_Memory(u32 _uAddress) :
m_szName = "CDataReader_Memory";
}
u32 CDataReader_Memory::GetReadAddress(void)
u32 CDataReader_Memory::GetReadAddress()
{
return m_uReadAddress;
}
u8 CDataReader_Memory::Read8(void)
int CDataReader_Memory::GetPosition()
{
return m_uReadAddress;
}
u8 CDataReader_Memory::Read8()
{
u8 tmp = Memory_Read_U8(m_uReadAddress);//m_pMemory[m_uReadAddress];
m_uReadAddress++;
return tmp;
}
u16 CDataReader_Memory::Read16(void)
u16 CDataReader_Memory::Read16()
{
u16 tmp = Memory_Read_U16(m_uReadAddress);//_byteswap_ushort(*(u16*)&m_pMemory[m_uReadAddress]);
m_uReadAddress += 2;
return tmp;
}
u32 CDataReader_Memory::Read32(void)
u32 CDataReader_Memory::Read32()
{
u32 tmp = Memory_Read_U32(m_uReadAddress);//_byteswap_ulong(*(u32*)&m_pMemory[m_uReadAddress]);
m_uReadAddress += 4;
+15 -11
View File
@@ -29,9 +29,11 @@ protected:
public:
virtual void Skip(u32) = 0;
virtual u8 Read8 (void) = 0;
virtual u16 Read16(void) = 0;
virtual u32 Read32(void) = 0;
virtual u8 Read8 () = 0;
virtual u16 Read16() = 0;
virtual u32 Read32() = 0;
virtual int GetPosition() = 0; // return values can be anything, as long as relative distances are correct
};
// =================================================================================================
@@ -43,12 +45,13 @@ class CDataReader_Fifo : public IDataReader
private:
public:
CDataReader_Fifo(void);
CDataReader_Fifo();
virtual void Skip(u32);
virtual u8 Read8(void);
virtual u16 Read16(void);
virtual u32 Read32(void);
virtual u8 Read8();
virtual u16 Read16();
virtual u32 Read32();
virtual int GetPosition();
};
// =================================================================================================
@@ -66,12 +69,13 @@ public:
CDataReader_Memory(u32 _uAddress);
u32 GetReadAddress(void);
u32 GetReadAddress();
virtual void Skip(u32);
virtual u8 Read8(void);
virtual u16 Read16(void);
virtual u32 Read32(void);
virtual u8 Read8();
virtual u16 Read16();
virtual u32 Read32();
virtual int GetPosition();
};
extern IDataReader* g_pDataReader;

Some files were not shown because too many files have changed in this diff Show More