From e26410526bbcd6b114ec39ade408f9496b801047 Mon Sep 17 00:00:00 2001 From: The Arrayser <68914060+TheArrayser@users.noreply.github.com> Date: Tue, 30 Aug 2022 13:36:47 +0200 Subject: [PATCH] debugged n tested --- System Abstraction/win32/cdb_thread.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/System Abstraction/win32/cdb_thread.c b/System Abstraction/win32/cdb_thread.c index a763569..e535704 100644 --- a/System Abstraction/win32/cdb_thread.c +++ b/System Abstraction/win32/cdb_thread.c @@ -1,12 +1,23 @@ #include "../cdb_sustem.h" #include -DWORD WINAPI threadProc(sus_threadProc proc){ - return proc(); +struct threadInfo{ + sus_threadProc proc; + void * args; +}; + +DWORD WINAPI threadProc(void * tiarg){ + struct threadInfo * ti = tiarg; + struct threadInfo currentTI = {.args = ti->args, .proc = ti->proc}; + sus_heapFree(ti); + return currentTI.proc(currentTI.args); } -sus_Bool sus_threadNew(sus_threadProc proc){ - if(CreateThread(NULL, 0, threadProc, proc, 0, NULL) == NULL){ +sus_Bool sus_threadNew(sus_threadProc proc, void * arg){ + struct threadInfo * ti = sus_heapAlloc(sizeof(struct threadInfo)); + ti->proc = proc; + ti->args = arg; + if(CreateThread(NULL, 0, threadProc, ti, 0, NULL) == NULL){ return sus_False; }else{ return sus_True;