[atexit] Make hb_languate_item_t *langs freeing threadsafe
Part of https://github.com/harfbuzz/harfbuzz/issues/923
This commit is contained in:
parent
8c9451107d
commit
5aa2c6e194
|
@ -252,11 +252,16 @@ static hb_language_item_t *langs;
|
||||||
static void
|
static void
|
||||||
free_langs (void)
|
free_langs (void)
|
||||||
{
|
{
|
||||||
while (langs) {
|
retry:
|
||||||
hb_language_item_t *next = langs->next;
|
hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs);
|
||||||
langs->finish ();
|
if (!hb_atomic_ptr_cmpexch (&langs, first_lang, nullptr))
|
||||||
free (langs);
|
goto retry;
|
||||||
langs = next;
|
|
||||||
|
while (first_lang) {
|
||||||
|
hb_language_item_t *next = first_lang->next;
|
||||||
|
first_lang->finish ();
|
||||||
|
free (first_lang);
|
||||||
|
first_lang = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue