From ee5421470a92d66ff79098f68e2ceb99c4cbfd3c Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Thu, 11 Jun 2026 19:07:19 +1000 Subject: fix(thread): Add mutex to ff_ctx and make ff_dprintf thread-safe --- include/tinyff/common.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/tinyff/common.h') diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 2b17911..6d93a70 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -8,6 +8,10 @@ #include #include +#ifdef USE_THREAD +#include +#endif + #ifdef USE_BENCH #include @@ -128,6 +132,11 @@ typedef struct ff_ctx { #ifdef USE_BENCH ff_bench bench; #endif + + #ifdef USE_THREAD + /* mutex to protect ctx internal mutable state when threads are enabled */ + pthread_mutex_t ff_lock; + #endif } ff_ctx; ff_ctx* ff_init(ff_allocator* allocator); -- cgit v1.2.3