[Fontconfig] mmaping FcInit

Owen Taylor otaylor at redhat.com
Sat Mar 26 22:49:53 EST 2005


On Sat, 2005-03-26 at 10:10 +0100, Lars Knoll wrote:
> On Friday 25 March 2005 22:25, Owen Taylor wrote:
> > On Fri, 2005-03-25 at 01:53 -0500, Patrick Lam wrote:
> > > BTW, Owen's suggested struct:
> > > struct FcPattern {
> > >     int refcount;
> > >     FcPatternStorage storage; /* dynamic, static */
> > >
> > >     union {
> > >       FcPatternDynamic *dynamic;
> > >       FcPatternStatic *static;
> > >     } u;
> > >   };
> > >
> > > still seems to be a struct, and thus requiring mallocness and a pointer.
> >
> > The point of my suggestion is that we need a single *public* structure
> > for:
> >
> >   - Patterns retrieved from the database of fonts on disk
> >   - Patterns created on the fly through the FcPattern API
> >
> > But that public structure can be small, lightweight, and created on
> > the fly.
> 
> Do you really? FcPattern is a completely opaque type. For patterns on the 
> disk, you can just return a pointer to them. All that should be needed is one 
> bitflag in the pattern structure itself marking it a begin readonly, and 
> using the same data structure for dynamic patterns. 
> 
> This requires using the same endianness and packing for dynamic and static 
> patterns and thus makes building up dynamic pattern a little more complex, 
> but I don't think the overhead would be noticable (and the code is needed for 
> the cache building anyway). The advantage would the that retrieving of 
> properties from the pattern could use the same code.

My thought that it would be hard to create a structure that both worked
on disk and was suitable for efficient implementation operations like
FcPatternAdd/FcPatternDel. The fundamental problem I see is that
FcPatternAdd requires allocating more storage, but you can't call
realloc on the FcPattern pointer.

I could be missing some tricky way to set things up, however.

Changing things so that a static FcPattern was only one memory block
would be easier, though if you don't reference count static patterns,
you may have trouble with font database changes,

						Owen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20050326/860af19f/attachment.pgp


More information about the Fontconfig mailing list