From 8ff6cfdda8be7659b06c18779dd2280685c83683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 28 Jun 2024 16:46:34 +0200 Subject: [PATCH] refactor: prevent a useless allocation (#895) * refactor: prevent a useless allocation * cs --- frankenphp.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/frankenphp.c b/frankenphp.c index 30860c79e..088f6997a 100644 --- a/frankenphp.c +++ b/frankenphp.c @@ -733,9 +733,7 @@ static void *manager_thread(void *arg) { exit(EXIT_FAILURE); } - int num_threads = *((int *)arg); - free(arg); - arg = NULL; + intptr_t num_threads = (intptr_t)arg; #ifdef ZTS #if (PHP_VERSION_ID >= 80300) @@ -796,11 +794,8 @@ static void *manager_thread(void *arg) { int frankenphp_init(int num_threads) { pthread_t thread; - int *num_threads_ptr = calloc(1, sizeof(int)); - *num_threads_ptr = num_threads; - - if (pthread_create(&thread, NULL, *manager_thread, (void *)num_threads_ptr) != - 0) { + if (pthread_create(&thread, NULL, *manager_thread, + (void *)(intptr_t)num_threads) != 0) { go_shutdown(); return -1;