From 12b14d5f92e2bee0fda9fe490c89d489d746ede4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 2 Mar 2024 20:41:20 +0100 Subject: [PATCH] random: Embed the Mt19937 and CombinedLCG state within the module globals 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; } /* }}} */