Re: [patch] using ref count in FcInit() and FcFinit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/20/2009 01:39 AM, Vincent Torri wrote:
>
> Hey

Hey,

> to 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.

Comments below.

> @@ -119,14 +121,20 @@ FcInit (void)
>   {
>       FcConfig	*config;
>
> +    if (!_fcInitCount)
> +    {
> +	if (_fcConfig)
> +	    return FcTrue;
> +	config = FcInitLoadConfigAndFonts ();
> +	if (!config)
> +	    return FcFalse;
> +	FcConfigSetCurrent (config);
> +	if (FcDebug()&  FC_DBG_MEMORY)
> +	    FcMemReport ();
> +    }
> +
> +    _fcInitCount++;
>       return FcTrue;
>   }

Currently one can do FcConfigDestroy(FcConfigGetCurrent()) to use a brand new 
configuration (ie. reset the default configuration).  However, everytime doing 
that causes an internal invocation of FcInit() and increasing the refcount. 
That's wrong.  I think we need a separate bool and a non-ref'ing _FcInit for 
the implicit initialization.  The implicit initialization should add up to 
only one reference.  Which is the one the unpaired FcFini() releases.

Also, the two return paths in the conditional do not increase the refcount and 
are hence wrong.  For example, if one does a FcConfigSetCurrent(), then the 
ref count will never increase and stay at zero.

Fix those and I'll happily commit this :).

behdad
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux