diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2012-09-20 14:01:47 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2013-01-01 22:55:08 -0600 |
commit | 7c0f79c5fe9db50b55112a1048a8f1c6a80e96fa (patch) | |
tree | e04c37fab041025227203ee79842b2db818e7624 | |
parent | 1e2c0d70527c39f761c5770d93a5c1f8e87522bc (diff) | |
download | fontconfig-7c0f79c5fe9db50b55112a1048a8f1c6a80e96fa.tar.gz |
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.
-rw-r--r-- | doc/fcconstant.fncs | 8 | ||||
-rw-r--r-- | doc/fcobjecttype.fncs | 6 | ||||
-rw-r--r-- | fontconfig/fontconfig.h | 10 | ||||
-rw-r--r-- | src/fcname.c | 100 |
4 files changed, 23 insertions, 101 deletions
diff --git a/doc/fcconstant.fncs b/doc/fcconstant.fncs index 2ead0a6..8f4c878 100644 --- a/doc/fcconstant.fncs +++ b/doc/fcconstant.fncs @@ -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 * diff --git a/doc/fcobjecttype.fncs b/doc/fcobjecttype.fncs index 45f3a31..3f976e4 100644 --- a/doc/fcobjecttype.fncs +++ b/doc/fcobjecttype.fncs @@ -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 * diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h index 0c169ef..1af63ab 100644 --- a/fontconfig/fontconfig.h +++ b/fontconfig/fontconfig.h @@ -424,7 +424,7 @@ FcCharSetCreate (void); /* deprecated alias for FcCharSetCreate */ FcPublic FcCharSet * FcCharSetNew (void); - + FcPublic void FcCharSetDestroy (FcCharSet *fcs); @@ -734,21 +734,25 @@ 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); - + FcPublic const FcConstant * FcNameGetConstant (const FcChar8 *string); diff --git a/src/fcname.c b/src/fcname.c index 3f63534..bc53794 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -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)) - return FcFalse; - return FcTrue; + /* Deprecated. */ + return FcFalse; } 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) - return FcFalse; - l->consts = consts; - l->nconsts = nconsts; - l->next = _FcConstants; - _FcConstants = l; - return FcTrue; + /* Deprecated. */ + return FcFalse; } 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; + 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; } |