__xmlGlobalInitMutexDestroy() will free global_init_lock on Win32. Patch
* globals.c threads.c include/libxml/threads.h:
__xmlGlobalInitMutexDestroy() will free global_init_lock on Win32.
Patch from Marc-Antoine Ruel.
svn path=/trunk/; revision=3664
diff --git a/ChangeLog b/ChangeLog
index 68cdf58..ec3511c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Nov 16 11:55:36 CET 2007 Rob Richards <rrichards@ctindustries.net>
+
+ * globals.c threads.c include/libxml/threads.h:
+ __xmlGlobalInitMutexDestroy() will free global_init_lock on Win32.
+ Patch from Marc-Antoine Ruel.
+
Tue Nov 13 21:26:27 CET 2007 Rob Richards <rrichards@ctindustries.net>
* schematron.c: fix crash/leaks from xmlSchematronParse due to improper
diff --git a/globals.c b/globals.c
index c104a1a..636ff87 100644
--- a/globals.c
+++ b/globals.c
@@ -60,6 +60,7 @@
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
+ __xmlGlobalInitMutexDestroy();
}
/************************************************************************
diff --git a/libxml.h b/libxml.h
index f5c6394..3c44c83 100644
--- a/libxml.h
+++ b/libxml.h
@@ -77,6 +77,7 @@
*/
void __xmlGlobalInitMutexLock(void);
void __xmlGlobalInitMutexUnlock(void);
+void __xmlGlobalInitMutexDestroy(void);
#ifdef IN_LIBXML
#ifdef __GNUC__
diff --git a/threads.c b/threads.c
index 0ab9e77..08c5ba3 100644
--- a/threads.c
+++ b/threads.c
@@ -451,6 +451,7 @@
* section in the global_init_lock then discard the one
* allocated by this thread. */
if (global_init_lock != cs) {
+ DeleteCriticalSection(cs);
free(cs);
}
}
@@ -500,6 +501,24 @@
#endif
}
+/**
+ * xmlGlobalInitMutexDestroy
+ *
+ * Makes sure that the global initialization mutex is destroyed before
+ * application termination.
+ */
+void __xmlGlobalInitMutexDestroy(void)
+{
+#if defined HAVE_WIN32_THREADS
+ if (global_init_lock != NULL)
+ {
+ DeleteCriticalSection(global_init_lock);
+ free(global_init_lock);
+ global_init_lock = NULL;
+ }
+#endif
+}
+
/************************************************************************
* *
* Per thread global state handling *