Deprecate FcName(Un)RegisterObjectTypes / FcName(Un)RegisterConstants

These never worked as intended.  The problem is, if Fontconfig tries to
read config files when these new types / constants are not registered,
it errs.  As a result, no defined types / constants are usable from
config files.  Which makes these really useless.  Xft was the only user
of this API and even there it's not really used.  Just kill it.

One inch closer to thread-safety since we can fix the object-type hash
table at compile time.
This commit is contained in:
Behdad Esfahbod 2012-09-20 14:01:47 -04:00
parent 1e2c0d7052
commit 7c0f79c5fe
4 changed files with 23 additions and 101 deletions

View File

@ -27,9 +27,7 @@
@TYPE2@ int% @ARG2@ nconsts
@PURPOSE@ Register symbolic constants
@DESC@
Register <parameter>nconsts</parameter> new symbolic constants. Returns
FcFalse if the constants cannot be registered (due to allocation failure).
Otherwise returns FcTrue.
Deprecated. Does nothing. Returns FcFalse.
@@
@RET@ FcBool
@ -38,9 +36,7 @@ Otherwise returns FcTrue.
@TYPE2@ int% @ARG2@ nconsts
@PURPOSE@ Unregister symbolic constants
@DESC@
Unregister <parameter>nconsts</parameter> symbolic constants. Returns
FcFalse if the specified constants were not registered. Otherwise returns
FcTrue.
Deprecated. Does nothing. Returns FcFalse.
@@
@RET@ const FcConstant *

View File

@ -27,9 +27,7 @@
@TYPE2@ int% @ARG2@ ntype
@PURPOSE@ Register object types
@DESC@
Register <parameter>ntype</parameter> new object types. Returns FcFalse if
some of the names cannot be
registered (due to allocation failure). Otherwise returns FcTrue.
Deprecated. Does nothing. Returns FcFalse.
@@
@RET@ FcBool
@ -38,7 +36,7 @@ registered (due to allocation failure). Otherwise returns FcTrue.
@TYPE2@ int% @ARG2@ ntype
@PURPOSE@ Unregister object types
@DESC@
Unregister <parameter>ntype</parameter> object types. Returns FcTrue.
Deprecated. Does nothing. Returns FcFalse.
@@
@RET@ const FcObjectType *

View File

@ -734,18 +734,22 @@ FcMatrixShear (FcMatrix *m, double sh, double sv);
/* fcname.c */
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
FcPublic const FcObjectType *
FcNameGetObjectType (const char *object);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts);

View File

@ -233,55 +233,18 @@ FcObjectHashInsert (const FcObjectType *object, FcBool copy)
return FcTrue;
}
static void
FcObjectHashRemove (const FcObjectType *object, FcBool cleanobj)
{
FcChar32 hash = FcStringHash ((const FcChar8 *) object->object);
FcObjectBucket **p;
FcObjectBucket *b;
FcObjectType *o;
if (!FcObjectsInited)
FcObjectInit ();
for (p = &FcObjectBuckets[hash%OBJECT_HASH_SIZE]; (b = *p); p = &(b->next))
{
o = FcObjects + b->id - 1;
if (b->hash == hash && !strcmp (object->object, o->object))
{
*p = b->next;
free (b);
if (cleanobj)
{
/* Clean up object array */
o->object = NULL;
o->type = -1;
while (FcObjects[FcObjectsNumber-1].object == NULL)
--FcObjectsNumber;
}
break;
}
}
}
FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
{
int i;
for (i = 0; i < ntypes; i++)
if (!FcObjectHashInsert (&types[i], FcTrue))
/* Deprecated. */
return FcFalse;
return FcTrue;
}
FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
{
int i;
for (i = 0; i < ntypes; i++)
FcObjectHashRemove (&types[i], FcTrue);
return FcTrue;
/* Deprecated. */
return FcFalse;
}
const FcObjectType *
@ -457,68 +420,29 @@ static const FcConstant _FcBaseConstants[] = {
#define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0])
typedef struct _FcConstantList FcConstantList;
struct _FcConstantList {
const FcConstantList *next;
const FcConstant *consts;
int nconsts;
};
static const FcConstantList _FcBaseConstantList = {
0,
_FcBaseConstants,
NUM_FC_CONSTANTS
};
static const FcConstantList *_FcConstants = &_FcBaseConstantList;
FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts)
{
FcConstantList *l;
l = (FcConstantList *) malloc (sizeof (FcConstantList));
if (!l)
/* Deprecated. */
return FcFalse;
l->consts = consts;
l->nconsts = nconsts;
l->next = _FcConstants;
_FcConstants = l;
return FcTrue;
}
FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
{
const FcConstantList *l, **prev;
for (prev = &_FcConstants;
(l = *prev);
prev = (const FcConstantList **) &(l->next))
{
if (l->consts == consts && l->nconsts == nconsts)
{
*prev = l->next;
free ((void *) l);
return FcTrue;
}
}
/* Deprecated. */
return FcFalse;
}
const FcConstant *
FcNameGetConstant (const FcChar8 *string)
{
const FcConstantList *l;
int i;
for (l = _FcConstants; l; l = l->next)
{
for (i = 0; i < l->nconsts; i++)
if (!FcStrCmpIgnoreCase (string, l->consts[i].name))
return &l->consts[i];
}
for (i = 0; i < NUM_FC_CONSTANTS; i++)
if (!FcStrCmpIgnoreCase (string, _FcBaseConstants[i].name))
return &_FcBaseConstants[i];
return 0;
}