Heyto allow FcFini to be called the same number of times than FcInit, here is a patch that uses a ref count in these 2 functions.
regards Vincent Torri
diff --git a/src/fcinit.c b/src/fcinit.c index 0998abc..ae98efe 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -25,6 +25,8 @@ #include "fcint.h" #include <stdlib.h> +static int _fcInitCount = 0; + static FcConfig * FcInitFallbackConfig (void) { @@ -119,14 +121,20 @@ FcInit (void) { FcConfig *config; - if (_fcConfig) + if (!_fcInitCount) + { + if (_fcConfig) + return FcTrue; + config = FcInitLoadConfigAndFonts (); + if (!config) + return FcFalse; + FcConfigSetCurrent (config); + if (FcDebug() & FC_DBG_MEMORY) + FcMemReport (); return FcTrue; - config = FcInitLoadConfigAndFonts (); - if (!config) - return FcFalse; - FcConfigSetCurrent (config); - if (FcDebug() & FC_DBG_MEMORY) - FcMemReport (); + } + + _fcInitCount++; return FcTrue; } @@ -136,13 +144,18 @@ FcInit (void) void FcFini (void) { - if (_fcConfig) - FcConfigDestroy (_fcConfig); + _fcInitCount--; - FcPatternFini (); - FcCacheFini (); - if (FcDebug() & FC_DBG_MEMORY) - FcMemReport (); + if (!_fcInitCount) + { + if (_fcConfig) + FcConfigDestroy (_fcConfig); + + FcPatternFini (); + FcCacheFini (); + if (FcDebug() & FC_DBG_MEMORY) + FcMemReport (); + } } /*
_______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig