Ensure thread safety by ensuring that tag_defs[] is thread local.
This has some overhead but is negligible on modern systems.
This commit is contained in:
Jim Derry 2021-08-14 21:36:38 -04:00
parent c8fbde5903
commit 28068b1273
2 changed files with 17 additions and 6 deletions

View file

@ -507,12 +507,12 @@ extern "C" {
# define setmode _setmode
# endif
# if defined(_MSC_VER)
# if defined(_MSC_VER)
# define fileno _fileno
#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_LOG) && !defined(DISABLE_DEBUG_LOG)
#define ENABLE_DEBUG_LOG
#endif
#endif
# if !defined(NDEBUG) && !defined(ENABLE_DEBUG_LOG) && !defined(DISABLE_DEBUG_LOG)
# define ENABLE_DEBUG_LOG
# endif
# endif
# define access _access
# define strcasecmp _stricmp
@ -553,6 +553,13 @@ extern "C" {
# endif
# endif
# ifndef TIDY_THREAD_LOCAL
# ifdef _MSC_VER
# define TIDY_THREAD_LOCAL __declspec( thread )
# endif
# endif
#endif /* _WIN32 */
@ -600,6 +607,10 @@ extern "C" {
# define TIDY_STRUCT
#endif
#ifndef TIDY_THREAD_LOCAL
# define TIDY_THREAD_LOCAL __thread
#endif
typedef unsigned char byte;
typedef uint tchar; /* single, full character */

View file

@ -166,7 +166,7 @@ static CheckAttribs CheckHTML;
* but allow this table to be ADJUSTED if NOT HTML5
* was static const Dict tag_defs[] =
\*/
static Dict tag_defs[] =
static TIDY_THREAD_LOCAL Dict tag_defs[] =
{
{ TidyTag_UNKNOWN, "unknown!", VERS_UNKNOWN, NULL, (0), NULL, NULL },