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

View File

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

View File

@ -424,7 +424,7 @@ FcCharSetCreate (void);
/* deprecated alias for FcCharSetCreate */ /* deprecated alias for FcCharSetCreate */
FcPublic FcCharSet * FcPublic FcCharSet *
FcCharSetNew (void); FcCharSetNew (void);
FcPublic void FcPublic void
FcCharSetDestroy (FcCharSet *fcs); FcCharSetDestroy (FcCharSet *fcs);
@ -734,21 +734,25 @@ FcMatrixShear (FcMatrix *m, double sh, double sv);
/* fcname.c */ /* fcname.c */
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool FcPublic FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntype); FcNameRegisterObjectTypes (const FcObjectType *types, int ntype);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool FcPublic FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype); FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype);
FcPublic const FcObjectType * FcPublic const FcObjectType *
FcNameGetObjectType (const char *object); FcNameGetObjectType (const char *object);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool FcPublic FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts); FcNameRegisterConstants (const FcConstant *consts, int nconsts);
/* Deprecated. Does nothing. Returns FcFalse. */
FcPublic FcBool FcPublic FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts); FcNameUnregisterConstants (const FcConstant *consts, int nconsts);
FcPublic const FcConstant * FcPublic const FcConstant *
FcNameGetConstant (const FcChar8 *string); FcNameGetConstant (const FcChar8 *string);

View File

@ -233,55 +233,18 @@ FcObjectHashInsert (const FcObjectType *object, FcBool copy)
return FcTrue; 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 FcBool
FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes) FcNameRegisterObjectTypes (const FcObjectType *types, int ntypes)
{ {
int i; /* Deprecated. */
return FcFalse;
for (i = 0; i < ntypes; i++)
if (!FcObjectHashInsert (&types[i], FcTrue))
return FcFalse;
return FcTrue;
} }
FcBool FcBool
FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes) FcNameUnregisterObjectTypes (const FcObjectType *types, int ntypes)
{ {
int i; /* Deprecated. */
return FcFalse;
for (i = 0; i < ntypes; i++)
FcObjectHashRemove (&types[i], FcTrue);
return FcTrue;
} }
const FcObjectType * const FcObjectType *
@ -457,68 +420,29 @@ static const FcConstant _FcBaseConstants[] = {
#define NUM_FC_CONSTANTS (sizeof _FcBaseConstants/sizeof _FcBaseConstants[0]) #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 FcBool
FcNameRegisterConstants (const FcConstant *consts, int nconsts) FcNameRegisterConstants (const FcConstant *consts, int nconsts)
{ {
FcConstantList *l; /* Deprecated. */
return FcFalse;
l = (FcConstantList *) malloc (sizeof (FcConstantList));
if (!l)
return FcFalse;
l->consts = consts;
l->nconsts = nconsts;
l->next = _FcConstants;
_FcConstants = l;
return FcTrue;
} }
FcBool FcBool
FcNameUnregisterConstants (const FcConstant *consts, int nconsts) FcNameUnregisterConstants (const FcConstant *consts, int nconsts)
{ {
const FcConstantList *l, **prev; /* Deprecated. */
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;
}
}
return FcFalse; return FcFalse;
} }
const FcConstant * const FcConstant *
FcNameGetConstant (const FcChar8 *string) FcNameGetConstant (const FcChar8 *string)
{ {
const FcConstantList *l; int i;
int i;
for (i = 0; i < NUM_FC_CONSTANTS; i++)
if (!FcStrCmpIgnoreCase (string, _FcBaseConstants[i].name))
return &_FcBaseConstants[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];
}
return 0; return 0;
} }