{
struct FcObjectOtherTypeInfo *ots, *ot;
- /* XXX MT-unsafe */
- ots = other_types;
+retry:
+ ots = fc_atomic_ptr_get (&other_types);
for (ot = ots; ot; ot = ot->next)
if (0 == strcmp (ot->object.object, str))
ot->object.object = strdup (str);
ot->object.type = -1;
- ot->id = next_id++; /* MT_unsafe */
+ ot->id = fc_atomic_int_add (next_id, +1);
ot->next = ot;
- other_types = ot;
+ if (!fc_atomic_ptr_cmpexch (&other_types, ots, ot)) {
+ free (ot);
+ goto retry;
+ }
}
if (id)
const char *
FcObjectLookupOtherNameById (FcObject id)
{
- /* XXX MT-unsafe */
struct FcObjectOtherTypeInfo *ot;
- for (ot = other_types; ot; ot = ot->next)
+ for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
if (ot->id == id)
return ot->object.object;
FcPrivate const FcObjectType *
FcObjectLookupOtherTypeById (FcObject id)
{
- /* XXX MT-unsafe */
struct FcObjectOtherTypeInfo *ot;
- for (ot = other_types; ot; ot = ot->next)
+ for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
if (ot->id == id)
return &ot->object;
}
-#define __fcobjs__
#include "fcaliastail.h"
#undef __fcobjs__