From 742528d17955425e5b920136eb4e8fc0c6d1bc82 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Fri, 8 Sep 2023 13:33:51 +0200 Subject: refactor allocs: win32 --- source/kit/thread.win32.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/source/kit/thread.win32.c b/source/kit/thread.win32.c index c4b6f15..e7f84bf 100644 --- a/source/kit/thread.win32.c +++ b/source/kit/thread.win32.c @@ -65,10 +65,9 @@ Implementation limits: */ typedef struct { - thrd_start_t func; - void *arg; - thrd_t thrd; - kit_allocator_t alloc; + thrd_start_t func; + void *arg; + thrd_t thrd; } impl_thrd_param_t; struct thrd_state { @@ -85,7 +84,7 @@ static unsigned __stdcall impl_thrd_routine(void *p) { impl_current_thread.thrd = pack_p->thrd; impl_current_thread.handle_need_close = false; memcpy(&pack, pack_p, sizeof(impl_thrd_param_t)); - kit_alloc_dispatch(pack.alloc, KIT_DEALLOCATE, 0, 0, p); + kit_alloc_dispatch(NULL, KIT_DEALLOCATE, 0, 0, p); code = pack.func(pack.arg); return (unsigned) code; } @@ -273,20 +272,18 @@ int thrd_create_with_stack(thrd_t *thr, thrd_start_t func, void *arg, uintptr_t handle; assert(thr != NULL); assert(stack_size >= 0 && stack_size < 0x100000000); - kit_allocator_t alloc = kit_alloc_default(); pack = (impl_thrd_param_t *) kit_alloc_dispatch( - alloc, KIT_ALLOCATE, (sizeof(impl_thrd_param_t)), 0, NULL); + NULL, KIT_ALLOCATE, (sizeof(impl_thrd_param_t)), 0, NULL); if (!pack) return thrd_nomem; - pack->func = func; - pack->arg = arg; - pack->alloc = alloc; - handle = _beginthreadex(NULL, (unsigned) stack_size, - impl_thrd_routine, pack, CREATE_SUSPENDED, - NULL); + pack->func = func; + pack->arg = arg; + handle = _beginthreadex(NULL, (unsigned) stack_size, + impl_thrd_routine, pack, CREATE_SUSPENDED, + NULL); if (handle == 0) { - kit_alloc_dispatch(alloc, KIT_DEALLOCATE, 0, 0, pack); + kit_alloc_dispatch(NULL, KIT_DEALLOCATE, 0, 0, pack); if (errno == EAGAIN || errno == EACCES) return thrd_nomem; return thrd_error; -- cgit v1.2.3