debugged n tested

This commit is contained in:
The Arrayser 2022-08-30 13:36:47 +02:00 committed by GitHub
parent 25421a8571
commit e26410526b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,23 @@
#include "../cdb_sustem.h" #include "../cdb_sustem.h"
#include <windows.h> #include <windows.h>
DWORD WINAPI threadProc(sus_threadProc proc){ struct threadInfo{
return proc(); 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){ sus_Bool sus_threadNew(sus_threadProc proc, void * arg){
if(CreateThread(NULL, 0, threadProc, proc, 0, NULL) == NULL){ 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; return sus_False;
}else{ }else{
return sus_True; return sus_True;