summaryrefslogtreecommitdiff
path: root/include/tinyff
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-06-11 19:07:19 +1000
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-06-11 19:07:19 +1000
commitee5421470a92d66ff79098f68e2ceb99c4cbfd3c (patch)
treed4224df4c1fd2eaf189adf00cdd3270a353e8551 /include/tinyff
parentb1e964269f4afc8f714687049b268a8901786e84 (diff)
fix(thread): Add mutex to ff_ctx and make ff_dprintf thread-safe
Diffstat (limited to 'include/tinyff')
-rw-r--r--include/tinyff/common.h9
1 files changed, 9 insertions, 0 deletions
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 <stddef.h>
#include <tinyff/stream.h>
+#ifdef USE_THREAD
+#include <pthread.h>
+#endif
+
#ifdef USE_BENCH
#include <tinyff/bench/bench.h>
@@ -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);