diff --git a/linux_sdk/Makefile.tier1 b/linux_sdk/Makefile.tier1 index fac93119..20c0c818 100644 --- a/linux_sdk/Makefile.tier1 +++ b/linux_sdk/Makefile.tier1 @@ -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 \ diff --git a/public/tier0/memalloc.h b/public/tier0/memalloc.h index 9de95fcf..032b5fc0 100644 --- a/public/tier0/memalloc.h +++ b/public/tier0/memalloc.h @@ -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 diff --git a/public/tier1/utlmemory.h b/public/tier1/utlmemory.h index a55f571e..511101de 100644 --- a/public/tier1/utlmemory.h +++ b/public/tier1/utlmemory.h @@ -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::CUtlMemoryAligned( int nGrowSize, int nInitAll { UTLMEMORY_TRACK_ALLOC(); MEM_ALLOC_CREDIT_CLASS(); - CUtlMemory::m_pMemory = (T*)_aligned_malloc( nInitAllocationCount * sizeof(T), nAlignment ); - } + CUtlMemory::m_pMemory = (T*)ALIGNED_MALLOC( nInitAllocationCount * sizeof(T), nAlignment ); + } } template< class T, int nAlignment > @@ -863,7 +871,7 @@ void CUtlMemoryAligned::Grow( int num ) else { MEM_ALLOC_CREDIT_CLASS(); - CUtlMemory::m_pMemory = (T*)_aligned_malloc( CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment ); + CUtlMemory::m_pMemory = (T*)ALIGNED_MALLOC( CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment ); Assert( CUtlMemory::m_pMemory ); } } @@ -899,7 +907,7 @@ inline void CUtlMemoryAligned::EnsureCapacity( int num ) else { MEM_ALLOC_CREDIT_CLASS(); - CUtlMemory::m_pMemory = (T*)_aligned_malloc( CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment ); + CUtlMemory::m_pMemory = (T*)ALIGNED_MALLOC( CUtlMemory::m_nAllocationCount * sizeof(T), nAlignment ); } } diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index 18b1c220..561bc649 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -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; }