hey, if i have understood correctly the code, it is possible to call several time FcInit, but FcFini can be called only once. That''s a problem when several libraries use fontconfig (like poppler + qt) Would it be possible to use a ref count for the initialisation / finalization of fontconfig ? thank you Vincent Torri
On 03/30/2009 04:56 AM, Vincent Torri wrote:> hey, > > if i have understood correctly the code, it is possible to call several > time FcInit, but FcFini can be called only once. That''s a problem when > several libraries use fontconfig (like poppler + qt)Hi, My understanding is that: * Calling FcInit() is optional. All fontconfig entry points check and initialize the library if needed. * FcFini() is designed to only be called by debugging code from applications, not for normal use by other libraries.> Would it be possible to use a ref count for the initialisation / > finalization of fontconfig ?It would be feasible if FcInit() was mandatory. But when it''s optional, I''m not sure how to define the semantics. What will the implicit initialization do? Increase the ref count or not? behdad> thank you > > Vincent Torri
On Mon, 2009-03-30 at 12:20 -0400, Behdad Esfahbod wrote:> * Calling FcInit() is optional. All fontconfig entry points check and > initialize the library if needed.FcFini was added so that valgrind output could be used to discover leaks in fontconfig. Normal applications should not use it, although I can see why they might want to (eliminate memory usage after a period of using fontconfig).> * FcFini() is designed to only be called by debugging code from > applications, not for normal use by other libraries.Even so, it seems like it should be fairly easy to make it mostly harmless to call FcFini in normal application use.> > Would it be possible to use a ref count for the initialisation / > > finalization of fontconfig ? > > It would be feasible if FcInit() was mandatory. But when it''s optional, I''m > not sure how to define the semantics. What will the implicit initialization > do? Increase the ref count or not?It sounds fairly easy to me - FcFini wouldn''t actually do anything until the ref count hit zero. We''d presumably need to add another FcFiniReallyDoStuff so that people wanting the current valgrind behaviour could still get that. Or, perhaps, we should add a separate function that would do a ref-counting version of FcFini instead. -- keith.packard at intel.com -------------- 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/20090330/fb0d5138/attachment.pgp
hey,>> if i have understood correctly the code, it is possible to call several >> time FcInit, but FcFini can be called only once. That''s a problem when >> several libraries use fontconfig (like poppler + qt) > > Hi, > > My understanding is that: > > * Calling FcInit() is optional. All fontconfig entry points check and > initialize the library if needed. > > * FcFini() is designed to only be called by debugging code from > applications, not for normal use by other libraries. > >> Would it be possible to use a ref count for the initialisation / >> finalization of fontconfig ? > > It would be feasible if FcInit() was mandatory. But when it''s optional, I''m > not sure how to define the semantics. What will the implicit initialization > do? Increase the ref count or not?do something like that: static int _fontconfig_init_count = 0; int FcIni() { if (!_fontconfig_init_count) { /* do what is needed during the first call of initialization */ } return ++_fontconfig_init_count; } int FcFini() { --_fontconfig_init_count; if (!_fontconfig_init_count) { /* do what is needed during finalization */ } return _fontconfig_init_count; } regards Vincent Torri