summaryrefslogtreecommitdiff
path: root/sapi/cli/php_cli.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-05-20 18:53:40 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-06-10 09:05:17 +0200
commit68dd6cc92b81cc2253cdfcdc53823ad6527d2e05 (patch)
tree68f5b226b06e50f0a29ead8cc5ec337a3d51865a /sapi/cli/php_cli.c
parentc1887974ccbf00f4c5a4950480eb53cf75c153a0 (diff)
downloadphp-git-68dd6cc92b81cc2253cdfcdc53823ad6527d2e05.tar.gz
Control VCRT leak reporting via environment variable in debug builds
Formerly, this had to be enabled by passing the configuration flag `--enable-crt-debug`; now it can be enabled by setting the environment variable `PHP_WIN32_DEBUG_HEAP`. The advantage is that it is no longer necessary to do separate builds, at the cost of a very minor performance penalty during process startup.
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r--sapi/cli/php_cli.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index a9069c6191..dfda90fb8e 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1184,20 +1184,23 @@ int main(int argc, char *argv[])
cli_sapi_module.additional_functions = additional_functions;
-#if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP)
+#if defined(PHP_WIN32) && defined(_DEBUG)
{
- int tmp_flag;
- _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
- tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
- tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
-
- _CrtSetDbgFlag(tmp_flag);
+ char *tmp = getenv("PHP_WIN32_DEBUG_HEAP");
+ if (tmp && zend_atoi(tmp, 0)) {
+ int tmp_flag;
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+ tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
+ tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
+
+ _CrtSetDbgFlag(tmp_flag);
+ }
}
#endif