From 650a8fb098006ec1c7feef3f825fca10e46897a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 4 Mar 2024 17:51:40 +0100 Subject: [PATCH] random: Embed the Mt19937 and CombinedLCG state within the module globals (#13579) These are always dynamically allocated in GINIT, thus always take up memory. By embedding them here we can avoid the dynamic allocation and additional pointer indirection accessing them. The test script: random_fd = -1; - - random_globals->combined_lcg = php_random_status_alloc(&php_random_algo_combinedlcg, true); - random_globals->combined_lcg_seeded = false; - - random_globals->mt19937 = php_random_status_alloc(&php_random_algo_mt19937, true); - random_globals->mt19937_seeded = false; } /* }}} */ @@ -631,12 +625,6 @@ static PHP_GSHUTDOWN_FUNCTION(random) close(random_globals->random_fd); random_globals->random_fd = -1; } - - php_random_status_free(random_globals->combined_lcg, true); - random_globals->combined_lcg = NULL; - - php_random_status_free(random_globals->mt19937, true); - random_globals->mt19937 = NULL; } /* }}} */