Fix POSIX threading support on MingW (Issue #287)

This commit is contained in:
Michael R Sweet 2021-10-26 14:28:16 -04:00
parent 1df294d735
commit 02f3310322
No known key found for this signature in database
GPG Key ID: 999559A027815955
2 changed files with 6 additions and 9 deletions

View File

@ -1,6 +1,7 @@
# Changes in Mini-XML 3.2.1
- Fixed `MXML_MINOR_VERSION` value in "mxml.h" (Issue #285)
- Fixed POSIX threading support for MingW (Issue #287)
- Fixed some minor memory leaks found by Coverity.

View File

@ -3,7 +3,7 @@
*
* https://www.msweet.org/mxml
*
* Copyright © 2003-2019 by Michael R Sweet.
* Copyright © 2003-2021 by Michael R Sweet.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
@ -140,7 +140,7 @@ mxml_real_cb(mxml_node_t *node) /* I - Current node */
#ifdef HAVE_PTHREAD_H /**** POSIX threading ****/
# include <pthread.h>
static pthread_key_t _mxml_key = -1; /* Thread local storage key */
static pthread_key_t _mxml_key; /* Thread local storage key */
static pthread_once_t _mxml_key_once = PTHREAD_ONCE_INIT;
/* One-time initialization object */
static void _mxml_init(void);
@ -168,14 +168,10 @@ _MXML_FINI(void)
_mxml_global_t *global; /* Global data */
if (_mxml_key != -1)
{
if ((global = (_mxml_global_t *)pthread_getspecific(_mxml_key)) != NULL)
_mxml_destructor(global);
if ((global = (_mxml_global_t *)pthread_getspecific(_mxml_key)) != NULL)
_mxml_destructor(global);
pthread_key_delete(_mxml_key);
_mxml_key = -1;
}
pthread_key_delete(_mxml_key);
}