X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=src%2Ffcpat.c;h=8f63659df673c2f204ec7bb5fe2ddeac6bff9dee;hb=HEAD;hp=792a164f9dddf3462525e16067205d469891d72c;hpb=efe5eae26b2443363b1000b3197d1731a40f8af9;p=fontconfig.git diff --git a/src/fcpat.c b/src/fcpat.c index 792a164..8f63659 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -5,9 +5,9 @@ * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in + * documentation, and that the name of the author(s) not be used in * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no + * specific, written prior permission. The authors make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * @@ -75,15 +75,15 @@ FcValueCanonicalize (const FcValue *v) switch (v->type) { case FcTypeString: - new.u.s = fc_value_string(v); + new.u.s = FcValueString(v); new.type = FcTypeString; break; case FcTypeCharSet: - new.u.c = fc_value_charset(v); + new.u.c = FcValueCharSet(v); new.type = FcTypeCharSet; break; case FcTypeLangSet: - new.u.l = fc_value_langset(v); + new.u.l = FcValueLangSet(v); new.type = FcTypeLangSet; break; default: @@ -138,11 +138,11 @@ FcValueListDestroy (FcValueListPtr l) FcMatrixFree ((FcMatrix *)l->value.u.m); break; case FcTypeCharSet: - FcCharSetDestroy + FcCharSetDestroy ((FcCharSet *) (l->value.u.c)); break; case FcTypeLangSet: - FcLangSetDestroy + FcLangSetDestroy ((FcLangSet *) (l->value.u.l)); break; default: @@ -210,7 +210,7 @@ FcStringHash (const FcChar8 *s) { FcChar8 c; FcChar32 h = 0; - + if (s) while ((c = *s++)) h = ((h << 1) | (h >> 31)) ^ c; @@ -220,7 +220,7 @@ FcStringHash (const FcChar8 *s) static FcChar32 FcValueHash (const FcValue *v) { - switch (fc_storage_type(v)) { + switch (v->type) { case FcTypeVoid: return 0; case FcTypeInteger: @@ -228,21 +228,21 @@ FcValueHash (const FcValue *v) case FcTypeDouble: return FcDoubleHash (v->u.d); case FcTypeString: - return FcStringHash (fc_value_string(v)); + return FcStringHash (FcValueString(v)); case FcTypeBool: return (FcChar32) v->u.b; case FcTypeMatrix: - return (FcDoubleHash (v->u.m->xx) ^ - FcDoubleHash (v->u.m->xy) ^ - FcDoubleHash (v->u.m->yx) ^ + return (FcDoubleHash (v->u.m->xx) ^ + FcDoubleHash (v->u.m->xy) ^ + FcDoubleHash (v->u.m->yx) ^ FcDoubleHash (v->u.m->yy)); case FcTypeCharSet: - return (FcChar32) fc_value_charset(v)->num; + return (FcChar32) FcValueCharSet(v)->num; case FcTypeFTFace: return FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->family_name) ^ FcStringHash ((const FcChar8 *) ((FT_Face) v->u.f)->style_name); case FcTypeLangSet: - return FcLangSetHash (fc_value_langset(v)); + return FcLangSetHash (FcValueLangSet(v)); } return FcFalse; } @@ -269,7 +269,7 @@ static FcChar32 FcValueListHash (FcValueListPtr l) { FcChar32 hash = 0; - + for (; l; l = FcValueListNext(l)) { hash = ((hash << 1) | (hash >> 31)) ^ FcValueHash (&l->value); @@ -282,7 +282,7 @@ FcPatternDestroy (FcPattern *p) { int i; FcPatternElt *elts; - + if (p->ref == FC_REF_CONSTANT) { FcCacheObjectDereference (p); @@ -342,12 +342,12 @@ FcPatternObjectInsertElt (FcPattern *p, FcObject object) { int i; FcPatternElt *e; - + i = FcPatternObjectPosition (p, object); if (i < 0) { i = -i - 1; - + /* reallocate array */ if (p->num + 1 >= p->size) { @@ -385,14 +385,14 @@ FcPatternObjectInsertElt (FcPattern *p, FcObject object) e + i, sizeof (FcPatternElt) * (p->num - i)); - + /* bump count */ p->num++; e[i].object = object; e[i].values = NULL; } - + return FcPatternElts(p) + i; } @@ -429,7 +429,7 @@ FcPatternHash (const FcPattern *p) for (i = 0; i < p->num; i++) { - h = (((h << 1) | (h >> 31)) ^ + h = (((h << 1) | (h >> 31)) ^ pe[i].object ^ FcValueListHash (FcPatternEltValues(&pe[i]))); } @@ -441,7 +441,7 @@ FcPatternEqualSubset (const FcPattern *pai, const FcPattern *pbi, const FcObject { FcPatternElt *ea, *eb; int i; - + for (i = 0; i < os->nobject; i++) { FcObject object = FcObjectFromName (os->objects[i]); @@ -503,11 +503,11 @@ FcPatternObjectAddWithBinding (FcPattern *p, new->value = value; new->binding = binding; new->next = NULL; - + e = FcPatternObjectInsertElt (p, object); if (!e) goto bail2; - + if (append) { for (prev = &e->values; *prev; prev = &(*prev)->next) @@ -519,10 +519,10 @@ FcPatternObjectAddWithBinding (FcPattern *p, new->next = e->values; e->values = new; } - + return FcTrue; -bail2: +bail2: FcValueDestroy (value); bail1: FcMemFree (FC_MEM_VALLIST, sizeof (FcValueList)); @@ -563,10 +563,10 @@ FcPatternObjectDel (FcPattern *p, FcObject object) /* destroy value */ FcValueListDestroy (e->values); - + /* shuffle existing ones down */ - memmove (e, e+1, - (FcPatternElts(p) + p->num - (e + 1)) * + memmove (e, e+1, + (FcPatternElts(p) + p->num - (e + 1)) * sizeof (FcPatternElt)); p->num--; e = FcPatternElts(p) + p->num; @@ -580,7 +580,7 @@ FcPatternDel (FcPattern *p, const char *object) { return FcPatternObjectDel (p, FcObjectFromName (object)); } - + FcBool FcPatternRemove (FcPattern *p, const char *object, int id) { @@ -773,8 +773,8 @@ FcPatternGetInteger (const FcPattern *p, const char *object, int id, int *i) { return FcPatternObjectGetInteger (p, FcObjectFromName (object), id, i); } - - + + FcResult FcPatternObjectGetDouble (const FcPattern *p, FcObject object, int id, double *d) { @@ -824,7 +824,7 @@ FcPatternGetString (const FcPattern *p, const char *object, int id, FcChar8 ** s { return FcPatternObjectGetString (p, FcObjectFromName (object), id, s); } - + FcResult FcPatternGetMatrix(const FcPattern *p, const char *object, int id, FcMatrix **m) { @@ -924,7 +924,7 @@ FcPatternDuplicate (const FcPattern *orig) l->binding, FcTrue)) goto bail1; - + } } @@ -949,7 +949,7 @@ FcPattern * FcPatternVaBuild (FcPattern *p, va_list va) { FcPattern *ret; - + FcPatternVapBuild (ret, p, va); return ret; } @@ -958,7 +958,7 @@ FcPattern * FcPatternBuild (FcPattern *p, ...) { va_list va; - + va_start (va, p); FcPatternVapBuild (p, p, va); va_end (va); @@ -974,14 +974,14 @@ FcPatternAppend (FcPattern *p, FcPattern *s) int i; FcPatternElt *e; FcValueListPtr v; - + for (i = 0; i < s->num; i++) { e = FcPatternElts(s)+i; for (v = FcPatternEltValues(e); v; v = FcValueListNext(v)) { if (!FcPatternObjectAddWithBinding (p, e->object, - FcValueCanonicalize(&v->value), + FcValueCanonicalize(&v->value), v->binding, FcTrue)) return FcFalse; } @@ -1057,9 +1057,13 @@ FcStrStaticName (const FcChar8 *name) if (b->hash == hash && !strcmp ((char *)name, (char *) (b + 1))) return (FcChar8 *) (b + 1); size = sizeof (struct objectBucket) + strlen ((char *)name) + 1; - b = malloc (size + sizeof (int)); - /* workaround glibc bug which reads strlen in groups of 4 */ - FcMemAlloc (FC_MEM_STATICSTR, size + sizeof (int)); + /* + * workaround valgrind warning because glibc takes advantage of how it knows memory is + * allocated to implement strlen by reading in groups of 4 + */ + size = (size + 3) & ~3; + b = malloc (size); + FcMemAlloc (FC_MEM_STATICSTR, size); if (!b) return NULL; b->next = 0; @@ -1102,7 +1106,7 @@ FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat) { int i; FcPatternElt *elts = FcPatternElts(pat); - + if (!FcSerializeAlloc (serialize, pat, sizeof (FcPattern))) return FcFalse; if (!FcSerializeAlloc (serialize, elts, pat->num * sizeof (FcPatternElt))) @@ -1128,11 +1132,11 @@ FcPatternSerialize (FcSerialize *serialize, const FcPattern *pat) *pat_serialized = *pat; pat_serialized->size = pat->num; pat_serialized->ref = FC_REF_CONSTANT; - + elts_serialized = FcSerializePtr (serialize, elts); if (!elts_serialized) return NULL; - + pat_serialized->elts_offset = FcPtrToOffset (pat_serialized, elts_serialized); @@ -1142,7 +1146,7 @@ FcPatternSerialize (FcSerialize *serialize, const FcPattern *pat) if (!values_serialized) return NULL; elts_serialized[i].object = elts[i].object; - elts_serialized[i].values = FcPtrToEncodedOffset (&elts_serialized[i], + elts_serialized[i].values = FcPtrToEncodedOffset (&elts_serialized[i], values_serialized, FcValueList); } @@ -1199,7 +1203,7 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl) vl_serialized = FcSerializePtr (serialize, vl); if (!vl_serialized) return NULL; - + if (prev_serialized) prev_serialized->next = FcPtrToEncodedOffset (prev_serialized, vl_serialized,