summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-06-17 19:46:37 -0700
committerChris Robinson <[email protected]>2008-06-17 19:46:37 -0700
commit2d0b12e49ee7023a51da855f0878290ab3e7e9ad (patch)
treeed4afab9fa8e812db87ec0718a85198f9bfc5e1f
parent55e2f294ac5c4b65b739f0d2b6bf43f7b8bf9da7 (diff)
Store thread return value in the struct to avoid void*-to-uint casting
-rw-r--r--Alc/alcThread.c17
1 files 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