/* Please do not revoke any of these bindings. */
static const FcObjectType _FcBaseObjectTypes[] = {
+ { "__DUMMY__", FcTypeVoid, },
{ FC_FAMILY, FcTypeString, },
{ FC_FAMILYLANG, FcTypeString, },
{ FC_STYLE, FcTypeString, },
static FcObjectType * _FcUserObjectNames = 0;
static int user_obj_alloc = 0;
+static int next_basic_offset = NUM_OBJECT_TYPES;
typedef struct _FcObjectTypeList FcObjectTypeList;
const FcObjectTypeList *next;
const FcObjectType *types;
int ntypes;
+ int basic_offset;
};
static const FcObjectTypeList _FcBaseObjectTypesList = {
l->types = types;
l->ntypes = ntypes;
l->next = _FcObjectTypes;
+ l->basic_offset = next_basic_offset;
+ next_basic_offset += ntypes;
_FcObjectTypes = l;
return FcTrue;
}
};
static struct objectBucket *FcObjectBuckets[OBJECT_HASH_SIZE];
+/* Design constraint: biggest_known_ntypes must never change
+ * after any call to FcNameRegisterObjectTypes. */
static const FcObjectType *biggest_known_types = _FcBaseObjectTypes;
static FcBool allocated_biggest_known_types;
static int biggest_known_ntypes = NUM_OBJECT_TYPES;
if (!strcmp (object, t->object))
{
if (l == (FcObjectTypeList*)_FcUserObjectNames)
- return i + biggest_known_ntypes;
+ return -i;
else
- return i;
+ return l->basic_offset + i;
}
}
}
FcObjectType * t = realloc (_FcUserObjectNames,
nt * sizeof (FcObjectType));
if (!t)
- return -1;
+ return 0;
_FcUserObjectNames = t;
user_obj_alloc = nt;
}
t[n].object = object;
t[n].type = FcTypeVoid;
- return n+biggest_known_ntypes;
+ return -n;
}
FcObjectPtr
b = malloc (size);
FcMemAlloc (FC_MEM_STATICSTR, size);
if (!b)
- return -1;
+ return 0;
b->next = 0;
b->hash = hash;
b->id = FcObjectToPtrLookup (name);
const char *
FcObjectPtrU (FcObjectPtr si)
{
- if (si < biggest_known_ntypes)
- return biggest_known_types[si].object;
- else
- return _FcUserObjectNames[si-biggest_known_ntypes].object;
+ const FcObjectTypeList *l;
+ int i, j;
+
+ if (si > 0)
+ {
+ if (si < biggest_known_ntypes)
+ return biggest_known_types[si].object;
+
+ j = 0;
+ for (l = _FcObjectTypes; l; l = l->next)
+ for (i = 0; i < l->ntypes; i++, j++)
+ if (j == si)
+ return l->types[i].object;
+ }
+
+ return _FcUserObjectNames[-si].object;
}
int