Use UE4's memory management functions.

This fixes unexpected behavior on certain platforms for which
UE4 specifically limits the maximum allocation size of malloc
in favor of using optimized allocation schemes.
This commit is contained in:
Pieter Vantorre 2018-03-20 09:21:47 +01:00
parent 05d9372c0e
commit f89f3fad21

View File

@ -37,8 +37,26 @@ class FSpinePlugin : public SpinePlugin {
IMPLEMENT_MODULE( FSpinePlugin, SpinePlugin )
void FSpinePlugin::StartupModule() { }
// These should be filled with UE4's specific allocator functions.
extern "C" {
void _spSetMalloc( void* ( *_malloc ) ( size_t size ) );
void _spSetFree( void( *_free ) ( void* ptr ) );
void _spSetRealloc( void* ( *_realloc ) ( void* ptr, size_t size ) );
}
static void * SpineMalloc( size_t size ) {
return FMemory::Malloc( size );
}
static void * SpineRealloc( void* ptr, size_t size ) {
return FMemory::Realloc( ptr, size );
}
void FSpinePlugin::StartupModule() {
_spSetMalloc( &SpineMalloc );
_spSetRealloc( &SpineRealloc );
_spSetFree( FMemory::Free );
}
void FSpinePlugin::ShutdownModule() { }