From 2319107fbd5563e5adc5ea2095461e770c28b393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 28 Jun 2024 15:04:49 +0200 Subject: [PATCH 1/2] refactor: prevent a useless allocation --- frankenphp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frankenphp.c b/frankenphp.c index 30860c79e..86272fbf3 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,10 +794,7 @@ 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) != + if (pthread_create(&thread, NULL, *manager_thread, (void *)(intptr_t)num_threads) != 0) { go_shutdown(); From 3d19a3335035ee66b7fe6d5ddeb99266a2689926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 28 Jun 2024 16:22:44 +0200 Subject: [PATCH 2/2] cs --- frankenphp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frankenphp.c b/frankenphp.c index 86272fbf3..088f6997a 100644 --- a/frankenphp.c +++ b/frankenphp.c @@ -733,7 +733,7 @@ static void *manager_thread(void *arg) { exit(EXIT_FAILURE); } - intptr_t num_threads = (intptr_t) arg; + intptr_t num_threads = (intptr_t)arg; #ifdef ZTS #if (PHP_VERSION_ID >= 80300) @@ -794,8 +794,8 @@ static void *manager_thread(void *arg) { int frankenphp_init(int num_threads) { pthread_t thread; - if (pthread_create(&thread, NULL, *manager_thread, (void *)(intptr_t)num_threads) != - 0) { + if (pthread_create(&thread, NULL, *manager_thread, + (void *)(intptr_t)num_threads) != 0) { go_shutdown(); return -1;