summaryrefslogtreecommitdiff
path: root/src/fccache.c
AgeCommit message (Collapse)AuthorFilesLines
2012-04-25Bug 39278 - make usage of mmap optionalHEADmasterAkira TAGOH1-2/+75
Stop using mmap() if the cache file is stored on NFS. also added FONTCONFIG_USE_MMAP environment variable to enforce the use of or not the use of mmap(2) regardless of what the filesystem the cache files are stored on.
2012-04-23Create CACHEDIR.TAG when fc-cache is run or only when the cache directory is ↵Akira TAGOH1-0/+85
created at the runtime. Also add FcCacheCreateTagFile() API to do create CACHEDIR.TAG on the cache directory.
2012-04-18Bug 25151 - Move cleanCacheDirectory() from fc-cache.c intoAkira TAGOH1-0/+91
the library Add FcDirCacheScan() API to clean up the cache files in the directory.
2012-04-17Use posix_fadvise to speed startupKeith Packard1-0/+3
Given that fontconfig will scan all of the cache file data during the first font search, ask the kernel to start reading the pages right away. Signed-off-by: Keith Packard <keithp@keithp.com>
2012-04-12Bug 27526 - Compatibility fix for old windows sytemsAkira TAGOH1-3/+0
Patch from Gianluigi Tiesi
2012-02-28Bug 41694 - FcCache functions have random-number-generator side effectsAkira TAGOH1-10/+59
Use the own random number generator state if possible.
2012-02-21FcStat: change to FcChar8 for first argMike Frysinger1-2/+2
This shouldn't affect the ABI, makes FcStat more like the rest of the fontconfig API, and fixes warnings where we pass FcChar8* pointers in to this func from other places. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21delete unused variablesMike Frysinger1-4/+2
Newer gcc is better at detecting set-but-unused variables. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-09-24Bug 41171 - Invalid use of memsetBehdad Esfahbod1-1/+1
2011-03-14Always define FcStat as a functionBehdad Esfahbod1-2/+11
Such that first arg is const char *. We also need to make more changes in that function as part of some other bug.
2010-12-28Make fc-arch stuff cross-compiling-safeBehdad Esfahbod1-1/+2
Fixes: Bug 32679 - fontconfig-2.8.0 does not cross compile Bug 25462 - Cross-compilation doesn't work
2010-11-10Cleanup copyright notices to replace "Keith Packard" with "the author(s)"Behdad Esfahbod1-2/+2
2010-04-12Remove all training whitespacesBehdad Esfahbod1-33/+33
2009-06-24Correctly handle mmap() failure (#21062)Serge van den Boom1-0/+2
2009-03-13Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all filesBehdad Esfahbod1-2/+2
2009-02-15[cache] After writing cache to file, update the internal copy to reflect thisBehdad Esfahbod1-0/+16
Only do it for small caches though. For large cache we'd better off loading the cache file again, mmap()ing it. Based on patch from Diego Santa Cruz.
2009-02-15[fccache] Make sure the cache is current when reusing from open cachesBehdad Esfahbod1-1/+7
Reported by Diego Santa Cruz.
2009-02-13Explicitly chmod() directories (bug #18934)Behdad Esfahbod1-3/+11
Two changes: - after mkdir(), we immediately chmod(), such that we are not affected by stupid umask's. - if a directory we want to use is not writable but exists, we try a chmod on it. This is to recover from stupid umask's having affected us with older versions.
2009-02-13Consistently use FcStat() over stat() in all placesBehdad Esfahbod1-6/+1
2009-02-13[fccache] Consistently use FcStat() over stat() (bug #18195)Behdad Esfahbod1-1/+1
2007-11-13Workaround for stat() brokenness in Microsoft's C library (bug 8526)Tor Lillqvist1-1/+92
Fix a couple of longstanding problems with fontconfig on Windows that manifest themselves especially in GIMP. The root cause to the problems is in Microsoft's incredibly stupid stat() implementation. Basically, stat() returns wrong timestamp fields for files on NTFS filesystems on machines that use automatic DST switching. See for instance http://bugzilla.gnome.org/show_bug.cgi?id=154968 and http://www.codeproject.com/datetime/dstbugs.asp As fccache.c now looks at more fields in the stat struct I fill in them all. I noticed that fstat() is used only on a fd just after opening it, so on Win32 I just call my stat() replacement before opening instead... Implementing a good replacement for fstat() would be harder because the code in fccache.c wants to compare inode numbers. There are no (readily accessible) inode numbers on Win32, so I fake it with the hash of the full file name, in the case as it is on disk. And fstat() doesn't know the full file name, so it would be rather hard to come up with a inode number to identify the file. The patch also adds similar handling for the cache directory as for the fonts directory: If a cachedir element in fonts.conf contains the magic string "WINDOWSTEMPDIR_FONTCONFIG_CACHE" it is replaced at runtime with a path under the machine's (or user's) temp folder as returned by GetTempPath(). I don't want to hardcode any pathnames in a fonts.conf intended to be distributed to end-users, most of which who wouldn't know how to edit it anyway. And requiring an installer to edit it gets complicated.
2007-11-03Make file_stat argument to FcDirCacheLoadFile optional.Keith Packard1-0/+3
Allow file_stat to be NULL by using a local stat structure in that case.
2007-10-18Must not insert cache into hash table before completely validating.Keith Packard1-2/+2
The cache was inserted into the hash table before the timestamps in the cache were verified; if that verification failed, an extra pointer to the now freed cache would be left in the hash table. FcFini would fail an assertion as a result.
2007-10-18Don't use X_OK bit when checking for writable directories (bug 12438)Keith Packard1-2/+2
Some mingw versions have broken X_OK checking; instead of trying to work around this in a system-depedent manner, simply don't bother checking for X_OK along with W_OK as such cases are expected to be mistakes, and not sensible access control.
2007-10-18Comment about mmaping cache files was misleading.Keith Packard1-1/+2
2007-10-18Store font directory mtime in cache file.Keith Packard1-23/+41
Instead of relying on mtime ordering between a directory and its associated cache file, write the directory mtime into the cache file itself. This makes cache file checks more reliable across file systems. This change is made in a way that old programs can use new cache files, but new programs will need new cache files.
2007-08-05Free temporary string in FcDirCacheUnlink (Bug #11758)Keith Packard1-0/+1
In FcDirCacheUnlink(), the line cache_hashed = FcStrPlus (cache_dir, cache_base); allocates memory in cache_hashed that is never free()'d before the function exits. Reported by Ben Combee.
2006-12-02Don't use varargs CPP macros in fccache.c. (bug 8733)Kean Johnston1-6/+7
src/fccache.c uses a trick to try and use a function name that is also a macro name. It does this using the varargs args() macro. Replace that with separate macros for each number of formals.
2006-09-17More fixes for Win32 building (bug 8311)Han-Wen Nienhuys1-1/+2
Our build system barfs on autogen.sh, which ignores --noconfigure. Configure needs a host of options to make the cross compile work in our case. Fix typo in fccache.c
2006-09-17FcStrCanonFileName buggy for mingw. (bug 8311)Han-Wen Nienhuys1-0/+5
FcStrCanonFileName checks whether s[0] == '/', and recurses if not. This only works on POSIX. On dos, this crashes with a stack overflow. The patch attached splits this functionality in two functions (FcStrCanonAbsoluteFilename) and uses GetFullPathName on windows to get an absolute path. It also fixes a number of other issues. With this patch, LilyPond actually produces output on Windows.
2006-09-17Detect and use available random number generator (bug 8308)Keith Packard1-1/+12
Prefer random over lrand48 over rand
2006-09-09Insert newly created caches into reference data structure.Keith Packard1-3/+14
All caches used in the application must be in the cache reference list so internal references can be tracked correctly. Failing to have newly created caches in the list would cause the cache to be deallocated while references were still present.
2006-09-07Reference patterns in FcCacheCopySet.Keith Packard1-1/+6
As patterns are put into the font set copy, mark them as referenced so the cache stays around while the font set is in use.
2006-09-05Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)Keith Packard1-0/+3
Using a simple shell script that processes the public headers, two header files are constructed that map public symbols to hidden internal aliases avoiding the assocated PLT entry for referring to a public symbol. A few mistakes in the FcPrivate/FcPublic annotations were also discovered through this process
2006-09-04Correct reference count when sharing cache file objects.Keith Packard1-1/+3
Multiple maps of the same cache file share the same mapped object; bump the cache object reference count in this case
2006-09-04Make cache reference counting more efficient.Keith Packard1-0/+9
Eliminate need to reference cache object once per cached font, instead just count the number of fonts used from the cache and bump the reference count once by that amount. I think this makes this refernece technique efficient enough for use.
2006-09-04Reference count cache objects.Keith Packard1-64/+191
Caches contain patterns and character sets which are reference counted and visible to applications. Reference count the underlying cache object so that it stays around until all reference objects are no longer in use. This is less efficient than just leaving all caches around forever, but does avoid eternal size increases in case applications ever bother to actually look for changes in the font configuration.
2006-09-04Leave cache files mapped permanently.Keith Packard1-31/+112
Without reference counting on cache objects, there's no way to know when an application is finished using objects pulled from the cache. Until some kinf of cache reference counting can be done, leave all cache objects mapped for the life of the library (until FcFini is called). To mitigate the cost of this, ensure that each instance of a cache file is mapped only once.
2006-09-04Hide private functions in shared library. Export functionality for utilities.Keith Packard1-0/+48
Borrowing header stuff written for cairo, fontconfig now exposes in the shared library only the symbols which are included in the public header files. All private symbols are hidden using suitable compiler directives. A few new public functions were required for the fontconfig utility programs (fc-cat and fc-cache) so those were added, bumping the .so minor version number in the process.
2006-09-02Allow font caches to contain newer version numbersKeith Packard1-2/+2
Use the version number inside the cache file to mark backward compatible changes while continuing to reserve the filename number for incompatible changes.
2006-09-01Pass directory information around in FcCache structure. Freeze charsets.Keith Packard1-178/+122
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-08-31Revert ABI changes from version 2.3Keith Packard1-2/+14
Accidental ABI changes and additions were discovered by looking at the differences in fontconfig.h. All of those have been reverted.
2006-08-31With no args, fc-cat now dumps all directories.Keith Packard1-6/+10
Automatically list all font directories when no arguments are given to fc-cat. Also add -r option to recurse from specified cache directories. fc-cat also now prints the cache filename in verbose mode, along with the related directory name.
2006-08-31Automatically remove invalid cache files.Keith Packard1-3/+3
Cache files for missing or more recently modified directories are automatically removed at the end of every fc-cache run.
2006-08-30Fix fc-cat again. Sigh.Keith Packard1-9/+10
Internal interfaces in cache management changed again...
2006-08-30Skip broken caches. Cache files are auto-written, don't rewrite in fc-cache.Keith Packard1-70/+78
Validate cache contents and skip broken caches, looking down cache path for valid ones. Every time a directory is scanned, it will be written to a cache file if possible, so fc-cache doesn't need to re-write the cache file. This makes detecting when the cache was generated a bit tricky, so we guess that if the cache wasn't valid before running and is valid afterwards, the cache file was written. Also, allow empty charsets to be serialized with null leaves/numbers. Eliminate a leak in FcEdit by switching to FcObject sooner. Call FcFini from fc-match to make valgrind happy.
2006-08-30FcCharSetSerialize was using wrong offset for leaves. Make fc-cat work.Keith Packard1-4/+2
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-30Rework cache files to use offsets for all data structures.Keith Packard1-350/+231
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-27Fix up fc-cache and fc-cat for no global cache changes.Keith Packard1-24/+53
fc-cache and fc-cat use internal (fcint.h) APIs that have changed with the elimination of the global cache.
2006-08-27Eliminate global cache. Eliminate multi-arch cache code.Keith Packard1-943/+108
With the removal of the in-directory cache files, and the addition of per-user cache directories, there is no longer any reason to preserve the giant global cache file. Eliminating of this unifies the cache structure and simplifies the overall caching strategies greatly.