mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Update CUtlMemoryPoolBase after 4/2/2024 update (#228)
Also updates tier0/tslist.h to sdk2013 variant and other minor stuff.
This commit is contained in:
@ -127,7 +127,7 @@ public:
|
||||
|
||||
virtual void PostReceivedNetMessage( INetworkSerializable *pNetMessage, const void *pData, const NetChannelBufType_t *pBufType, int nBits, int nInSequenceNr ) = 0;
|
||||
virtual void InsertReplayMessage( InstantReplayMessage_t &msg ) = 0;
|
||||
virtual bool HasQueuedPackets( int nMessageId ) const = 0;
|
||||
virtual bool HasQueuedNetMessages( int nMessageId ) const = 0;
|
||||
|
||||
virtual void SetPendingDisconnect( ENetworkDisconnectionReason reason ) = 0;
|
||||
virtual ENetworkDisconnectionReason GetPendingDisconnect( void ) const = 0;
|
||||
@ -135,10 +135,10 @@ public:
|
||||
virtual void SuppressTransmit( bool suppress ) = 0;
|
||||
virtual bool IsSuppressingTransmit( void ) const = 0;
|
||||
|
||||
virtual EResult SendMessage( const void *pData, uint32 cbData, int nSendFlags ) = 0;
|
||||
virtual EResult SendRawMessage( const void *pData, uint32 cbData, int nSendFlags ) = 0;
|
||||
|
||||
virtual int GetCurrentMessageBits( void ) const = 0;
|
||||
virtual int GetCurrentMessageInSequenceNr( void ) const = 0;
|
||||
virtual int GetCurrentNetMessageBits( void ) const = 0;
|
||||
virtual int GetCurrentNetMessageInSequenceNr( void ) const = 0;
|
||||
|
||||
virtual void unk101( void ) = 0;
|
||||
virtual void unk102( void ) = 0;
|
||||
|
@ -76,8 +76,8 @@ public:
|
||||
virtual void MarkEnumAsRequiringGlobalPromotion( const CSchemaEnumInfo* pEnumInfo ) = 0;
|
||||
|
||||
virtual void ResolveAtomicInfoThreadsafe( const SchemaAtomicTypeInfo_t** ppAtomicInfo, const char* pszAtomicName, int nAtomicID ) = 0;
|
||||
virtual void ResolveEnumInfoThreadsafe( const CSchemaEnumInfo** pEnumInfo, const char* pszEnumName ) = 0;
|
||||
virtual void ResolveClassInfoThreadsafe( const CSchemaClassInfo** pClassInfo, const char* pszClassName ) = 0;
|
||||
virtual void ResolveEnumInfoThreadsafe( const CSchemaEnumInfo** ppEnumInfo, const char* pszEnumName ) = 0;
|
||||
virtual void ResolveClassInfoThreadsafe( const CSchemaClassInfo** ppClassInfo, const char* pszClassName ) = 0;
|
||||
};
|
||||
|
||||
class CSchemaSystemTypeScope : public ISchemaSystemTypeScope
|
||||
|
@ -288,8 +288,10 @@ inline bool ThreadInterlockedAssignIf128( volatile int128 *pDest, const int128 &
|
||||
volatile int64 *pDest64 = ( volatile int64 * )pDest;
|
||||
int64 *pValue64 = ( int64 * )&value;
|
||||
int64 *pComperand64 = ( int64 * )&comperand;
|
||||
|
||||
int64 local_comperand[2] = { pComperand64[0], pComperand64[1] };
|
||||
|
||||
return _InterlockedCompareExchange128( pDest64, pValue64[1], pValue64[0], pComperand64 ) == 1;
|
||||
return _InterlockedCompareExchange128( pDest64, pValue64[1], pValue64[0], local_comperand ) == 1;
|
||||
}
|
||||
#else
|
||||
typedef __int128_t int128;
|
||||
@ -298,7 +300,10 @@ typedef __int128_t int128;
|
||||
inline bool ThreadInterlockedAssignIf128( volatile int128 *pDest, const int128 &value, const int128 &comperand )
|
||||
{
|
||||
Assert( (size_t)pDest % 16 == 0 );
|
||||
return __sync_bool_compare_and_swap( pDest, comperand, value );
|
||||
|
||||
int128 local_comperand = comperand;
|
||||
|
||||
return __sync_bool_compare_and_swap( pDest, local_comperand, value );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -153,6 +153,7 @@ public:
|
||||
// Returns NULL if they can't be made relative (on separate drives, for example)
|
||||
DLL_CLASS_IMPORT const char *MakeRelativePath(const char *pFullPath, const char *pDirectory);
|
||||
|
||||
// Copies data from pOther and then purges it
|
||||
DLL_CLASS_IMPORT void MoveFrom(CBufferString &pOther);
|
||||
|
||||
DLL_CLASS_IMPORT void Purge(int nLength);
|
||||
@ -242,7 +243,7 @@ public:
|
||||
{
|
||||
m_nAllocated |= ALLOW_HEAP_ALLOCATION;
|
||||
}
|
||||
MoveFrom(const_cast<CBufferStringGrowable&>(other));
|
||||
Insert(0, other.Get());
|
||||
}
|
||||
|
||||
~CBufferStringGrowable()
|
||||
@ -259,7 +260,8 @@ public:
|
||||
|
||||
inline CBufferStringGrowable& operator=(const CBufferStringGrowable& src)
|
||||
{
|
||||
MoveFrom(const_cast<CBufferStringGrowable&>(src));
|
||||
Clear();
|
||||
Insert(0, src.Get());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ enum MemoryPoolGrowType_t
|
||||
UTLMEMORYPOOL_GROW_NONE=0, // Don't allow new blobs.
|
||||
UTLMEMORYPOOL_GROW_FAST=1, // New blob size is numElements * (i+1) (ie: the blocks it allocates get larger and larger each time it allocates one).
|
||||
UTLMEMORYPOOL_GROW_SLOW=2, // New blob size is numElements.
|
||||
UTLMEMORYPOOL_GROW_RBTREE=3 // No blobs. All blocks are stored in RBTree.
|
||||
};
|
||||
|
||||
class CUtlMemoryPoolBase
|
||||
@ -51,22 +50,20 @@ public:
|
||||
DLL_CLASS_IMPORT void Free( void *pMem );
|
||||
|
||||
// Frees everything
|
||||
DLL_CLASS_IMPORT void Clear();
|
||||
|
||||
void Clear() { ClearDestruct( NULL ); }
|
||||
|
||||
// returns number of allocated blocks
|
||||
int Count() const { return m_BlocksAllocated; }
|
||||
int PeakCount() const { return m_PeakAlloc; }
|
||||
int BlockSize() const { return m_BlockSize; }
|
||||
int Size() const { return m_NumBlobs * m_BlocksPerBlob * m_BlockSize; }
|
||||
int Size() const { return m_TotalSize; }
|
||||
|
||||
DLL_CLASS_IMPORT bool IsAllocationWithinPool( void *pMem ) const;
|
||||
|
||||
protected:
|
||||
struct FreeList_t
|
||||
{
|
||||
FreeList_t *m_pNext;
|
||||
};
|
||||
DLL_CLASS_IMPORT void ClearDestruct( void (*)( void* ) );
|
||||
|
||||
private:
|
||||
class CBlob
|
||||
{
|
||||
public:
|
||||
@ -76,10 +73,8 @@ protected:
|
||||
char m_Padding[3]; // to int align the struct
|
||||
};
|
||||
|
||||
DLL_CLASS_IMPORT FreeList_t* AddNewBlob();
|
||||
DLL_CLASS_IMPORT void ResetAllocationCounts();
|
||||
DLL_CLASS_IMPORT void InternalClear( CBlob *blob, FreeList_t *free_list );
|
||||
DLL_CLASS_IMPORT void ClearDestruct( void (*)( void* ) );
|
||||
DLL_CLASS_IMPORT bool AddNewBlob();
|
||||
DLL_CLASS_IMPORT void ResetAllocationCounts();
|
||||
|
||||
int m_BlockSize;
|
||||
int m_BlocksPerBlob;
|
||||
@ -90,16 +85,15 @@ protected:
|
||||
CInterlockedInt m_PeakAlloc;
|
||||
unsigned short m_nAlignment;
|
||||
unsigned short m_NumBlobs;
|
||||
|
||||
FreeList_t** m_ppTailOfFreeList;
|
||||
FreeList_t* m_pHeadOfFreeList;
|
||||
|
||||
CBlob** m_ppBlobTail;
|
||||
CBlob* m_pBlobHead;
|
||||
|
||||
|
||||
CTSListBase m_FreeBlocks;
|
||||
|
||||
MemAllocAttribute_t m_AllocAttribute;
|
||||
|
||||
bool m_Unk1;
|
||||
|
||||
bool m_Unk1;
|
||||
CThreadMutex m_Mutex;
|
||||
CBlob* m_pBlobHead;
|
||||
int m_TotalSize;
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,6 +72,9 @@ public:
|
||||
// Number of elements
|
||||
unsigned int Count() const;
|
||||
|
||||
// Number of allocated slots
|
||||
I MaxElement() const;
|
||||
|
||||
// Checks if a node is valid and in the tree
|
||||
bool IsValidIndex( I i ) const;
|
||||
|
||||
@ -190,7 +193,15 @@ inline unsigned int CUtlDict<T, I, COMPARE_TYPE>::Count() const
|
||||
return m_Elements.Count();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Number of allocated slots
|
||||
//-----------------------------------------------------------------------------
|
||||
template <class T, class I, int COMPARE_TYPE>
|
||||
inline I CUtlDict<T, I, COMPARE_TYPE>::MaxElement() const
|
||||
{
|
||||
return m_Elements.MaxElement();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Checks if a node is valid and in the tree
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1796,10 +1796,7 @@ void CKeyValues3Context::CopyMetaData( KV3MetaData_t* pDest, const KV3MetaData_t
|
||||
|
||||
FOR_EACH_MAP_FAST( pSrc->m_Comments, iter )
|
||||
{
|
||||
CBufferStringGrowable<8> buff;
|
||||
buff.Insert( 0, pSrc->m_Comments[ iter ].Get() );
|
||||
|
||||
pDest->m_Comments.Insert( pSrc->m_Comments.Key( iter ), buff );
|
||||
pDest->m_Comments.Insert( pSrc->m_Comments.Key( iter ), pSrc->m_Comments.Element( iter ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user