Skip to content

Commit

Permalink
refactor: prevent a useless allocation (#895)
Browse files Browse the repository at this point in the history
* refactor: prevent a useless allocation

* cs
  • Loading branch information
dunglas authored Jun 28, 2024
1 parent 952dd7a commit 8ff6cfd
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions frankenphp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8ff6cfd

Please sign in to comment.