summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-11-30 10:38:28 -0800
committerVito Caputo <vcaputo@pengaru.com>2023-11-30 10:43:19 -0800
commit686b24cfb95e4f451b5993c2c15cbf50c173b32e (patch)
treefe0cd5f00381afc5ae3a1c2b198383590fcf9cd3
parent7076aa56d7a2b18d02152696f0e4082223bf86e7 (diff)
til_fb: initialize synchronization primitives earlier
Noticed while working on unrelated til_fb stuff; once _til_fb_page_new() started taking a mutex, its use in til_fb_new() was too early relative to initializing said mutex. Funny that this never blew anything up nor angered ASAN, just having the memory allocated and zeroed goes a long way towards hiding such things... for better or worse.
-rw-r--r--src/til_fb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/til_fb.c b/src/til_fb.c
index 951688c..a802c40 100644
--- a/src/til_fb.c
+++ b/src/til_fb.c
@@ -579,17 +579,17 @@ int til_fb_new(const til_fb_ops_t *ops, const char *title, const til_setup_t *se
goto fail;
}
- for (int i = 0; i < n_pages; i++)
- _til_fb_page_new(fb);
-
- fb->n_pages = n_pages;
-
pthread_mutex_init(&fb->ready_mutex, NULL);
pthread_cond_init(&fb->ready_cond, NULL);
pthread_mutex_init(&fb->inactive_mutex, NULL);
pthread_cond_init(&fb->inactive_cond, NULL);
pthread_mutex_init(&fb->rebuild_mutex, NULL);
+ for (int i = 0; i < n_pages; i++)
+ _til_fb_page_new(fb);
+
+ fb->n_pages = n_pages;
+
page = _til_fb_page_get(fb);
if (!page) {
r = -ENOMEM;
© All Rights Reserved