[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Mar 28 22:34:37 UTC 2018


 src/hb-common.cc |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 5aa2c6e194bc75637d3f4862a096c0e7100072e2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Mar 28 15:33:51 2018 -0700

    [atexit] Make hb_languate_item_t *langs freeing threadsafe
    
    Part of https://github.com/harfbuzz/harfbuzz/issues/923

diff --git a/src/hb-common.cc b/src/hb-common.cc
index d1fcf799..ce3d01b8 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -252,11 +252,16 @@ static hb_language_item_t *langs;
 static void
 free_langs (void)
 {
-  while (langs) {
-    hb_language_item_t *next = langs->next;
-    langs->finish ();
-    free (langs);
-    langs = next;
+retry:
+  hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs);
+  if (!hb_atomic_ptr_cmpexch (&langs, first_lang, nullptr))
+    goto retry;
+
+  while (first_lang) {
+    hb_language_item_t *next = first_lang->next;
+    first_lang->finish ();
+    free (first_lang);
+    first_lang = next;
   }
 }
 #endif


More information about the HarfBuzz mailing list