[PATCH] savage: Replace deprecated x(c)alloc/xfree with m/calloc/free

Tormod Volden lists.tormod at gmail.com
Sun Jan 23 03:47:02 PST 2011


From: Tormod Volden <debian.tormod at gmail.com>

sed -i 's/xalloc/malloc/g; s/xcalloc/calloc/g; s/xfree/free/g'

Also replace xrealloc with realloc.
---
 src/savage_dga.c    |    6 ++--
 src/savage_dri.c    |   70 +++++++++++++++++++++++++-------------------------
 src/savage_driver.c |   22 ++++++++--------
 src/savage_hwmc.c   |   10 +++---
 src/savage_vbe.c    |   10 +++---
 src/savage_video.c  |   26 +++++++++---------
 6 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/src/savage_dga.c b/src/savage_dga.c
index eb1c5d2..7a9e22c 100644
--- a/src/savage_dga.c
+++ b/src/savage_dga.c
@@ -107,15 +107,15 @@ SavageSetupDGAMode(
 	otherPitch = secondPitch ? secondPitch : pMode->HDisplay;
 
 	if(pMode->HDisplay != otherPitch) {
-	    newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec));
+	    newmodes = realloc(modes, (*num + 2) * sizeof(DGAModeRec));
 	    oneMore = TRUE;
 	} else {
-	    newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec));
+	    newmodes = realloc(modes, (*num + 1) * sizeof(DGAModeRec));
 	    oneMore = FALSE;
 	}
 
 	if(!newmodes) {
-	   xfree(modes);
+	   free(modes);
 	   return NULL;
 	}
 	modes = newmodes;
diff --git a/src/savage_dri.c b/src/savage_dri.c
index 190e8ee..e4ebf84 100644
--- a/src/savage_dri.c
+++ b/src/savage_dri.c
@@ -105,24 +105,24 @@ static Bool SAVAGEInitVisualConfigs( ScreenPtr pScreen )
    case 16:
       numConfigs = 8;
 
-      pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
+      pConfigs = (__GLXvisualConfig*)calloc( sizeof(__GLXvisualConfig),
 						numConfigs );
       if ( !pConfigs ) {
 	 return FALSE;
       }
 
-      pSAVAGEConfigs = (SAVAGEConfigPrivPtr)xcalloc( sizeof(SAVAGEConfigPrivRec),
+      pSAVAGEConfigs = (SAVAGEConfigPrivPtr)calloc( sizeof(SAVAGEConfigPrivRec),
 						 numConfigs );
       if ( !pSAVAGEConfigs ) {
-	 xfree( pConfigs );
+	 free( pConfigs );
 	 return FALSE;
       }
 
-      pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)xcalloc( sizeof(SAVAGEConfigPrivPtr),
+      pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)calloc( sizeof(SAVAGEConfigPrivPtr),
 						     numConfigs );
       if ( !pSAVAGEConfigPtrs ) {
-	 xfree( pConfigs );
-	 xfree( pSAVAGEConfigs );
+	 free( pConfigs );
+	 free( pSAVAGEConfigs );
 	 return FALSE;
       }
 
@@ -201,24 +201,24 @@ static Bool SAVAGEInitVisualConfigs( ScreenPtr pScreen )
    case 32:
       numConfigs = 8;
 
-      pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
+      pConfigs = (__GLXvisualConfig*)calloc( sizeof(__GLXvisualConfig),
 						numConfigs );
       if ( !pConfigs ) {
 	 return FALSE;
       }
 
-      pSAVAGEConfigs = (SAVAGEConfigPrivPtr)xcalloc( sizeof(SAVAGEConfigPrivRec),
+      pSAVAGEConfigs = (SAVAGEConfigPrivPtr)calloc( sizeof(SAVAGEConfigPrivRec),
 						 numConfigs );
       if ( !pSAVAGEConfigs ) {
-	 xfree( pConfigs );
+	 free( pConfigs );
 	 return FALSE;
       }
 
-      pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)xcalloc( sizeof(SAVAGEConfigPrivPtr),
+      pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)calloc( sizeof(SAVAGEConfigPrivPtr),
 						     numConfigs );
       if ( !pSAVAGEConfigPtrs ) {
-	 xfree( pConfigs );
-	 xfree( pSAVAGEConfigs );
+	 free( pConfigs );
+	 free( pSAVAGEConfigs );
 	 return FALSE;
       }
 
@@ -906,7 +906,7 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
    if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
       pDRIInfo->busIdString = DRICreatePCIBusID(psav->PciInfo);
    } else {
-      pDRIInfo->busIdString            = xalloc(64);
+      pDRIInfo->busIdString            = malloc(64);
       sprintf(pDRIInfo->busIdString,
               "PCI:%d:%d:%d",
               psav->PciInfo->bus,
@@ -960,7 +960,7 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
 
    pDRIInfo->SAREASize = SAREA_MAX;
 
-   pSAVAGEDRI = (SAVAGEDRIPtr)xcalloc( sizeof(SAVAGEDRIRec), 1 );
+   pSAVAGEDRI = (SAVAGEDRIPtr)calloc( sizeof(SAVAGEDRIRec), 1 );
    if ( !pSAVAGEDRI ) {
       DRIDestroyInfoRec( psav->pDRIInfo );
       psav->pDRIInfo = 0;
@@ -970,9 +970,9 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
    }
 
    pSAVAGEDRIServer = (SAVAGEDRIServerPrivatePtr)
-      xcalloc( sizeof(SAVAGEDRIServerPrivateRec), 1 );
+      calloc( sizeof(SAVAGEDRIServerPrivateRec), 1 );
    if ( !pSAVAGEDRIServer ) {
-      xfree( pSAVAGEDRI );
+      free( pSAVAGEDRI );
       DRIDestroyInfoRec( psav->pDRIInfo );
       psav->pDRIInfo = 0;
       xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
@@ -998,9 +998,9 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
    pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
 
    if ( !DRIScreenInit( pScreen, pDRIInfo, &psav->drmFD ) ) {
-      xfree( pSAVAGEDRIServer );
+      free( pSAVAGEDRIServer );
       psav->DRIServerInfo = 0;
-      xfree( pDRIInfo->devPrivate );
+      free( pDRIInfo->devPrivate );
       pDRIInfo->devPrivate = 0;
       DRIDestroyInfoRec( psav->pDRIInfo );
       psav->pDRIInfo = 0;
@@ -1361,21 +1361,21 @@ void SAVAGEDRICloseScreen( ScreenPtr pScreen )
 
    if ( psav->pDRIInfo ) {
       if ( psav->pDRIInfo->devPrivate ) {
-	 xfree( psav->pDRIInfo->devPrivate );
+	 free( psav->pDRIInfo->devPrivate );
 	 psav->pDRIInfo->devPrivate = 0;
       }
       DRIDestroyInfoRec( psav->pDRIInfo );
       psav->pDRIInfo = 0;
    }
    if ( psav->DRIServerInfo ) {
-      xfree( psav->DRIServerInfo );
+      free( psav->DRIServerInfo );
       psav->DRIServerInfo = 0;
    }
    if ( psav->pVisualConfigs ) {
-      xfree( psav->pVisualConfigs );
+      free( psav->pVisualConfigs );
    }
    if ( psav->pVisualConfigsPriv ) {
-      xfree( psav->pVisualConfigsPriv );
+      free( psav->pVisualConfigsPriv );
    }
 }
 
@@ -1466,11 +1466,11 @@ SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
         if (nbox>1) {
 	    /* Keep ordering in each band, reverse order of bands */
-	    pboxNew1 = xalloc(sizeof(BoxRec)*nbox);
+	    pboxNew1 = malloc(sizeof(BoxRec)*nbox);
 	    if (!pboxNew1) return;
-	    pptNew1 = xalloc(sizeof(DDXPointRec)*nbox);
+	    pptNew1 = malloc(sizeof(DDXPointRec)*nbox);
 	    if (!pptNew1) {
-	        xfree(pboxNew1);
+	        free(pboxNew1);
 	        return;
 	    }
 	    pboxBase = pboxNext = pbox+nbox-1;
@@ -1501,14 +1501,14 @@ SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
         if (nbox > 1) {
 	    /*reverse orderof rects in each band */
-	    pboxNew2 = xalloc(sizeof(BoxRec)*nbox);
-	    pptNew2 = xalloc(sizeof(DDXPointRec)*nbox);
+	    pboxNew2 = malloc(sizeof(BoxRec)*nbox);
+	    pptNew2 = malloc(sizeof(DDXPointRec)*nbox);
 	    if (!pboxNew2 || !pptNew2) {
-	        if (pptNew2) xfree(pptNew2);
-	        if (pboxNew2) xfree(pboxNew2);
+	        if (pptNew2) free(pptNew2);
+	        if (pboxNew2) free(pboxNew2);
 	        if (pboxNew1) {
-		    xfree(pptNew1);
-		    xfree(pboxNew1);
+		    free(pptNew1);
+		    free(pboxNew1);
 		}
 	       return;
 	    }
@@ -1563,12 +1563,12 @@ SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
     SAVAGESelectBuffer(pScrn, SAVAGE_FRONT);
 
     if (pboxNew2) {
-        xfree(pptNew2);
-        xfree(pboxNew2);
+        free(pptNew2);
+        free(pboxNew2);
     }
     if (pboxNew1) {
-        xfree(pptNew1);
-        xfree(pboxNew1);
+        free(pptNew1);
+        free(pboxNew1);
     }
 
     BCI_SEND(0xc0020000); /* wait for 2D idle */
diff --git a/src/savage_driver.c b/src/savage_driver.c
index 1cb91f6..b0b26b9 100644
--- a/src/savage_driver.c
+++ b/src/savage_driver.c
@@ -652,7 +652,7 @@ static void SavageFreeRec(ScrnInfoPtr pScrn)
     if (!pScrn->driverPrivate)
 	return;
     SavageUnmapMem(pScrn, 1);
-    xfree(pScrn->driverPrivate);
+    free(pScrn->driverPrivate);
     pScrn->driverPrivate = NULL;
 }
 
@@ -761,7 +761,7 @@ static Bool SavageProbe(DriverPtr drv, int flags)
 	return FALSE;
     if (xf86GetPciVideoInfo() == NULL) {
         if (devSections)
-	    xfree(devSections);
+	    free(devSections);
         return FALSE;
     }
 
@@ -770,7 +770,7 @@ static Bool SavageProbe(DriverPtr drv, int flags)
 				    devSections, numDevSections, drv,
 				    &usedChips);
     if (devSections)
-	xfree(devSections);
+	free(devSections);
     devSections = NULL;
     if (numUsed <= 0)
 	return FALSE;
@@ -850,11 +850,11 @@ static Bool SavageProbe(DriverPtr drv, int flags)
 		    pSavageEnt->HasSecondary = TRUE;
 		}
 	    }
-	    xfree(pEnt);
+	    free(pEnt);
 	}
 
 
-    xfree(usedChips);
+    free(usedChips);
     return foundScreen;
 }
 
@@ -1060,7 +1060,7 @@ static void SavageGetPanelInfo(ScrnInfoPtr pScrn)
 	    if (!pScrn->monitor->maxPixClock)
 		pScrn->monitor->maxPixClock = native->Clock;
 
-	    xfree(native);
+	    free(native);
 	} while (0);
 
 	if( psav->LCDClock > 0.0 )
@@ -1196,7 +1196,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
     if (pScrn->depth == 8)
 	pScrn->rgbBits = 8;
 
-    if (!(psav->Options = xalloc(sizeof(SavageOptions))))
+    if (!(psav->Options = malloc(sizeof(SavageOptions))))
 	return FALSE;
     memcpy(psav->Options, SavageOptions, sizeof(SavageOptions));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, psav->Options);
@@ -1398,7 +1398,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
     pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
 #ifndef XSERVER_LIBPCIACCESS
     if (pEnt->resources) {
-	xfree(pEnt);
+	free(pEnt);
 	SavageFreeRec(pScrn);
 	return FALSE;
     }
@@ -1449,7 +1449,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
     if (pEnt->device->videoRam != 0)
     	pScrn->videoRam = pEnt->device->videoRam;
 
-    xfree(pEnt);
+    free(pEnt);
 
 #ifndef XSERVER_LIBPCIACCESS
     psav->PciTag = pciTag(psav->PciInfo->bus, psav->PciInfo->device,
@@ -3552,7 +3552,7 @@ static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen)
   
     if(psav->shadowFB) {
 	psav->ShadowPitch = BitmapBytePad(pScrn->bitsPerPixel * width);
-	psav->ShadowPtr = xalloc(psav->ShadowPitch * height);
+	psav->ShadowPtr = malloc(psav->ShadowPitch * height);
 	displayWidth = psav->ShadowPitch / (pScrn->bitsPerPixel >> 3);
 	FBStart = psav->ShadowPtr;
     } else {
@@ -4001,7 +4001,7 @@ static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen)
     }
 
     if( psav->DGAModes ) {
-	xfree( psav->DGAModes );
+	free( psav->DGAModes );
 	psav->DGAModes = NULL;
 	psav->numDGAModes = 0;
     }
diff --git a/src/savage_hwmc.c b/src/savage_hwmc.c
index abfe805..905ef87 100644
--- a/src/savage_hwmc.c
+++ b/src/savage_hwmc.c
@@ -224,7 +224,7 @@ Bool SAVAGEInitMC(ScreenPtr pScreen)
  *  Set *num_priv to the number of 32bit words that make up the size of
  *  of the data that priv will point to.
  *
- *  *priv = (long *) xcalloc (elements, sizeof(element))
+ *  *priv = (long *) calloc (elements, sizeof(element))
  *  *num_priv = (elements * sizeof(element)) >> 2;
  *
  **************************************************************************/
@@ -253,7 +253,7 @@ int SAVAGEXvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
     return BadAlloc;
   }
 
-  *priv = xcalloc(1,sizeof(SAVAGEXvMCCreateContextRec));
+  *priv = calloc(1,sizeof(SAVAGEXvMCCreateContextRec));
   contextRec = (SAVAGEXvMCCreateContextRec *)*priv;
 
   if(!*priv) {
@@ -266,7 +266,7 @@ int SAVAGEXvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
   if(drmCreateContext(pSAVAGE->drmFD, &(contextRec->drmcontext) ) < 0) {
     xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
         "SAVAGEXvMCCreateContext: Unable to create DRMContext!\n");
-    xfree(*priv);
+    free(*priv);
     return(BadAlloc);
   }
 
@@ -310,7 +310,7 @@ int SAVAGEXvMCCreateSurface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf,
   /* This size is used for flip, mixer, subpicture and palette buffers*/
   unsigned int offset = ((786*576*2 + 2048)*5 + 2048) & 0xfffff800; 
 
-  *priv = (long *)xcalloc(2,sizeof(long));
+  *priv = (long *)calloc(2,sizeof(long));
 
   if(!*priv) {
     xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
@@ -340,7 +340,7 @@ int SAVAGEXvMCCreateSubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp,
   SavagePtr pSAVAGE = SAVPTR(pScrn);
   int i;
 
-  *priv = (long *)xcalloc(1,sizeof(long));
+  *priv = (long *)calloc(1,sizeof(long));
 
   if(!*priv) {
     xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
diff --git a/src/savage_vbe.c b/src/savage_vbe.c
index afbaa8f..d24da24 100644
--- a/src/savage_vbe.c
+++ b/src/savage_vbe.c
@@ -229,13 +229,13 @@ SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable )
     {
 	if( pMode->RefreshRate )
 	{
-	    xfree( pMode->RefreshRate );
+	    free( pMode->RefreshRate );
 	    pMode->RefreshRate = NULL;
 	}
 	pMode++;
     }
 
-    xfree( *ppTable );
+    free( *ppTable );
 }
 
 
@@ -246,7 +246,7 @@ SavageGetBIOSModeTable( SavagePtr psav, int iDepth )
     SavageModeTablePtr pTable;
 
     pTable = (SavageModeTablePtr) 
-	xcalloc( 1, sizeof(SavageModeTableRec) + 
+	calloc( 1, sizeof(SavageModeTableRec) + 
 		    (nModes-1) * sizeof(SavageModeEntry) );
     if( pTable ) {
 	pTable->NumModes = nModes;
@@ -346,7 +346,7 @@ SavageGetBIOSModes(
 			if( s3vModeTable->RefreshRate )
 			{
 			    s3vModeTable->RefreshRate = (unsigned char *)
-				xrealloc( 
+				realloc( 
 				    s3vModeTable->RefreshRate,
 				    (iRefresh+8) * sizeof(unsigned char)
 				);
@@ -354,7 +354,7 @@ SavageGetBIOSModes(
 			else
 			{
 			    s3vModeTable->RefreshRate = (unsigned char *)
-				xcalloc( 
+				calloc( 
 				    sizeof(unsigned char),
 				    (iRefresh+8)
 				);
diff --git a/src/savage_video.c b/src/savage_video.c
index 3b991e8..311f47a 100644
--- a/src/savage_video.c
+++ b/src/savage_video.c
@@ -384,7 +384,7 @@ void SavageInitVideo(ScreenPtr pScreen)
             adaptors = &newAdaptor;
         } else {
             newAdaptors =  /* need to free this someplace */
-        	xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
+        	malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
             if(newAdaptors) {
         	memcpy(newAdaptors, adaptors, num_adaptors * 
         				sizeof(XF86VideoAdaptorPtr));
@@ -399,7 +399,7 @@ void SavageInitVideo(ScreenPtr pScreen)
         xf86XVScreenInit(pScreen, adaptors, num_adaptors);
 
     if(newAdaptors)
-	xfree(newAdaptors);
+	free(newAdaptors);
 
     if( newAdaptor )
     {
@@ -884,7 +884,7 @@ SavageSetupImageVideo(ScreenPtr pScreen)
 
     xf86ErrorFVerb(XVTRACE,"SavageSetupImageVideo\n");
 
-    if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
+    if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
 			    sizeof(SavagePortPrivRec) +
 			    sizeof(DevUnion))))
 	return NULL;
@@ -2208,18 +2208,18 @@ SavageAllocateSurface(
     surface->width = w;
     surface->height = h;
 
-    if(!(surface->pitches = xalloc(sizeof(int)))) {
+    if(!(surface->pitches = malloc(sizeof(int)))) {
 	SavageFreeMemory(pScrn, surface_memory);
 	return BadAlloc;
     }
-    if(!(surface->offsets = xalloc(sizeof(int)))) {
-	xfree(surface->pitches);
+    if(!(surface->offsets = malloc(sizeof(int)))) {
+	free(surface->pitches);
 	SavageFreeMemory(pScrn, surface_memory);
 	return BadAlloc;
     }
-    if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
-	xfree(surface->pitches);
-	xfree(surface->offsets);
+    if(!(pPriv = malloc(sizeof(OffscreenPrivRec)))) {
+	free(surface->pitches);
+	free(surface->offsets);
 	SavageFreeMemory(pScrn, surface_memory);
 	return BadAlloc;
     }
@@ -2264,9 +2264,9 @@ SavageFreeSurface(
     if(pPriv->isOn)
 	SavageStopSurface(surface);
     SavageFreeMemory(pScrn, pPriv->surface_memory);
-    xfree(surface->pitches);
-    xfree(surface->offsets);
-    xfree(surface->devPrivate.ptr);
+    free(surface->pitches);
+    free(surface->offsets);
+    free(surface->devPrivate.ptr);
 
     return Success;
 }
@@ -2359,7 +2359,7 @@ SavageInitOffscreenImages(ScreenPtr pScreen)
 
     /* need to free this someplace */
     if (!psav->offscreenImages) {
-	if(!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
+	if(!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec))))
 	    return;
 	psav->offscreenImages = offscreenImages;
     } else {
-- 
1.7.0.4



More information about the xorg-devel mailing list