[PATCH] xf86-video-mga: replace deprecated X*alloc functions

Ian Romanick idr at freedesktop.org
Mon Apr 4 13:55:22 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/02/2011 11:17 AM, Nicolas Kaiser wrote:
> diff --git a/src/mga_dri.c b/src/mga_dri.c
> index 2723dd8..8b1d751 100644
> --- a/src/mga_dri.c
> +++ b/src/mga_dri.c
> @@ -92,24 +92,24 @@ static Bool MGAInitVisualConfigs( ScreenPtr pScreen )
>     case 16:
>        numConfigs = 8;
>  
> -      pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
> +      pConfigs = (__GLXvisualConfig*)calloc( 1, sizeof(__GLXvisualConfig) *
>  						numConfigs );

Why?  I think the correct thing is the switch numConfigs and sizeof(...)
in all these cases.  Calling calloc like that is just silly.  This
comment applies to all the xcalloc -> calloc changes in this file.

>        if ( !pConfigs ) {
>  	 return FALSE;
>        }
>  
> -      pMGAConfigs = (MGAConfigPrivPtr)xcalloc( sizeof(MGAConfigPrivRec),
> +      pMGAConfigs = (MGAConfigPrivPtr)calloc( 1, sizeof(MGAConfigPrivRec) *
>  						 numConfigs );
>        if ( !pMGAConfigs ) {
> -	 xfree( pConfigs );
> +	 free( pConfigs );
>  	 return FALSE;
>        }
>  
> -      pMGAConfigPtrs = (MGAConfigPrivPtr*)xcalloc( sizeof(MGAConfigPrivPtr),
> +      pMGAConfigPtrs = (MGAConfigPrivPtr*)calloc( 1, sizeof(MGAConfigPrivPtr) *
>  						     numConfigs );
>        if ( !pMGAConfigPtrs ) {
> -	 xfree( pConfigs );
> -	 xfree( pMGAConfigs );
> +	 free( pConfigs );
> +	 free( pMGAConfigs );
>  	 return FALSE;
>        }
>  
> @@ -183,24 +183,24 @@ static Bool MGAInitVisualConfigs( ScreenPtr pScreen )
>     case 32:
>        numConfigs = 8;
>  
> -      pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
> +      pConfigs = (__GLXvisualConfig*)calloc( 1, sizeof(__GLXvisualConfig) *
>  						numConfigs );
>        if ( !pConfigs ) {
>  	 return FALSE;
>        }
>  
> -      pMGAConfigs = (MGAConfigPrivPtr)xcalloc( sizeof(MGAConfigPrivRec),
> +      pMGAConfigs = (MGAConfigPrivPtr)calloc( 1, sizeof(MGAConfigPrivRec) *
>  						 numConfigs );
>        if ( !pMGAConfigs ) {
> -	 xfree( pConfigs );
> +	 free( pConfigs );
>  	 return FALSE;
>        }
>  
> -      pMGAConfigPtrs = (MGAConfigPrivPtr*)xcalloc( sizeof(MGAConfigPrivPtr),
> +      pMGAConfigPtrs = (MGAConfigPrivPtr*)calloc( 1, sizeof(MGAConfigPrivPtr) *
>  						     numConfigs );
>        if ( !pMGAConfigPtrs ) {
> -	 xfree( pConfigs );
> -	 xfree( pMGAConfigs );
> +	 free( pConfigs );
> +	 free( pMGAConfigs );
>  	 return FALSE;
>        }
>  
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2aMDoACgkQX1gOwKyEAw9J6gCdGIvzAiB1FCVRyAf4CIHXAwzZ
ufcAniOtSPtqg1VRZ+FedhCUu2YeLxSI
=J7I4
-----END PGP SIGNATURE-----


More information about the xorg-devel mailing list