[PATCH 2/5] xfree86: xv: set pointers to NULL in xf86XVFreeAdaptor

Jeremy Huddleston jeremyhu at apple.com
Tue Apr 5 09:47:15 PDT 2011


Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

On Apr 4, 2011, at 10:54 AM, Tiago Vignatti wrote:

> As a good practice and for eventual double frees.
> 
> The reason of this patch is due the resilience of xf86XVInitAdaptors, where
> for any adaptor failure it's able to keep trying registering the following
> ones.
> 
> I discussed briefly with Pauli and Ville about a bigger refactoring of such
> function, doing it in a way to return instantly when a failure happens; after
> all that's how mostly of the other driver functions work. Instead, we just
> thought that xf86XVInitAdaptors is wise and cool, and eventually other driver
> functions should be even following the main idea of resilience.
> 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
> 
> hw/xfree86/common/xf86xv.c |    6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
> index f87af4c..b46dfef 100644
> --- a/hw/xfree86/common/xf86xv.c
> +++ b/hw/xfree86/common/xf86xv.c
> @@ -313,6 +313,7 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
>    int i;
> 
>    free(pAdaptor->name);
> +   pAdaptor->name = NULL;
> 
>    if(pAdaptor->pEncodings) {
>       XvEncodingPtr pEncode = pAdaptor->pEncodings;
> @@ -320,9 +321,11 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
>       for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
> 	  free(pEncode->name);
>       free(pAdaptor->pEncodings);
> +      pAdaptor->pEncodings = NULL;
>    }
> 
>    free(pAdaptor->pFormats);
> +   pAdaptor->pFormats = NULL;
> 
>    if(pAdaptor->pPorts) {
>       XvPortPtr pPort = pAdaptor->pPorts;
> @@ -341,6 +344,7 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
> 	  }
>       }
>       free(pAdaptor->pPorts);
> +      pAdaptor->pPorts = NULL;
>    }
> 
>    if(pAdaptor->pAttributes) {
> @@ -354,6 +358,8 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
> 
>    free(pAdaptor->pImages);
>    free(pAdaptor->devPriv.ptr);
> +   pAdaptor->pImages = NULL;
> +   pAdaptor->devPriv.ptr = NULL;
> }
> 
> static Bool
> -- 
> 1.7.0.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 



More information about the xorg-devel mailing list