diff --git a/CHANGES.md b/CHANGES.md index 7e1870d..8f7d154 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/mxml-private.c b/mxml-private.c index 726acc9..8c1c58d 100644 --- a/mxml-private.c +++ b/mxml-private.c @@ -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 -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); }