mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-01-04 00:23:25 +08:00
Fix SDK issues with NO_MALLOC_OVERRIDE (bug 5521).
This commit is contained in:
parent
0a57c2d8aa
commit
1cf728f9a1
@ -42,7 +42,6 @@ LIB_OBJS= \
|
||||
$(LIB_OBJ_DIR)/interface.o \
|
||||
$(LIB_OBJ_DIR)/KeyValues.o \
|
||||
$(LIB_OBJ_DIR)/mempool.o \
|
||||
$(LIB_OBJ_DIR)/memstack.o \
|
||||
$(LIB_OBJ_DIR)/NetAdr.o \
|
||||
$(LIB_OBJ_DIR)/newbitbuf.o \
|
||||
$(LIB_OBJ_DIR)/processor_detect.o \
|
||||
|
@ -349,6 +349,7 @@ struct MemAllocFileLine_t
|
||||
#define MEM_ALLOC_CREDIT() MEM_ALLOC_CREDIT_(__FILE__)
|
||||
#define MEM_ALLOC_CREDIT_CLASS()
|
||||
#define MEM_ALLOC_CLASSNAME(type) NULL
|
||||
#define MEM_ALLOC_CREDIT_FUNCTION()
|
||||
|
||||
#endif // !STEAM && NO_MALLOC_OVERRIDE
|
||||
|
||||
|
@ -37,6 +37,14 @@
|
||||
#define UTLMEMORY_TRACK_FREE() ((void)0)
|
||||
#endif
|
||||
|
||||
#if defined(_LINUX) || defined(__APPLE__)
|
||||
#define ALIGNED_MALLOC( size, alignment ) \
|
||||
memalign( alignment, size )
|
||||
#else
|
||||
#define ALIGNED_MALLOC( size, alignment ) \
|
||||
_aligned_malloc( size, alignment )
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// The CUtlMemory class:
|
||||
@ -768,8 +776,8 @@ CUtlMemoryAligned<T, nAlignment>::CUtlMemoryAligned( int nGrowSize, int nInitAll
|
||||
{
|
||||
UTLMEMORY_TRACK_ALLOC();
|
||||
MEM_ALLOC_CREDIT_CLASS();
|
||||
CUtlMemory<T>::m_pMemory = (T*)_aligned_malloc( nInitAllocationCount * sizeof(T), nAlignment );
|
||||
}
|
||||
CUtlMemory<T>::m_pMemory = (T*)ALIGNED_MALLOC( nInitAllocationCount * sizeof(T), nAlignment );
|
||||
}
|
||||
}
|
||||
|
||||
template< class T, int nAlignment >
|
||||
@ -863,7 +871,7 @@ void CUtlMemoryAligned<T, nAlignment>::Grow( int num )
|
||||
else
|
||||
{
|
||||
MEM_ALLOC_CREDIT_CLASS();
|
||||
CUtlMemory<T>::m_pMemory = (T*)_aligned_malloc( CUtlMemory<T>::m_nAllocationCount * sizeof(T), nAlignment );
|
||||
CUtlMemory<T>::m_pMemory = (T*)ALIGNED_MALLOC( CUtlMemory<T>::m_nAllocationCount * sizeof(T), nAlignment );
|
||||
Assert( CUtlMemory<T>::m_pMemory );
|
||||
}
|
||||
}
|
||||
@ -899,7 +907,7 @@ inline void CUtlMemoryAligned<T, nAlignment>::EnsureCapacity( int num )
|
||||
else
|
||||
{
|
||||
MEM_ALLOC_CREDIT_CLASS();
|
||||
CUtlMemory<T>::m_pMemory = (T*)_aligned_malloc( CUtlMemory<T>::m_nAllocationCount * sizeof(T), nAlignment );
|
||||
CUtlMemory<T>::m_pMemory = (T*)ALIGNED_MALLOC( CUtlMemory<T>::m_nAllocationCount * sizeof(T), nAlignment );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2348,9 +2348,13 @@ void *KeyValues::operator new( size_t iAllocSize )
|
||||
|
||||
void *KeyValues::operator new( size_t iAllocSize, int nBlockUse, const char *pFileName, int nLine )
|
||||
{
|
||||
#ifndef NO_MALLOC_OVERRIDE
|
||||
MemAlloc_PushAllocDbgInfo( pFileName, nLine );
|
||||
#endif
|
||||
void *p = KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize);
|
||||
#ifndef NO_MALLOC_OVERRIDE
|
||||
MemAlloc_PopAllocDbgInfo();
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user