diff options
author | rubidium <rubidium@openttd.org> | 2007-01-10 18:56:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-10 18:56:51 +0000 |
commit | a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7 (patch) | |
tree | 1a1c59c13ddb1d152052f3a3a0bcffe4fb531173 /src/thread.cpp | |
parent | ce75f6549dd379b506c9f1e9383bd881aa7cf5c7 (diff) | |
download | openttd-a7d0cdf95fd8847ab76b35446e1c9b77f8ef1cb7.tar.xz |
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
Diffstat (limited to 'src/thread.cpp')
-rw-r--r-- | src/thread.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/thread.cpp b/src/thread.cpp index ab2cfd21d..233c4ecb6 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -3,6 +3,7 @@ #include "stdafx.h" #include "thread.h" #include <stdlib.h> +#include "helpers.hpp" #if defined(__AMIGA__) || defined(__MORPHOS__) || defined(NO_THREADS) OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) { return NULL; } @@ -24,20 +25,21 @@ struct OTTDThread { static void Proxy(void* arg) { - OTTDThread* t = arg; + OTTDThread* t = (OTTDThread*)arg; t->ret = t->func(t->arg); } OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg) { - OTTDThread* t = malloc(sizeof(*t)); + OTTDThread* t; + MallocT(&t, 1); if (t == NULL) return NULL; t->func = function; t->arg = arg; t->thread = _beginthread(Proxy, NULL, 32768, t); - if (t->thread != -1) { + if (t->thread != (TID)-1) { return t; } else { free(t); @@ -72,7 +74,8 @@ struct OTTDThread { OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg) { - OTTDThread* t = malloc(sizeof(*t)); + OTTDThread* t; + MallocT(&t, 1); if (t == NULL) return NULL; @@ -113,14 +116,15 @@ struct OTTDThread { static DWORD WINAPI Proxy(LPVOID arg) { - OTTDThread* t = arg; + OTTDThread* t = (OTTDThread*)arg; t->ret = t->func(t->arg); return 0; } OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void* arg) { - OTTDThread* t = malloc(sizeof(*t)); + OTTDThread* t; + MallocT(&t, 1); DWORD dwThreadId; if (t == NULL) return NULL; |