While basic support for MSVCRT debugging has been added long
ago[1], the leak checking is not usable for the test suite, because we
are no longer calling `xmlCleanupParser()` on RSHUTDOWN of
ext/libxml[2], and therefore a few bogus leaks are reported whenever
ext/libxml is unloaded.
We therefore ignore memory leaks for this case. We introduce
`ZEND_IGNORE_LEAKS_BEGIN()` and `ZEND_IGNORE_LEAKS_END()` to keep
those ignores better readable, and also because these *might* be
useful for other leak checkers as well.
We also explicitly free the `zend_handlers_table` and the `p5s` to
avoid spurious leak reports.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=
d756e1db2324c1f4ab6f9b52e329959ce6a02bc3>
[2] <http://git.php.net/?p=php-src.git;a=commit;h=
8742276eb3905eb97a585417000c7b8df85006d4>
# define ZEND_PREFER_RELOAD
#endif
+#if defined(ZEND_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP)
+# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
+# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
+#else
+# define ZEND_IGNORE_LEAKS_BEGIN()
+# define ZEND_IGNORE_LEAKS_END()
+#endif
+
#endif /* ZEND_PORTABILITY_H */
static Bigint *freelist[Kmax+1];
static void destroy_freelist(void);
+static void free_p5s(void);
#ifdef ZTS
static MUTEX_T dtoa_mutex;
ZEND_API int zend_shutdown_strtod(void) /* {{{ */
{
destroy_freelist();
+ free_p5s();
+
#ifdef ZTS
tsrm_mutex_free(dtoa_mutex);
dtoa_mutex = NULL;
FREE_DTOA_LOCK(0)
}
+static void free_p5s(void)
+{
+ Bigint **listp, *tmp;
+
+ ACQUIRE_DTOA_LOCK(1)
+ listp = &p5s;
+ while ((tmp = *listp) != NULL) {
+ *listp = tmp->next;
+ free(tmp);
+ }
+ FREE_DTOA_LOCK(1)
+}
+
#ifdef __cplusplus
}
#endif
VM_TRACE_START();
}
+static HashTable *zend_handlers_table = NULL;
+
void zend_vm_dtor(void)
{
VM_TRACE_END();
+ if (zend_handlers_table) {
+ zend_hash_destroy(zend_handlers_table);
+ free(zend_handlers_table);
+ }
}
-static HashTable *zend_handlers_table = NULL;
-
static void init_opcode_serialiser(void)
{
int i;
VM_TRACE_START();
}
+static HashTable *zend_handlers_table = NULL;
+
void zend_vm_dtor(void)
{
VM_TRACE_END();
+ if (zend_handlers_table) {
+ zend_hash_destroy(zend_handlers_table);
+ free(zend_handlers_table);
+ }
}
-static HashTable *zend_handlers_table = NULL;
-
static void init_opcode_serialiser(void)
{
int i;
ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
}
PHP_INSTALL_HEADERS("ext/libxml/", "php_libxml.h");
+ if (PHP_CRT_DEBUG == "yes") {
+ ADD_FLAG("CFLAGS_LIBXML", "/D PHP_WIN32_DEBUG_HEAP");
+ }
} else {
WARNING("libxml support can't be enabled, iconv or libxml are missing")
PHP_LIBXML = "no"
{
if (!_php_libxml_initialized) {
/* we should be the only one's to ever init!! */
+ ZEND_IGNORE_LEAKS_BEGIN();
xmlInitParser();
+ ZEND_IGNORE_LEAKS_END();
_php_libxml_default_entity_loader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader);