2 * fontconfig/src/fclist.c
4 * Copyright © 2000 Keith Packard
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of the author(s) not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. The authors make no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
27 #include "fcobjshash.h"
31 static int next_id = FC_MAX_BASE_OBJECT + 1;
32 struct FcObjectOtherTypeInfo {
33 struct FcObjectOtherTypeInfo *next;
39 _FcObjectLookupOtherTypeByName (const char *str, FcObject *id)
41 struct FcObjectOtherTypeInfo *ots, *ot;
44 ots = fc_atomic_ptr_get (&other_types);
46 for (ot = ots; ot; ot = ot->next)
47 if (0 == strcmp (ot->object.object, str))
52 ot = malloc (sizeof (*ot));
56 ot->object.object = (const char *) FcStrdup (str);
58 ot->id = fc_atomic_int_add (next_id, +1);
61 if (!fc_atomic_ptr_cmpexch (&other_types, ots, ot)) {
74 FcObjectLookupBuiltinIdByName (const char *str)
76 const struct FcObjectTypeInfo *o = FcObjectTypeLookup (str, strlen (str));
85 FcObjectLookupIdByName (const char *str)
87 const struct FcObjectTypeInfo *o = FcObjectTypeLookup (str, strlen (str));
92 if (_FcObjectLookupOtherTypeByName (str, &id))
99 FcObjectLookupOtherNameById (FcObject id)
101 struct FcObjectOtherTypeInfo *ot;
103 for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
105 return ot->object.object;
111 FcObjectLookupOtherTypeByName (const char *str)
113 return _FcObjectLookupOtherTypeByName (str, NULL);
116 FcPrivate const FcObjectType *
117 FcObjectLookupOtherTypeById (FcObject id)
119 struct FcObjectOtherTypeInfo *ot;
121 for (ot = fc_atomic_ptr_get (&other_types); ot; ot = ot->next)
129 #include "fcaliastail.h"