From 3f3ff971ecff9936cebafc813af9193b97bba89c Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Thu, 6 May 2010 01:44:06 +0700 Subject: Replace X-allocation functions with their C89 counterparts The only remaining X-functions used in server are XNF*, the rest is converted to plain alloc/calloc/realloc/free/strdup. X* functions are still exported from server and x* macros are still defined in header file, so both ABI and API are not affected by this change. Signed-off-by: Mikhail Gusarov Reviewed-by: Peter Hutterer --- record/record.c | 54 +++++++++++++++++++++++++++--------------------------- record/set.c | 12 ++++++------ 2 files changed, 33 insertions(+), 33 deletions(-) (limited to 'record') diff --git a/record/record.c b/record/record.c index 1a10c9edc..930374001 100644 --- a/record/record.c +++ b/record/record.c @@ -825,7 +825,7 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata) EventToXI(pei->event, &xi_events, &count); RecordSendProtocolEvents(pRCAP, pContext, xi_events, count); - xfree(xi_events); + free(xi_events); } /* end this RCAP selects device events */ } /* end for each RCAP on this context */ } /* end for each enabled context */ @@ -913,7 +913,7 @@ RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient) RecordClientPrivatePtr pClientPriv; /* no Record proc vector; allocate one */ pClientPriv = (RecordClientPrivatePtr) - xalloc(sizeof(RecordClientPrivateRec)); + malloc(sizeof(RecordClientPrivateRec)); if (!pClientPriv) return BadAlloc; /* copy old proc vector to new */ @@ -1033,7 +1033,7 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient) pClient->requestVector = pClientPriv->originalVector; dixSetPrivate(&pClient->devPrivates, RecordClientPrivateKey, NULL); - xfree(pClientPriv); + free(pClientPriv); } } /* end if this RCAP specifies any requests */ } /* end if not future clients */ @@ -1101,8 +1101,8 @@ RecordDeleteClientFromRCAP(RecordClientsAndProtocolPtr pRCAP, int position) } /* free the RCAP */ if (pRCAP->clientIDsSeparatelyAllocated) - xfree(pRCAP->pClientIDs); - xfree(pRCAP); + free(pRCAP->pClientIDs); + free(pRCAP); } } /* RecordDeleteClientFromRCAP */ @@ -1130,7 +1130,7 @@ RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec) { if (pRCAP->clientIDsSeparatelyAllocated) { - XID *pNewIDs = (XID *)xrealloc(pRCAP->pClientIDs, + XID *pNewIDs = (XID *)realloc(pRCAP->pClientIDs, (pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT) * sizeof(XID)); if (!pNewIDs) @@ -1140,7 +1140,7 @@ RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec) } else { - XID *pNewIDs = (XID *)xalloc((pRCAP->sizeClients + + XID *pNewIDs = (XID *)malloc((pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT) * sizeof(XID)); if (!pNewIDs) return; @@ -1246,7 +1246,7 @@ RecordSanityCheckClientSpecifiers(ClientPtr client, XID *clientspecs, int nspecs * - XRecordCurrentClients expanded to a list of all currently * connected clients - excludespec (if non-zero) * The returned array may be the passed array modified in place, or - * it may be an Xalloc'ed array. The caller should keep a pointer to the + * it may be an malloc'ed array. The caller should keep a pointer to the * original array and free the returned array if it is different. * * *pNumClientspecs is set to the number of elements in the returned @@ -1278,7 +1278,7 @@ RecordCanonicalizeClientSpecifiers(XID *pClientspecs, int *pNumClientspecs, XID pClientspecs[i] == XRecordCurrentClients) { /* expand All/Current */ int j, nc; - XID *pCanon = (XID *)xalloc(sizeof(XID) * (currentMaxClients + 1)); + XID *pCanon = (XID *)malloc(sizeof(XID) * (currentMaxClients + 1)); if (!pCanon) return NULL; for (nc = 0, j = 1; j < currentMaxClients; j++) { @@ -1492,7 +1492,7 @@ RecordAllocIntervals(SetInfoPtr psi, int nIntervals) { assert(!psi->intervals); psi->intervals = (RecordSetInterval *) - xalloc(nIntervals * sizeof(RecordSetInterval)); + malloc(nIntervals * sizeof(RecordSetInterval)); if (!psi->intervals) return BadAlloc; bzero(psi->intervals, nIntervals * sizeof(RecordSetInterval)); @@ -1663,7 +1663,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegist * range for extension replies. */ maxSets = PREDEFSETS + 2 * stuff->nRanges; - si = (SetInfoPtr)xalloc(sizeof(SetInfoRec) * maxSets); + si = (SetInfoPtr)malloc(sizeof(SetInfoRec) * maxSets); if (!si) { err = BadAlloc; @@ -1755,7 +1755,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client, xRecordRegist /* allocate memory for the whole RCAP */ - pRCAP = (RecordClientsAndProtocolPtr)xalloc(totRCAPsize); + pRCAP = (RecordClientsAndProtocolPtr)malloc(totRCAPsize); if (!pRCAP) { err = BadAlloc; @@ -1869,11 +1869,11 @@ bailout: { for (i = 0; i < maxSets; i++) if (si[i].intervals) - xfree(si[i].intervals); - xfree(si); + free(si[i].intervals); + free(si); } if (pCanonClients && pCanonClients != (XID *)&stuff[1]) - xfree(pCanonClients); + free(pCanonClients); return err; } /* RecordRegisterClients */ @@ -1918,14 +1918,14 @@ ProcRecordCreateContext(ClientPtr client) REQUEST_AT_LEAST_SIZE(xRecordCreateContextReq); LEGAL_NEW_RESOURCE(stuff->context, client); - pContext = (RecordContextPtr)xalloc(sizeof(RecordContextRec)); + pContext = (RecordContextPtr)malloc(sizeof(RecordContextRec)); if (!pContext) goto bailout; /* make sure there is room in ppAllContexts to store the new context */ ppNewAllContexts = (RecordContextPtr *) - xrealloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1)); + realloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1)); if (!ppNewAllContexts) goto bailout; ppAllContexts = ppNewAllContexts; @@ -1956,7 +1956,7 @@ ProcRecordCreateContext(ClientPtr client) } bailout: if (pContext) - xfree(pContext); + free(pContext); return err; } /* ProcRecordCreateContext */ @@ -2005,7 +2005,7 @@ ProcRecordUnregisterClients(ClientPtr client) RecordDeleteClientFromContext(pContext, pCanonClients[i]); } if (pCanonClients != (XID *)&stuff[1]) - xfree(pCanonClients); + free(pCanonClients); return Success; } /* ProcRecordUnregisterClients */ @@ -2046,7 +2046,7 @@ RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges) #define SZINCR 8 newsize = max(pri->size + SZINCR, nRanges); - pNewRange = (xRecordRange *)xrealloc(pri->pRanges, + pNewRange = (xRecordRange *)realloc(pri->pRanges, newsize * sizeof(xRecordRange)); if (!pNewRange) return BadAlloc; @@ -2237,7 +2237,7 @@ ProcRecordGetContext(ClientPtr client) /* allocate and initialize space for record range info */ - pRangeInfo = (GetContextRangeInfoPtr)xalloc( + pRangeInfo = (GetContextRangeInfoPtr)malloc( nRCAPs * sizeof(GetContextRangeInfoRec)); if (!pRangeInfo && nRCAPs > 0) return BadAlloc; @@ -2352,9 +2352,9 @@ ProcRecordGetContext(ClientPtr client) bailout: for (i = 0; i < nRCAPs; i++) { - if (pRangeInfo[i].pRanges) xfree(pRangeInfo[i].pRanges); + if (pRangeInfo[i].pRanges) free(pRangeInfo[i].pRanges); } - xfree(pRangeInfo); + free(pRangeInfo); return err; } /* ProcRecordGetContext */ @@ -2522,7 +2522,7 @@ RecordDeleteContext(pointer value, XID id) } } - xfree(pContext); + free(pContext); /* remove context from AllContexts list */ @@ -2531,7 +2531,7 @@ RecordDeleteContext(pointer value, XID id) ppAllContexts[i] = ppAllContexts[numContexts - 1]; if (--numContexts == 0) { - xfree(ppAllContexts); + free(ppAllContexts); ppAllContexts = NULL; } } @@ -2764,14 +2764,14 @@ RecordConnectionSetupInfo(RecordContextPtr pContext, NewClientInfoRec *pci) if (pci->client->swapped) { - char *pConnSetup = (char *)xalloc(prefixsize + restsize); + char *pConnSetup = (char *)malloc(prefixsize + restsize); if (!pConnSetup) return; SwapConnSetupPrefix(pci->prefix, (xConnSetupPrefix*)pConnSetup); SwapConnSetupInfo((char*)pci->setup, (char*)(pConnSetup + prefixsize)); RecordAProtocolElement(pContext, pci->client, XRecordClientStarted, (pointer)pConnSetup, prefixsize + restsize, 0); - xfree(pConnSetup); + free(pConnSetup); } else { diff --git a/record/set.c b/record/set.c index f0e094eed..f2064fd3c 100644 --- a/record/set.c +++ b/record/set.c @@ -87,7 +87,7 @@ typedef struct { static void BitVectorDestroySet(RecordSetPtr pSet) { - xfree(pSet); + free(pSet); } static unsigned long @@ -199,7 +199,7 @@ BitVectorCreateSet(RecordSetInterval *pIntervals, int nIntervals, } else { - pbvs = (BitVectorSetPtr)Xcalloc(memsize); + pbvs = (BitVectorSetPtr)calloc(1, memsize); if (!pbvs) return NULL; pbvs->baseSet.ops = &BitVectorSetOperations; } @@ -233,7 +233,7 @@ typedef struct { static void IntervalListDestroySet(RecordSetPtr pSet) { - xfree(pSet); + free(pSet); } static unsigned long @@ -302,7 +302,7 @@ IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals, if (nIntervals > 0) { - stackIntervals = (RecordSetInterval *)xalloc( + stackIntervals = (RecordSetInterval *)malloc( sizeof(RecordSetInterval) * nIntervals); if (!stackIntervals) return NULL; @@ -353,14 +353,14 @@ IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals, else { prls = (IntervalListSetPtr) - xalloc(sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval)); + malloc(sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval)); if (!prls) goto bailout; prls->baseSet.ops = &IntervalListSetOperations; } memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval)); prls->nIntervals = nIntervals; bailout: - if (stackIntervals) xfree(stackIntervals); + if (stackIntervals) free(stackIntervals); return (RecordSetPtr)prls; } -- cgit v1.2.3