Skip to content

Commit

Permalink
Fix POSIX threading support on MingW (Issue #287)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Oct 26, 2021
1 parent 1df294d commit 02f3310
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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.


Expand Down
14 changes: 5 additions & 9 deletions mxml-private.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 02f3310

Please sign in to comment.