summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2020-03-31 23:18:25 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2020-05-04 13:53:11 +0200
commit9fa3200cb366c726f7c8ef234282603bb9e8816d (patch)
tree6d1fda0dcbe3d4394c09397ff7cd4c4fc1a0248e
parente4fb36841800038c289997432ca547c9bfef9db1 (diff)
downloadlibxml2-9fa3200cb366c726f7c8ef234282603bb9e8816d.tar.gz
Call xmlCleanupParser on ELF destruction
Fixes #153.
-rw-r--r--configure.ac10
-rw-r--r--parser.c11
2 files changed, 20 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 09418af2..5f95fee0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -641,6 +641,16 @@ else
[Type cast for the send() function 2nd arg])
fi
+dnl Checking whether __attribute__((destructor)) is accepted by the compiler
+AC_MSG_CHECKING([whether __attribute__((destructor)) is accepted])
+AC_TRY_COMPILE2([
+void __attribute__((destructor))
+f(void) {}], [], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ATTRIBUTE_DESTRUCTOR], [1],[Define if __attribute__((destructor)) is accepted])],[
+ AC_MSG_RESULT(no)])
+
+
dnl ***********************Checking for availability of IPv6*******************
AC_MSG_CHECKING([whether to enable IPv6])
diff --git a/parser.c b/parser.c
index 072eb22d..4ea8e84b 100644
--- a/parser.c
+++ b/parser.c
@@ -14599,7 +14599,7 @@ xmlInitParser(void) {
if (xmlParserInitialized != 0)
return;
-#if defined(WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#if defined(_WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
atexit(xmlCleanupParser);
#endif
@@ -14681,6 +14681,15 @@ xmlCleanupParser(void) {
xmlParserInitialized = 0;
}
+#if defined(ATTRIBUTE_DESTRUCTOR) && !defined(LIBXML_STATIC) && \
+ !defined(_WIN32)
+static void
+__attribute__((destructor))
+xmlDestructor(void) {
+ xmlCleanupParser();
+}
+#endif
+
/************************************************************************
* *
* New set (2.6.0) of simpler and more flexible APIs *