mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
fixed memory leak in console
This commit is contained in:
parent
b8e997f99e
commit
80fac31175
|
@ -840,6 +840,19 @@ CConsole::CConsole(int FlagMask)
|
||||||
m_Cheated = false;
|
m_Cheated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CConsole::~CConsole()
|
||||||
|
{
|
||||||
|
CCommand *pCommand = m_pFirstCommand;
|
||||||
|
while(pCommand)
|
||||||
|
{
|
||||||
|
CCommand *pNext = pCommand->m_pNext;
|
||||||
|
if(pCommand->m_pfnCallback == Con_Chain)
|
||||||
|
mem_free(static_cast<CChain *>(pCommand->m_pUserData));
|
||||||
|
delete pCommand;
|
||||||
|
pCommand = pNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CConsole::ParseArguments(int NumArgs, const char **ppArguments)
|
void CConsole::ParseArguments(int NumArgs, const char **ppArguments)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < NumArgs; i++)
|
for(int i = 0; i < NumArgs; i++)
|
||||||
|
@ -895,7 +908,7 @@ void CConsole::Register(const char *pName, const char *pParams,
|
||||||
bool DoAdd = false;
|
bool DoAdd = false;
|
||||||
if(pCommand == 0)
|
if(pCommand == 0)
|
||||||
{
|
{
|
||||||
pCommand = new(mem_alloc(sizeof(CCommand), sizeof(void*))) CCommand;
|
pCommand = new CCommand();
|
||||||
DoAdd = true;
|
DoAdd = true;
|
||||||
}
|
}
|
||||||
pCommand->m_pfnCallback = pfnFunc;
|
pCommand->m_pfnCallback = pfnFunc;
|
||||||
|
|
|
@ -180,6 +180,7 @@ class CConsole : public IConsole
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CConsole(int FlagMask);
|
CConsole(int FlagMask);
|
||||||
|
~CConsole();
|
||||||
|
|
||||||
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int FlagMask) const;
|
virtual const CCommandInfo *FirstCommandInfo(int AccessLevel, int FlagMask) const;
|
||||||
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp);
|
virtual const CCommandInfo *GetCommandInfo(const char *pName, int FlagMask, bool Temp);
|
||||||
|
|
Loading…
Reference in a new issue