Commit Graph

76 Commits

Author SHA1 Message Date
Keith Packard bc5e487f2a Pass directory information around in FcCache structure. Freeze charsets.
Instead of passing directory information around in separate variables,
collect it all in an FcCache structure. Numerous internal and tool
interfaces changed as a result of this.

Charsets are now pre-frozen before being serialized. This causes them to
share across multiple fonts in the same cache.
2006-09-01 01:15:14 -07:00
Keith Packard e9a564e2cd Serialized value lists were only including one value.
The next pointer in the serialized value list wasn't getting set, so they
were truncated at a single value.
2006-08-31 09:07:32 -07:00
Keith Packard 09f9f6f62a Rework Object name database to unify typechecking and object lookup.
Eliminate ancient list of object name databases and load names into single
hash table that includes type information. Typecheck all pattern values to
avoid mis-typed pattern elements.
2006-08-30 18:50:58 -07:00
Keith Packard c02886485b FcCharSetSerialize was using wrong offset for leaves. Make fc-cat work.
FcCharSetSerialize was computing the offset to the unserialized leaf,
which left it pointing at random data when the cache was reloaded.

fc-cat has been updated to work with the new cache structure.

Various debug messages extended to help diagnose serialization errors.
2006-08-30 13:51:03 -07:00
Keith Packard 7ce1967331 Rework cache files to use offsets for all data structures.
Replace all of the bank/id pairs with simple offsets, recode several
data structures to always use offsets inside the library to avoid
conditional paths. Exposed data structures use pointers to hold offsets,
setting the low bit to distinguish between offset and pointer.

Use offset-based data structures for lang charset encodings; eliminates
separate data structure format for that file.

Much testing will be needed; offsets are likely not detected everywhere in
the library yet.
2006-08-30 04:16:22 -07:00
Keith Packard 529291bef4 Eliminate pattern freezing 2006-04-27 07:54:07 +00:00
Keith Packard c1c3ba06d5 Make path names in cache files absolute (NB, cache format change) Stop
permitting cache files to be stored in font dirs. Bump cache magic.
    Don't include /fonts.cache-2 in cache hash construction.
reviewed by: Patrick Lam <plam@mit.edu>
2006-04-27 07:11:44 +00:00
Patrick Lam f045376c08 Include $(top_srcdir), $(top_srcdir)/src before anything else.
Shuffle order of includes for building out of srcdir on win32.
reviewed by: plam
2006-04-25 05:57:41 +00:00
Patrick Lam 2f02e38361 Fix memory leak (Coverity defect #2089).
Ignore script if subtable is missing (Coverity defect #2088).
Fix possible null pointer dereference (Coverity defect #784) and memory
    leak (Coverity defects #785, #786).
Don't copy FcCharSet if we're going to throw it away anyway. (Reported by
    Kenichi Handa).
reviewed by: plam
2006-04-12 14:36:36 +00:00
Patrick Lam 04f7d3e7fd Properly convert static charsets to dynamic charsets.
Fix memory leak in error case (Coverity defects #1820, #1821, #1822).
Fix memory leak (Coverity defect #1819).
prevent crash when invalid include line is parsed (Coverity defect #763).
Fix potential null pointer access (Coverity defect #1804).
Remove dead code (Coverity defect #1194).
Prevent potential null pointer access (Coverity defect #767), ensure error
    value is read (Coverity defect #1195).
reviewed by: plam
2006-04-11 14:20:59 +00:00
Patrick Lam 44415a079a Portability fixes for HP-UX (reported by Christoph Bauer). Replace
'__inline__' by AC_C_INLINE and 'inline'. Replace '__alignof__' by
    'fc_alignof'.
reviewed by: plam
2006-04-07 17:27:39 +00:00
Patrick Lam 392fa276dc Reduce amount of dirty rss by const'ing some data structures.
Don't fail if we can't create or remove $(pkgcachedir) i.e.
    /var/cache/fontconfig. (reported by Quanah Gibson-Mount).
reviewed by: plam
2006-04-06 04:52:21 +00:00
Patrick Lam 9226e04c69 Because we hacked FcPatternGet, we don't really need to expand the filename
again in FcPatternGetString.
2006-03-05 15:33:46 +00:00
Patrick Lam 618adbaf7b Ok, so some people (wine!) use FcPatternGet to fetch FC_FILE. Make that
work. Reported by Bernhard Rosenkraenzer.
2006-03-05 06:05:50 +00:00
Patrick Lam bb6b19938e Get rid of C++-style comments. 2006-03-03 06:35:53 +00:00
Patrick Lam efb11b36c4 Perf optimizations. Inline FcValueCanonicalize, reduce FcValueListPtrU
usage, remove redundant cast.
reviewed by: plam
2006-02-07 21:15:33 +00:00
Patrick Lam 575a37b797 Fix additional memory leaks reported by Ronny V. Vindenes: don't invoke
FcValueSave on hashed static strings in FcPatternAddWithBinding.
Add another st_dev check in FcDirCacheOpen.
2006-01-25 14:52:49 +00:00
Patrick Lam 986e35979e Fix for unaligned memory accesses.
reviewed by: plam
2006-01-19 19:20:30 +00:00
Patrick Lam c60ec7cc6d Add self to AUTHORS list.
Minor change to global cache file format to fix fc-cat bug reported by
    Frederic Crozat, and buglet with not globally caching directories with
    zero fonts cached.
2006-01-05 15:12:22 +00:00
Patrick Lam ebc157f9a1 Shut up GCC warnings on amd.
reviewed by: plam
2005-12-21 20:00:20 +00:00
Patrick Lam 204da5a8b8 Because we've changed FcPatternAddString to use FcStrStaticName and not
FcValueSave, explicitly handle the case of a null string.
2005-12-08 05:54:27 +00:00
Patrick Lam 9ede93f1dc Don't free strings that have been returned from FcStrStaticName. 2005-12-05 16:08:01 +00:00
Patrick Lam 51af050992 Don't make FcPatternFindFullFname available to fccfg, it's not really safe.
Instead go through FcPatternGetString (sorry, perf guys.) Also, use
    globs for dirs as well.
2005-11-29 06:09:18 +00:00
Patrick Lam ced3f0a0ab Fix problem dating back at least to 2.3.2 where globs weren't being applied
to patterns loaded from a cache.
Fix some obvious spelling mistakes.
2005-11-29 00:14:42 +00:00
Patrick Lam 81fe99fdd0 Rename fcpatterns, fcpatternelts, fcvaluelists to _fcPatterns,
_fcPatternElts, _fcValueLists for consistency.
2005-11-25 16:04:44 +00:00
Patrick Lam 61571f3f2e Pass around FcCache *s to the Unserialize functions for extra consistency
(and less overhead, for what that's worth).
2005-11-25 15:50:34 +00:00
Patrick Lam 9ab79bdfb7 Inline the *PtrU functions to gain perf. Remove unneeded params for the
FcCompare* functions.
reviewed by: plam
2005-11-25 03:00:51 +00:00
Patrick Lam 1c9fdccab9 Move FC_BANK_DYNAMIC, FC_BANK_FIRST to internal header.
Check for type validity during FcPatternAddWithBinding, don't verify type
    in FcFontMatch, don't call FcCanonicalize here (which always does a
    deep copy).
reviewed by: plam
2005-11-24 21:40:20 +00:00
Patrick Lam 4f8b266fd9 Make FcCompareString and FcCompareFamily less expensive. Only add a value
for FC_FAMILY if the proposed value is a string.
reviewed by: plam
2005-11-24 20:20:26 +00:00
Patrick Lam 1c5b6345b9 Don't add current_arch_start more than once.
Fix ordering of ALIGN with respect to saving block_ptr; add another ALIGN
    to fcfs.c.
reviewed by: plam
2005-11-17 15:43:39 +00:00
Patrick Lam 7fd7221e68 Add *NeededBytesAlign(), which overestimates the padding which is later
added by the new ALIGN macro. Fix alignment problems on ia64 and s390
    by bumping up block_ptr appropriately. (Earlier version by Andreas
    Schwab).
Use sysconf to determine proper PAGESIZE value; this appears to be
    POSIX-compliant. (reported by Andreas Schwab)
reviewed by: plam
2005-11-16 15:55:17 +00:00
Patrick Lam ea9726b620 Fix argument ordering problem in call to FcPatternTransferFullFname. 2005-11-03 04:45:57 +00:00
Patrick Lam 7358dae49b Fix warnings and embarrassing double-free error. 2005-11-03 04:23:22 +00:00
Patrick Lam d7b3ac6367 Don't zero out full names for FC_REF_CONSTANT fonts; also, duplicate full
names when transferring, and free full names when freeing the
    associated font. Reported by Jinghua Luo.
2005-11-02 15:29:53 +00:00
Patrick Lam 303bcf9b9d Revert the previous patch and commit the correct patch: I forgot a
canonicalization in FcValueListSerialize, so that it would choke on
    already-serialized input files. Duh!
2005-11-02 07:37:00 +00:00
Patrick Lam 793154ed8d Copy the full pathname whenever duplicating an FcPattern; otherwise,
applications continue breaking.
2005-11-01 06:57:25 +00:00
Patrick Lam e77c17184a Reinstate basename patch, but keep a hash table linking FcPatterns to their
fully-qualified font names for clients' benefit. Clients only pay for
    the font names once they request the FC_FILE property from an
    FcPattern, but the font name is malloc'd at that point (i.e. not
    mmapped: that's impossible, since it may vary between machines.)
    Clients do have to pay for a copy of the path name per cache file.
Note that FcPatternGetString now does some rewriting if you ask for an
    FC_FILE, appending the pathname as appropriate.
2005-11-01 05:26:27 +00:00
Patrick Lam 23787a8f1b Add padding to make valgrind and glibc not hate each other when calling
strlen().
2005-10-06 20:45:25 +00:00
Patrick Lam e3ff8a4ea6 Remove debugging printf (oops). 2005-09-23 02:33:55 +00:00
Patrick Lam 67accef4d3 Fix more gcc4 warnings:
- Cast sizeof to int, to shut up signedness warnings in comparison.
- Add consts where appropriate.
reviewed by: Patrick Lam <plam@mit.edu>
2005-09-22 23:45:53 +00:00
Patrick Lam 9fe2bd7ab0 Add missing FcValueCanonicalize on call to FcPatternAdd. 2005-09-16 04:57:18 +00:00
Patrick Lam 8245771d5a Merge with HEAD and finish the GCC 4 cleanups (no more warnings!) 2005-09-11 02:16:09 +00:00
Patrick Lam 07b3e57663 Apply Matthias Clasen's patch to fix obvious bogosity (i.e. missing
FcObjectPtrU).
2005-09-01 18:29:28 +00:00
Patrick Lam 7f37423d8c Replace FcObjectStaticName by FcStrStaticName. Implement serialization of
'object' table (strings pointed to by FcPatternElt->object and used as
    keys) and loading of object table from cache file if more strings are
    present in cache file than in current version of fontconfig. Hash the
    object table in memory.
2005-08-27 02:34:24 +00:00
Patrick Lam 4262e0b385 Overhaul the serialization system to create one mmapable file per directory
and distribute bytes for each directory from a single malloc for that
    directory. Store pointers as differences between the data pointed to
    and the pointer's address (s_off = s - v). Don't serialize data
    structures that never actually get serialized. Separate strings used
    for keys from strings used for values (in FcPatternElt and FcValue,
    respectively). Bump FC_CACHE_VERSION to 2.
2005-08-24 06:21:30 +00:00
Patrick Lam 212c9f437e #ifdef out old cache stuff, replace with first version of new mmapping
cache. Add *Read and *Write procedures which mmap in and write out the
    fontconfig data structures to disk. Currently, create cache in /tmp,
    with different sections for each architecture (as returned by uname's
    .machine field. Run the fc-cache binary to create a new cache file;
    fontconfig then uses this cache file on subsequent runs, saving lots of
    memory. Also fixes a few bugs and leaks.
2005-07-25 04:10:09 +00:00
Patrick Lam e1b9d091c6 Forward port cworth's patch to branch. 2005-07-15 18:49:12 +00:00
Patrick Lam 0fa680f076 Convert ObjectPtr from a fat structure to a simple index into an id table;
ids can be positive (for static strings) or negative (for dynamic
    strings). Static strings belong to a single buffer, while dynamic
    strings are independently allocated.
2005-07-07 12:09:10 +00:00
Patrick Lam cd2ec1a940 Add functionality to allow fontconfig data structure serialization.
This patch allows the fundamental fontconfig data structures to be
    serialized. I've converted everything from FcPattern down to be able to
    use *Ptr objects, which can be either static or dynamic (using a union
    which either contains a pointer or an index) and replaced storage of
    pointers in the heap with the appropriate *Ptr object. I then changed
    all writes of pointers to the heap with a *CreateDynamic call, which
    creates a dynamic Ptr object pointing to the same object as before.
    This way, the fundamental fontconfig semantics should be unchanged; I
    did not have to change external signatures this way, although I did
    change some internal signatures. When given a *Ptr object, just run *U
    to get back to a normal pointer; it gives the right answer regardless
    of whether we're using static or dynamic storage.
I've also implemented a Fc*Serialize call. Calling FcFontSetSerialize
    converts the dynamic FcFontSets contained in the config object to
    static FcFontSets and also converts its dependencies (e.g. everything
    you'd need to write to disk) to static objects. Note that you have to
    call Fc*PrepareSerialize first; this call will count the number of
    objects that actually needs to be allocated, so that we can avoid
    realloc. The Fc*Serialize calls then check the static pointers for
    nullness, and allocate the buffers if necessary. I've tested the
    execution of fc-list and fc-match after Fc*Serialize and they appear to
    work the same way.
2005-06-28 03:41:02 +00:00
Ross Burton 2ff4f0760a Check that a pattern isn't already frozen in FcPatternFreeze 2005-04-13 09:11:52 +00:00