[Debugger] Fix symbols memory leak
This commit is contained in:
parent
37beacbe09
commit
a2427459cb
|
@ -27,15 +27,8 @@ CSymbolTable::CSymbolTable(CDebuggerUI* debugger) :
|
||||||
|
|
||||||
CSymbolTable::~CSymbolTable()
|
CSymbolTable::~CSymbolTable()
|
||||||
{
|
{
|
||||||
if (m_SymFileBuffer != NULL)
|
delete[] m_SymFileBuffer;
|
||||||
{
|
delete[] m_SymFileParseBuffer;
|
||||||
free(m_SymFileBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_SymFileParseBuffer != NULL)
|
|
||||||
{
|
|
||||||
free(m_SymFileParseBuffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol_type_info_t CSymbolTable::m_SymbolTypes[] = {
|
symbol_type_info_t CSymbolTable::m_SymbolTypes[] = {
|
||||||
|
@ -108,23 +101,6 @@ CPath CSymbolTable::GetSymFilePath()
|
||||||
return symFilePath;
|
return symFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSymbolTable::ParserInit()
|
|
||||||
{
|
|
||||||
if (m_SymFileParseBuffer != NULL)
|
|
||||||
{
|
|
||||||
free(m_SymFileParseBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_SymFileParseBuffer = (char*)malloc(m_SymFileSize + 1);
|
|
||||||
strcpy(m_SymFileParseBuffer, m_SymFileBuffer);
|
|
||||||
m_bHaveFirstToken = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSymbolTable::ParserDone()
|
|
||||||
{
|
|
||||||
free(m_SymFileParseBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSymbolTable::ParserFetchToken(const char* delim)
|
void CSymbolTable::ParserFetchToken(const char* delim)
|
||||||
{
|
{
|
||||||
if (!m_bHaveFirstToken)
|
if (!m_bHaveFirstToken)
|
||||||
|
@ -172,17 +148,29 @@ void CSymbolTable::Load()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_SymFileBuffer != NULL)
|
||||||
|
{
|
||||||
|
delete[] m_SymFileBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_SymFileParseBuffer != NULL)
|
||||||
|
{
|
||||||
|
delete[] m_SymFileParseBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
m_SymFileSize = m_SymFileHandle.GetLength();
|
m_SymFileSize = m_SymFileHandle.GetLength();
|
||||||
m_SymFileBuffer = (char*)malloc(m_SymFileSize + 1);
|
m_SymFileBuffer = new char[m_SymFileSize + 1];
|
||||||
|
m_SymFileParseBuffer = new char[m_SymFileSize + 1];
|
||||||
m_SymFileHandle.Read(m_SymFileBuffer, m_SymFileSize);
|
m_SymFileHandle.Read(m_SymFileBuffer, m_SymFileSize);
|
||||||
m_SymFileHandle.Close();
|
m_SymFileHandle.Close();
|
||||||
m_SymFileBuffer[m_SymFileSize] = '\0';
|
m_SymFileBuffer[m_SymFileSize] = '\0';
|
||||||
|
|
||||||
|
strcpy(m_SymFileParseBuffer, m_SymFileBuffer);
|
||||||
|
m_bHaveFirstToken = false;
|
||||||
|
|
||||||
symbol_parse_error_t errorCode = ERR_SUCCESS;
|
symbol_parse_error_t errorCode = ERR_SUCCESS;
|
||||||
int lineNumber = 1;
|
int lineNumber = 1;
|
||||||
|
|
||||||
ParserInit();
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
uint32_t address = 0;
|
uint32_t address = 0;
|
||||||
|
@ -254,8 +242,11 @@ void CSymbolTable::Load()
|
||||||
lineNumber++;
|
lineNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserDone();
|
delete[] m_SymFileParseBuffer;
|
||||||
free(m_SymFileBuffer);
|
m_SymFileParseBuffer = NULL;
|
||||||
|
|
||||||
|
delete[] m_SymFileBuffer;
|
||||||
|
m_SymFileBuffer = NULL;
|
||||||
|
|
||||||
switch (errorCode)
|
switch (errorCode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,8 +69,6 @@ private:
|
||||||
char* m_SymFileParseBuffer;
|
char* m_SymFileParseBuffer;
|
||||||
bool m_bHaveFirstToken;
|
bool m_bHaveFirstToken;
|
||||||
|
|
||||||
void ParserInit();
|
|
||||||
void ParserDone();
|
|
||||||
void ParserFetchToken(const char* delim);
|
void ParserFetchToken(const char* delim);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue