Skip to content

Commit

Permalink
Update thread.c
Browse files Browse the repository at this point in the history
  • Loading branch information
recp authored May 16, 2019
1 parent 60dc0fa commit 93662d1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/win/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ static
DWORD
WINAPI
thread_entry(void *arg) {
tm_thread_entry entry;

/* to call free before calling thread func */
memcpy(&entry, arg, sizeof(entry));
free(arg);

entry.func(entry.arg);

tm_thread_entry entry;

/* to call free before calling thread func */
memcpy(&entry, arg, sizeof(entry));
free(arg);

entry.func(entry.arg);

return 0;
}

Expand All @@ -37,17 +37,17 @@ thread_new(void (*func)(void *), void *obj) {
tm_allocator *alc;
tm_thread *th;
tm_thread_entry *entry;


alc = tm_get_allocator();
th = alc->calloc(1, sizeof(*th));
entry = calloc(1, sizeof(*entry));
entry->func = func;


alc = tm_get_allocator();
th = alc->calloc(1, sizeof(*th));
entry = calloc(1, sizeof(*entry));
entry->func = func;
entry->arg = obj;

th->id = CreateThread(NULL, 0, thread_entry, entry, 0, NULL);
th->id = CreateThread(NULL, 0, thread_entry, entry, 0, NULL);

return th;
return th;
}

TM_HIDE
Expand Down

0 comments on commit 93662d1

Please sign in to comment.