summaryrefslogtreecommitdiff
path: root/src/fclang.c
diff options
context:
space:
mode:
authorPatrick Lam <plam@MIT.EDU>2005-07-25 04:10:09 +0000
committerPatrick Lam <plam@MIT.EDU>2005-07-25 04:10:09 +0000
commit212c9f437e959fbdc5fe344c67b8c1cf8ca63edb (patch)
treea5a82c8017ff6461dd8bdb4bb3e218af91b22ee6 /src/fclang.c
parente1b9d091c661b0e1d1e9f73c5c55ad53959c55c7 (diff)
#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.
Diffstat (limited to 'src/fclang.c')
-rw-r--r--src/fclang.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/fclang.c b/src/fclang.c
index 28b2d9b..515e3cf 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -774,3 +774,31 @@ FcLangSetSerialize(FcLangSet *l)
new.u.stat = p;
return new;
}
+
+FcBool
+FcLangSetWrite (int fd, FcCache *metadata)
+{
+ metadata->langsets_length = langset_ptr;
+ metadata->langsets_offset = FcCacheNextOffset(fd);
+
+ if (langset_ptr > 0)
+ {
+ lseek (fd, metadata->langsets_offset, SEEK_SET);
+ return write(fd, langsets,
+ metadata->langsets_length * sizeof(FcLangSet)) != -1;
+ }
+ return FcTrue;
+}
+
+FcBool
+FcLangSetRead (int fd, FcCache metadata)
+{
+ langsets = mmap(NULL,
+ metadata.langsets_length * sizeof (FcLangSet),
+ PROT_READ,
+ MAP_SHARED, fd, metadata.langsets_offset);
+ if (langsets == MAP_FAILED)
+ return FcFalse;
+ langset_count = langset_ptr = metadata.langsets_length;
+ return FcTrue;
+}