mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 12:06:07 +08:00
Copy CUtlStringList from sdk2013 (#238)
Fixes mismatched delete on CUtlStringList usage.
This commit is contained in:
@ -435,7 +435,9 @@ bool V_StrSubst( const char *pIn, const char *pMatch, const char *pReplaceWith,
|
||||
char *pOut, int outLen, bool bCaseSensitive=false );
|
||||
|
||||
|
||||
// Split the specified string on the specified separator.
|
||||
// If possible, use CSplitString instead
|
||||
// AM TODO: These are exported by tier0, but will require changes to CUtlVector
|
||||
// Split the specified string on the specified separator.
|
||||
// Returns a list of strings separated by pSeparator.
|
||||
// You are responsible for freeing the contents of outStrings (call outStrings.PurgeAndDeleteElements).
|
||||
void V_SplitString( const char *pString, const char *pSeparator, CUtlVector<char*, CUtlMemory<char*, int> > &outStrings );
|
||||
|
@ -1161,6 +1161,11 @@ public:
|
||||
class CUtlStringList : public CUtlVectorAutoPurge< char *>
|
||||
{
|
||||
public:
|
||||
~CUtlStringList()
|
||||
{
|
||||
PurgeAndDeleteElements();
|
||||
}
|
||||
|
||||
void CopyAndAddToTail( char const *pString ) // clone the string and add to the end
|
||||
{
|
||||
char *pNewStr = new char[1 + strlen( pString )];
|
||||
@ -1173,6 +1178,14 @@ public:
|
||||
return strcmp( *sz1, *sz2 );
|
||||
}
|
||||
|
||||
inline void PurgeAndDeleteElements()
|
||||
{
|
||||
for( int i = 0; i < m_Size; i++ )
|
||||
{
|
||||
delete[] Element(i);
|
||||
}
|
||||
Purge();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user