Merge pull request #585 from turtleli/fix-broken-aligned-malloc

Fix AlignedMalloc on Windows
This commit is contained in:
Gregory Hainaut 2015-06-05 23:34:26 +02:00
commit 091f0d5ee9
1 changed files with 8 additions and 3 deletions

View File

@ -29,8 +29,9 @@ static const uint headsize = sizeof(AlignedMallocHeader);
void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align)
{
pxAssert( align < 0x10000 );
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
#ifdef _WIN32
return _aligned_malloc(size, align);
#elif defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
return aligned_alloc(align, size);
#else
void *result=0;
@ -48,12 +49,16 @@ void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align)
if( handle != NULL )
{
memcpy_fast( newbuf, handle, size );
free( handle );
pcsx2_aligned_free(handle);
}
return newbuf;
}
__fi void pcsx2_aligned_free(void* pmem)
{
#ifdef _WIN32
_aligned_free(pmem);
#elif
free(pmem);
#endif
}