mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-27 14:08:00 +03:00
Fixed memory leak with hintmessage. (#581)
Fixed memory leak with hintmessage.
This commit is contained in:
parent
99954a2646
commit
519b7db38d
@ -15,10 +15,7 @@ CHintMessage::CHintMessage(const char *hintString, bool isHint, CUtlVector<const
|
||||
|
||||
CHintMessage::~CHintMessage()
|
||||
{
|
||||
for (int i = 0; i < m_args.Count(); i++)
|
||||
delete[] m_args[i];
|
||||
|
||||
m_args.RemoveAll();
|
||||
m_args.PurgeAndDeleteArrays();
|
||||
}
|
||||
|
||||
void CHintMessage::Send(CBaseEntity *client)
|
||||
@ -29,11 +26,7 @@ void CHintMessage::Send(CBaseEntity *client)
|
||||
void CHintMessageQueue::Reset()
|
||||
{
|
||||
m_tmMessageEnd = 0;
|
||||
|
||||
for (int i = 0; i < m_messages.Count(); i++)
|
||||
delete m_messages[i];
|
||||
|
||||
m_messages.RemoveAll();
|
||||
m_messages.PurgeAndDeleteElements();
|
||||
}
|
||||
|
||||
void CHintMessageQueue::Update(CBaseEntity *client)
|
||||
|
@ -99,6 +99,7 @@ void CBasePlayer::OnDestroy()
|
||||
delete[] m_rebuyString;
|
||||
m_rebuyString = nullptr;
|
||||
}
|
||||
m_hintMessageQueue.Reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
|
||||
// Purges the list and calls delete on each element in it.
|
||||
void PurgeAndDeleteElements();
|
||||
void PurgeAndDeleteArrays();
|
||||
|
||||
// Set the size by which it grows when it needs to allocate more memory.
|
||||
void SetGrowSize(int size);
|
||||
@ -547,6 +548,15 @@ inline void CUtlVector<T>::PurgeAndDeleteElements()
|
||||
Purge();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void CUtlVector<T>::PurgeAndDeleteArrays()
|
||||
{
|
||||
for (int i = 0; i < m_Size; i++)
|
||||
delete[] Element(i);
|
||||
|
||||
Purge();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CUtlVector<T>::SetGrowSize(int size)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user