Skip to content

Commit

Permalink
Make sure to init dtoa_ctx_key also on win32 (#2834)
Browse files Browse the repository at this point in the history
Fixes page fault for mingw build

Related to #2831
  • Loading branch information
wader authored Aug 10, 2023
1 parent d1a6da2 commit 765a5c7
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/jv_dtoa_tsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
#include "jv_dtoa.h"
#include "jv_alloc.h"

#ifndef WIN32
static pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;
#endif

static pthread_key_t dtoa_ctx_key;
static void tsd_dtoa_ctx_dtor(void *ctx) {
Expand All @@ -35,15 +33,11 @@ void jv_tsd_dtoa_ctx_init() {
fprintf(stderr, "error: cannot create thread specific key");
abort();
}
#ifndef WIN32
atexit(jv_tsd_dtoa_ctx_fini);
#endif
}

inline struct dtoa_context *tsd_dtoa_context_get() {
#ifndef WIN32
pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail
#endif
struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);
if (!ctx) {
ctx = malloc(sizeof(struct dtoa_context));
Expand Down

0 comments on commit 765a5c7

Please sign in to comment.