From 2d0b12e49ee7023a51da855f0878290ab3e7e9ad Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 17 Jun 2008 19:46:37 -0700 Subject: [PATCH] Store thread return value in the struct to avoid void*-to-uint casting --- Alc/alcThread.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Alc/alcThread.c b/Alc/alcThread.c index 7db1c5dc..2d49a468 100644 --- a/Alc/alcThread.c +++ b/Alc/alcThread.c @@ -83,22 +83,21 @@ ALuint StopThread(ALvoid *thread) typedef struct { ALuint (*func)(ALvoid*); ALvoid *ptr; + ALuint ret; pthread_t thread; } ThreadInfo; static void *StarterFunc(void *ptr) { ThreadInfo *inf = (ThreadInfo*)ptr; - ALint ret; - - ret = inf->func(inf->ptr); - return (void*)ret; + inf->ret = inf->func(inf->ptr); + return NULL; } ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) { ThreadInfo *inf = malloc(sizeof(ThreadInfo)); - if(!inf) return 0; + if(!inf) return NULL; inf->func = func; inf->ptr = ptr; @@ -114,12 +113,14 @@ ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) ALuint StopThread(ALvoid *thread) { ThreadInfo *inf = thread; - void *ret; + ALuint ret; + + pthread_join(inf->thread, NULL); + ret = inf->ret; - pthread_join(inf->thread, &ret); free(inf); - return (ALuint)ret; + return ret; } #endif -- 2.11.4.GIT