diff --git a/AerofoilX/GpSystemServices_X.cpp b/AerofoilX/GpSystemServices_X.cpp index 32e0f8f..fbcb8d9 100644 --- a/AerofoilX/GpSystemServices_X.cpp +++ b/AerofoilX/GpSystemServices_X.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include struct GpSystemServices_X_ThreadStartParams { @@ -52,13 +54,19 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) if (!evt) return nullptr; + pthread_t *threadPtr = static_cast(malloc(sizeof(pthread_t))); + if (!threadPtr) + { + evt->Destroy(); + return nullptr; + } + GpSystemServices_X_ThreadStartParams startParams; startParams.m_threadContext = context; startParams.m_threadFunc = threadFunc; startParams.m_threadStartEvent = evt; - pthread_t thread = nullptr; - if (pthread_create(&thread, nullptr, StaticStartThread, &startParams) != 0) + if (pthread_create(threadPtr, nullptr, StaticStartThread, &startParams) != 0) { evt->Destroy(); return nullptr; @@ -67,7 +75,7 @@ void *GpSystemServices_X::CreateThread(ThreadFunc_t threadFunc, void *context) evt->Wait(); evt->Destroy(); - return thread; + return static_cast(threadPtr); } bool GpSystemServices_X::Beep() const