diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc index 46fe13999..5d95ca57b 100644 --- a/src/hb-graphite2.cc +++ b/src/hb-graphite2.cc @@ -79,10 +79,12 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s p->blob = blob; p->tag = tag; - /* TODO Not thread-safe, but fairly harmless. - * We can do the double-checked pointer cmpexch thing here. */ - p->next = face_data->tlist; - face_data->tlist = p; +retry: + hb_graphite2_tablelist_t *tlist = (hb_graphite2_tablelist_t *) hb_atomic_ptr_get (&face_data->tlist); + p->next = tlist; + + if (!hb_atomic_ptr_cmpexch (&face_data->tlist, tlist, p)) + goto retry; } unsigned int tlen; diff --git a/src/hb-graphite2.h b/src/hb-graphite2.h index 82b1e64cd..05c55debe 100644 --- a/src/hb-graphite2.h +++ b/src/hb-graphite2.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2011 Martin Hosken - * Copyright (C) 2011 SIL International + * Copyright © 2011 Martin Hosken + * Copyright © 2011 SIL International * * This is part of HarfBuzz, a text shaping library. *