From 240ba88f5342e6301fa5baea184353ab754350a2 Mon Sep 17 00:00:00 2001 From: elasota Date: Fri, 14 May 2021 19:30:31 -0400 Subject: [PATCH] Fix Android crash --- AerofoilAndroid/app/jni/main/GpMain_SDL_Android.cpp | 5 +++++ AerofoilPortable/Android.mk | 1 + AerofoilPortable/GpAllocator_C.cpp | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AerofoilAndroid/app/jni/main/GpMain_SDL_Android.cpp b/AerofoilAndroid/app/jni/main/GpMain_SDL_Android.cpp index 157fe93e..5e1a193e 100644 --- a/AerofoilAndroid/app/jni/main/GpMain_SDL_Android.cpp +++ b/AerofoilAndroid/app/jni/main/GpMain_SDL_Android.cpp @@ -1,6 +1,7 @@ #include "SDL.h" #include "GpMain.h" +#include "GpAllocator_C.h" #include "GpAudioDriverFactory.h" #include "GpDisplayDriverFactory.h" #include "GpGlobalConfig.h" @@ -70,6 +71,8 @@ GpLogDriver_Android GpLogDriver_Android::ms_instance; int main(int argc, char* argv[]) { + IGpAllocator *alloc = GpAllocator_C::GetInstance(); + SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO); if (SDL_Init(SDL_INIT_VIDEO) < 0) @@ -83,6 +86,7 @@ int main(int argc, char* argv[]) drivers->SetDriver(GpFileSystem_Android::GetInstance()); drivers->SetDriver(GpSystemServices_Android::GetInstance()); drivers->SetDriver(GpLogDriver_Android::GetInstance()); + drivers->SetDriver(alloc); g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2; @@ -96,6 +100,7 @@ int main(int argc, char* argv[]) g_gpGlobalConfig.m_osGlobals = &g_gpAndroidGlobals; g_gpGlobalConfig.m_logger = GpLogDriver_Android::GetInstance(); g_gpGlobalConfig.m_systemServices = GpSystemServices_Android::GetInstance(); + g_gpGlobalConfig.m_allocator = alloc; GpDisplayDriverFactory::RegisterDisplayDriverFactory(EGpDisplayDriverType_SDL_GL2, GpDriver_CreateDisplayDriver_SDL_GL2); GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL); diff --git a/AerofoilPortable/Android.mk b/AerofoilPortable/Android.mk index acc8f470..eb38edab 100644 --- a/AerofoilPortable/Android.mk +++ b/AerofoilPortable/Android.mk @@ -14,6 +14,7 @@ LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0 # Add your application source files here... LOCAL_SRC_FILES := \ + GpAllocator_C.cpp \ GpThreadEvent_Cpp11.cpp \ GpSystemServices_POSIX.cpp diff --git a/AerofoilPortable/GpAllocator_C.cpp b/AerofoilPortable/GpAllocator_C.cpp index 247bfb51..e34be515 100644 --- a/AerofoilPortable/GpAllocator_C.cpp +++ b/AerofoilPortable/GpAllocator_C.cpp @@ -104,7 +104,7 @@ void GpAllocator_C::Free(void *buf) const GpAllocator_C_MMBlock *mmBlock = reinterpret_cast(bytes - GpAllocator_C_MMBlock::AlignedSize()); void *freeLoc = bytes - GpAllocator_C_MMBlock::AlignedSize() - mmBlock->m_offsetFromAllocLocation; - realloc(freeLoc, 0); + (void)realloc(freeLoc, 0); } GpAllocator_C *GpAllocator_C::GetInstance()