mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-12-07 02:28:22 +00:00
Better fix for posix _aligned_malloc in utlmemory, fixing mac support.
This commit is contained in:
parent
eebf58324d
commit
7d37bfc976
@ -38,11 +38,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_LINUX) || defined(__APPLE__)
|
#if defined(_LINUX) || defined(__APPLE__)
|
||||||
#define ALIGNED_MALLOC( size, alignment ) \
|
inline void *_aligned_malloc( size_t size, size_t alignment )
|
||||||
memalign( alignment, size )
|
{
|
||||||
#else
|
void *pTemp;
|
||||||
#define ALIGNED_MALLOC( size, alignment ) \
|
posix_memalign( &pTemp, alignment, size );
|
||||||
_aligned_malloc( size, alignment )
|
return pTemp;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -776,7 +777,7 @@ CUtlMemoryAligned<T, nAlignment>::CUtlMemoryAligned( int nGrowSize, int nInitAll
|
|||||||
{
|
{
|
||||||
UTLMEMORY_TRACK_ALLOC();
|
UTLMEMORY_TRACK_ALLOC();
|
||||||
MEM_ALLOC_CREDIT_CLASS();
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,7 +872,7 @@ void CUtlMemoryAligned<T, nAlignment>::Grow( int num )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MEM_ALLOC_CREDIT_CLASS();
|
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 );
|
Assert( CUtlMemory<T>::m_pMemory );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -907,7 +908,7 @@ inline void CUtlMemoryAligned<T, nAlignment>::EnsureCapacity( int num )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
MEM_ALLOC_CREDIT_CLASS();
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user