[Xorg-driver-geode] [PATCH] Replace xalloc/xrealloc/xfree/xcalloc with malloc/realloc/free/calloc

Huang, FrankR FrankR.Huang at amd.com
Tue Aug 31 19:30:35 PDT 2010


From: Frank Huang <frankr.huang at amd.com>

* Replace the deprecated functions with new ones
  Refer to "/xserver/include/os.h"

Signed-off-by: Frank Huang <frankr.huang at amd.com>
---
 src/geode_driver.c |    6 +++---
 src/gx_driver.c    |   16 ++++++++--------
 src/gx_randr.c     |    4 ++--
 src/gx_video.c     |   26 +++++++++++++-------------
 src/lx_driver.c    |    4 ++--
 src/lx_memory.c    |   12 ++++++------
 src/lx_output.c    |    2 +-
 src/lx_video.c     |   24 ++++++++++++------------
 src/z4l.c          |   18 +++++++++---------
 9 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/src/geode_driver.c b/src/geode_driver.c
index 43e9506..ff12fee 100644
--- a/src/geode_driver.c
+++ b/src/geode_driver.c
@@ -499,7 +499,7 @@ AmdProbe(DriverPtr drv, int flags)
 			    break;
 			}
 		    }
-		    xfree(pEnt);
+		    free(pEnt);
 		    if (drvr_setup == NULL)
 			return FALSE;
 
@@ -520,9 +520,9 @@ AmdProbe(DriverPtr drv, int flags)
     }
 
     if (usedChips)
-	xfree(usedChips);
+	free(usedChips);
     if (devSections)
-	xfree(devSections);
+	free(devSections);
     DEBUGMSG(1, (0, X_INFO, "AmdProbe: result (%d)!\n", foundScreen));
     return foundScreen;
 }
diff --git a/src/gx_driver.c b/src/gx_driver.c
index 1c25e1a..e2ed44b 100644
--- a/src/gx_driver.c
+++ b/src/gx_driver.c
@@ -447,7 +447,7 @@ GXPreInit(ScrnInfoPtr pScrni, int flags)
 	    pGeode->useVGA = FALSE;
 
 #if INT10_SUPPORT
-	pGeode->vesa = xcalloc(sizeof(VESARec), 1);
+	pGeode->vesa = calloc(sizeof(VESARec), 1);
 #endif
     }
 
@@ -960,19 +960,19 @@ GXCloseScreen(int scrnIndex, ScreenPtr pScrn)
 	XAADestroyInfoRec(pGeode->AccelInfoRec);
 
     if (pGeode->AccelImageWriteBuffers) {
-	xfree(pGeode->AccelImageWriteBuffers[0]);
-	xfree(pGeode->AccelImageWriteBuffers);
+	free(pGeode->AccelImageWriteBuffers[0]);
+	free(pGeode->AccelImageWriteBuffers);
 	pGeode->AccelImageWriteBuffers = NULL;
     }
 
     if (pGeode->AccelColorExpandBuffers) {
-	xfree(pGeode->AccelColorExpandBuffers);
+	free(pGeode->AccelColorExpandBuffers);
 	pGeode->AccelColorExpandBuffers = NULL;
     }
 
     if (pGeode->pExa) {
 	exaDriverFini(pScrn);
-	xfree(pGeode->pExa);
+	free(pGeode->pExa);
 	pGeode->pExa = NULL;
     }
 
@@ -1259,10 +1259,10 @@ GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv)
 	    }
 	} else {
 	    pGeode->AccelImageWriteBuffers =
-		xcalloc(sizeof(pGeode->AccelImageWriteBuffers[0]),
+		calloc(sizeof(pGeode->AccelImageWriteBuffers[0]),
 		pGeode->NoOfImgBuffers);
 	    pGeode->AccelColorExpandBuffers =
-		xcalloc(sizeof(pGeode->AccelColorExpandBuffers[0]),
+		calloc(sizeof(pGeode->AccelColorExpandBuffers[0]),
 		pGeode->NoOfColorExpandLines);
 	}
     }
@@ -1535,7 +1535,7 @@ static void
 GeodeFreeRec(ScrnInfoPtr pScrni)
 {
     if (pScrni->driverPrivate != NULL) {
-	xfree(pScrni->driverPrivate);
+	free(pScrni->driverPrivate);
 	pScrni->driverPrivate = NULL;
     }
 }
diff --git a/src/gx_randr.c b/src/gx_randr.c
index a3aa5e4..1593c97 100644
--- a/src/gx_randr.c
+++ b/src/gx_randr.c
@@ -344,12 +344,12 @@ GXRandRInit(ScreenPtr pScreen, int rotation)
 	return FALSE;
 #endif
 
-    pRandr = xcalloc(sizeof(XF86RandRInfoRec), 1);
+    pRandr = calloc(sizeof(XF86RandRInfoRec), 1);
     if (pRandr == NULL)
 	return FALSE;
 
     if (!RRScreenInit(pScreen)) {
-	xfree(pRandr);
+	free(pRandr);
 	return FALSE;
     }
 
diff --git a/src/gx_video.c b/src/gx_video.c
index 9041f5f..f475bb6 100644
--- a/src/gx_video.c
+++ b/src/gx_video.c
@@ -182,7 +182,7 @@ GXInitVideo(ScreenPtr pScrn)
 		adaptors = &newAdaptor;
 	    } else {
 		newAdaptors =	       /* need to free this someplace */
-		    xalloc((num_adaptors +
+		    malloc((num_adaptors +
 			1) * sizeof(XF86VideoAdaptorPtr *));
 		if (newAdaptors) {
 		    memcpy(newAdaptors, adaptors, num_adaptors *
@@ -198,7 +198,7 @@ GXInitVideo(ScreenPtr pScrn)
 	    xf86XVScreenInit(pScrn, adaptors, num_adaptors);
 
 	if (newAdaptors)
-	    xfree(newAdaptors);
+	    free(newAdaptors);
     }
 }
 
@@ -374,7 +374,7 @@ GXSetupImageVideo(ScreenPtr pScrn)
     XF86VideoAdaptorPtr adapt;
     GeodePortPrivRec *pPriv;
 
-    if (!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
+    if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
 		sizeof(GeodePortPrivRec) + sizeof(DevUnion))))
 	return NULL;
 
@@ -1403,17 +1403,17 @@ GXAllocateSurface(ScrnInfoPtr pScrni,
     surface->width = w;
     surface->height = h;
 
-    if (!(surface->pitches = xalloc(sizeof(int))))
+    if (!(surface->pitches = malloc(sizeof(int))))
 	return BadAlloc;
 
-    if (!(surface->offsets = xalloc(sizeof(int)))) {
-	xfree(surface->pitches);
+    if (!(surface->offsets = malloc(sizeof(int)))) {
+	free(surface->pitches);
 	return BadAlloc;
     }
 
-    if (!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
-	xfree(surface->pitches);
-	xfree(surface->offsets);
+    if (!(pPriv = malloc(sizeof(OffscreenPrivRec)))) {
+	free(surface->pitches);
+	free(surface->offsets);
 	return BadAlloc;
     }
 
@@ -1452,9 +1452,9 @@ GXFreeSurface(XF86SurfacePtr surface)
 	GXStopSurface(surface);
 
     xf86FreeOffscreenArea(pPriv->area);
-    xfree(surface->pitches);
-    xfree(surface->offsets);
-    xfree(surface->devPrivate.ptr);
+    free(surface->pitches);
+    free(surface->offsets);
+    free(surface->devPrivate.ptr);
 
     return Success;
 }
@@ -1542,7 +1542,7 @@ GXInitOffscreenImages(ScreenPtr pScrn)
     XF86OffscreenImagePtr offscreenImages;
 
     /* need to free this someplace */
-    if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
+    if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec))))
 	return;
 
     offscreenImages[0].image = &Images[0];
diff --git a/src/lx_driver.c b/src/lx_driver.c
index 08d1fdd..0fcd51e 100644
--- a/src/lx_driver.c
+++ b/src/lx_driver.c
@@ -313,7 +313,7 @@ LXPreInit(ScrnInfoPtr pScrni, int flags)
 	if (!xf86LoadSubModule(pScrni, "vgahw") || !vgaHWGetHWRec(pScrni))
 	    pGeode->useVGA = FALSE;
 
-	pGeode->vesa = xcalloc(sizeof(VESARec), 1);
+	pGeode->vesa = calloc(sizeof(VESARec), 1);
     }
 
     cim_rdmsr = LXReadMSR;
@@ -698,7 +698,7 @@ LXCloseScreen(int scrnIndex, ScreenPtr pScrn)
 
     if (pGeode->pExa) {
 	exaDriverFini(pScrn);
-	xfree(pGeode->pExa);
+	free(pGeode->pExa);
 	pGeode->pExa = NULL;
     }
 
diff --git a/src/lx_memory.c b/src/lx_memory.c
index 41ac077..3de7886 100644
--- a/src/lx_memory.c
+++ b/src/lx_memory.c
@@ -69,7 +69,7 @@ GeodeFreeOffscreen(GeodeRec * pGeode, GeodeMemPtr ptr)
     if (ptr->next)
 	ptr->next->prev = ptr->prev;
 
-    xfree(ptr);
+    free(ptr);
 }
 
 /* Allocate the "rest" of the offscreen memory - this is for
@@ -83,7 +83,7 @@ GeodeAllocRemainder(GeodeRec * pGeode)
     GeodeMemPtr nptr, ptr = pGeode->offscreenList;
 
     if (!pGeode->offscreenList) {
-	pGeode->offscreenList = xcalloc(1, sizeof(*nptr));
+	pGeode->offscreenList = calloc(1, sizeof(*nptr));
 	pGeode->offscreenList->offset = pGeode->offscreenStart;
 	pGeode->offscreenList->size = pGeode->offscreenSize;
 	pGeode->offscreenList->next = NULL;
@@ -95,7 +95,7 @@ GeodeAllocRemainder(GeodeRec * pGeode)
     /* Go to the end of the list of allocated stuff */
     for (; ptr->next; ptr = ptr->next) ;
 
-    nptr = xcalloc(1, sizeof(*nptr));
+    nptr = calloc(1, sizeof(*nptr));
     nptr->offset = ptr->offset + ptr->size;
     nptr->size = pGeode->offscreenSize -
 	(nptr->offset - pGeode->offscreenStart);
@@ -125,7 +125,7 @@ GeodeAllocOffscreen(GeodeRec * pGeode, int size, int align)
 
 	offset = ALIGN(pGeode->offscreenStart, align);
 
-	pGeode->offscreenList = xcalloc(1, sizeof(*nptr));
+	pGeode->offscreenList = calloc(1, sizeof(*nptr));
 	pGeode->offscreenList->offset = offset;
 	pGeode->offscreenList->size = size;
 	pGeode->offscreenList->next = NULL;
@@ -149,7 +149,7 @@ GeodeAllocOffscreen(GeodeRec * pGeode, int size, int align)
 	    offset = ptr->offset + ptr->size;
 	    offset = ALIGN(ptr->offset + ptr->size, align);
 
-	    nptr = xcalloc(1, sizeof(*nptr));
+	    nptr = calloc(1, sizeof(*nptr));
 	    nptr->offset = offset;
 	    nptr->size = size;
 	    nptr->next = ptr->next;
@@ -307,7 +307,7 @@ GeodeCloseOffscreen(ScrnInfoPtr pScrni)
 
     while (ptr) {
 	nptr = ptr->next;
-	xfree(ptr);
+	free(ptr);
 	ptr = nptr;
     }
 
diff --git a/src/lx_output.c b/src/lx_output.c
index beb1634..85480a2 100644
--- a/src/lx_output.c
+++ b/src/lx_output.c
@@ -242,7 +242,7 @@ static void
 lx_output_destroy(xf86OutputPtr output)
 {
     if (output->driver_private)
-	xfree(output->driver_private);
+	free(output->driver_private);
 
     output->driver_private = NULL;
 }
diff --git a/src/lx_video.c b/src/lx_video.c
index f917ef0..76c38ca 100644
--- a/src/lx_video.c
+++ b/src/lx_video.c
@@ -677,7 +677,7 @@ LXSetupImageVideo(ScreenPtr pScrn)
     XF86VideoAdaptorPtr adapt;
     GeodePortPrivRec *pPriv;
 
-    adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
+    adapt = calloc(1, sizeof(XF86VideoAdaptorRec) +
 	sizeof(GeodePortPrivRec) + sizeof(DevUnion));
 
     if (adapt == NULL) {
@@ -822,11 +822,11 @@ LXAllocateSurface(ScrnInfoPtr pScrni, int id, unsigned short w,
     surface->width = w;
     surface->height = h;
 
-    surface->pitches = xalloc(sizeof(int));
+    surface->pitches = malloc(sizeof(int));
 
-    surface->offsets = xalloc(sizeof(int));
+    surface->offsets = malloc(sizeof(int));
 
-    pPriv = xalloc(sizeof(struct OffscreenPrivRec));
+    pPriv = malloc(sizeof(struct OffscreenPrivRec));
 
     if (pPriv && surface->pitches && surface->offsets) {
 
@@ -844,10 +844,10 @@ LXAllocateSurface(ScrnInfoPtr pScrni, int id, unsigned short w,
     }
 
     if (surface->offsets)
-	xfree(surface->offsets);
+	free(surface->offsets);
 
     if (surface->pitches)
-	xfree(surface->pitches);
+	free(surface->pitches);
 
     if (vidmem)
 	GeodeFreeOffscreen(pGeode, vidmem);
@@ -881,9 +881,9 @@ LXFreeSurface(XF86SurfacePtr surface)
 	pPriv->vidmem = NULL;
     }
 
-    xfree(surface->pitches);
-    xfree(surface->offsets);
-    xfree(surface->devPrivate.ptr);
+    free(surface->pitches);
+    free(surface->offsets);
+    free(surface->devPrivate.ptr);
 
     return Success;
 }
@@ -908,7 +908,7 @@ LXInitOffscreenImages(ScreenPtr pScrn)
     XF86OffscreenImagePtr offscreenImages;
 
     /* need to free this someplace */
-    if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
+    if (!(offscreenImages = malloc(sizeof(XF86OffscreenImageRec))))
 	return;
 
     offscreenImages[0].image = &Images[0];
@@ -957,7 +957,7 @@ LXInitVideo(ScreenPtr pScrn)
 	adaptors = &newAdaptor;
     } else {
 	newAdaptors =
-	    xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
+	    malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
 
 	if (newAdaptors) {
 	    memcpy(newAdaptors, adaptors, num_adaptors *
@@ -973,5 +973,5 @@ LXInitVideo(ScreenPtr pScrn)
 	xf86XVScreenInit(pScrn, adaptors, num_adaptors);
 
     if (newAdaptors)
-	xfree(newAdaptors);
+	free(newAdaptors);
 }
diff --git a/src/z4l.c b/src/z4l.c
index 1bad0d8..11b3fa5 100644
--- a/src/z4l.c
+++ b/src/z4l.c
@@ -960,7 +960,7 @@ Z4lNewEncoding(XF86VideoEncodingPtr * encs, int *nencs)
 {
     XF86VideoEncodingPtr enc;
     XF86VideoEncodingPtr tencs =
-	(XF86VideoEncodingPtr) xrealloc(*encs, sizeof(*tencs) * (*nencs + 1));
+	(XF86VideoEncodingPtr) realloc(*encs, sizeof(*tencs) * (*nencs + 1));
 
     if (tencs == NULL)
 	return NULL;
@@ -1029,7 +1029,7 @@ Z4lAddEncoding(XF86VideoEncodingPtr enc, char *name, int id, int width,
     l = strlen(&name[0]) + 1;
     l = (l + n) & ~n;
     n = l + sizeof(*sp);
-    cp = (char *)xalloc(n);
+    cp = (char *)malloc(n);
 
     if (cp == NULL)
 	return 0;
@@ -1055,7 +1055,7 @@ Z4lNewImage(XF86ImagePtr * imgs, int *nimgs)
 {
     XF86ImagePtr img;
     XF86ImagePtr timgs =
-	(XF86ImagePtr) xrealloc(*imgs, sizeof(*timgs) * (*nimgs + 1));
+	(XF86ImagePtr) realloc(*imgs, sizeof(*timgs) * (*nimgs + 1));
 
     if (timgs == NULL)
 	return NULL;
@@ -1081,7 +1081,7 @@ Z4lNewAttribute(XF86AttributePtr * attrs, int *nattrs)
 {
     XF86AttributePtr attr;
     XF86AttributePtr tattrs =
-	(XF86AttributePtr) xrealloc(*attrs, sizeof(*tattrs) * (*nattrs + 1));
+	(XF86AttributePtr) realloc(*attrs, sizeof(*tattrs) * (*nattrs + 1));
 
     if (tattrs == NULL)
 	return NULL;
@@ -1127,7 +1127,7 @@ static int
 Z4lAddAttribute(XF86AttributePtr attr, char *name,
     int min, int max, int flags)
 {
-    char *cp = (char *)xalloc(strlen((char *)&name[0]) + 1);
+    char *cp = (char *)malloc(strlen((char *)&name[0]) + 1);
 
     if (cp == NULL)
 	return 0;
@@ -1149,7 +1149,7 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs)
     Z4lPortPrivRec *pPriv;
     XF86VideoAdaptorPtr adpt, *tadpts;
 
-    tadpts = (XF86VideoAdaptorPtr *) xrealloc(*adpts,
+    tadpts = (XF86VideoAdaptorPtr *) realloc(*adpts,
 	sizeof(*tadpts) * (*nadpts + 1));
 
     if (tadpts == NULL)
@@ -1158,7 +1158,7 @@ Z4lNewAdaptor(XF86VideoAdaptorPtr ** adpts, int *nadpts, int nattrs)
     *adpts = tadpts;
     n = sizeof(*adpt) + sizeof(*pPriv) + 1 * sizeof(*adpt->pPortPrivates);
     n += (nattrs - 1) * sizeof(pPriv->attrIds[0]);
-    adpt = (XF86VideoAdaptorPtr) xalloc(n);
+    adpt = (XF86VideoAdaptorPtr) malloc(n);
 
     if (adpt == NULL)
 	return NULL;
@@ -1559,7 +1559,7 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors)
 	    has_colorkey = 1;
 	}
 
-	dp = xalloc(strlen((char *)&capability.card[0]) + 1);
+	dp = malloc(strlen((char *)&capability.card[0]) + 1);
 	if (dp == NULL)
 	    goto fail;
 	strcpy(dp, (char *)&capability.card[0]);
@@ -1668,7 +1668,7 @@ Z4lInit(ScrnInfoPtr pScrni, XF86VideoAdaptorPtr ** adaptors)
 		}
 		if ((imgs = adpt->pImages) != NULL)
 		    free(imgs);
-		xfree(adpt);
+		free(adpt);
 	    }
 	}
 	free(adpts);
-- 
1.7.1




More information about the Xorg-driver-geode mailing list