treewide: replace xnfreallocarray macro call by XNFreallocarray()
The xnfreallocarray was added along (and just as an alias to) XNFreallocarray
back a decade ago. It's just used in a few places and it's only saves us from
passing the first parameter (NULL), so the actual benefit isn't really huge.
No (known) driver is using it, so the macro can be dropped entirely.
Fixes: ae75d50395
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
This commit is contained in:
parent
6b3c916030
commit
61233adbca
|
@ -615,7 +615,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
|
|||
|
||||
if (from->button->xkb_acts) {
|
||||
size_t maxbuttons = max(to->button->numButtons, from->button->numButtons);
|
||||
to->button->xkb_acts = xnfreallocarray(to->button->xkb_acts,
|
||||
to->button->xkb_acts = XNFreallocarray(to->button->xkb_acts,
|
||||
maxbuttons,
|
||||
sizeof(XkbAction));
|
||||
memset(to->button->xkb_acts, 0, maxbuttons * sizeof(XkbAction));
|
||||
|
|
|
@ -2569,7 +2569,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
|
|||
|
||||
master->button->numButtons = maxbuttons;
|
||||
if (last_num_buttons < maxbuttons) {
|
||||
master->button->xkb_acts = xnfreallocarray(master->button->xkb_acts,
|
||||
master->button->xkb_acts = XNFreallocarray(master->button->xkb_acts,
|
||||
maxbuttons,
|
||||
sizeof(XkbAction));
|
||||
memset(&master->button->xkb_acts[last_num_buttons],
|
||||
|
|
|
@ -107,7 +107,7 @@ AppendToList(const char *s, const char ***list, int *lines)
|
|||
str = xnfstrdup(s);
|
||||
for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
|
||||
(*lines)++;
|
||||
*list = xnfreallocarray(*list, *lines + 1, sizeof(**list));
|
||||
*list = XNFreallocarray(*list, *lines + 1, sizeof(**list));
|
||||
newstr = XNFalloc(strlen(p) + 2);
|
||||
strcpy(newstr, p);
|
||||
strcat(newstr, "\n");
|
||||
|
|
|
@ -297,7 +297,7 @@ int
|
|||
xf86AllocateEntity(void)
|
||||
{
|
||||
xf86NumEntities++;
|
||||
xf86Entities = xnfreallocarray(xf86Entities,
|
||||
xf86Entities = XNFreallocarray(xf86Entities,
|
||||
xf86NumEntities, sizeof(EntityPtr));
|
||||
xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
|
||||
xf86Entities[xf86NumEntities - 1]->entityPrivates =
|
||||
|
@ -355,11 +355,11 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
|
|||
}
|
||||
|
||||
pScrn->numEntities++;
|
||||
pScrn->entityList = xnfreallocarray(pScrn->entityList,
|
||||
pScrn->entityList = XNFreallocarray(pScrn->entityList,
|
||||
pScrn->numEntities, sizeof(int));
|
||||
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
|
||||
xf86Entities[entityIndex]->inUse = TRUE;
|
||||
pScrn->entityInstanceList = xnfreallocarray(pScrn->entityInstanceList,
|
||||
pScrn->entityInstanceList = XNFreallocarray(pScrn->entityInstanceList,
|
||||
pScrn->numEntities,
|
||||
sizeof(int));
|
||||
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
|
||||
|
@ -457,7 +457,7 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
|
|||
|
||||
pEnt = xf86Entities[entityIndex];
|
||||
pEnt->numInstances++;
|
||||
pEnt->devices = xnfreallocarray(pEnt->devices,
|
||||
pEnt->devices = XNFreallocarray(pEnt->devices,
|
||||
pEnt->numInstances, sizeof(GDevPtr));
|
||||
pEnt->devices[pEnt->numInstances - 1] = dev;
|
||||
dev->claimed = TRUE;
|
||||
|
@ -651,7 +651,7 @@ xf86AllocateEntityPrivateIndex(void)
|
|||
idx = xf86EntityPrivateCount++;
|
||||
for (i = 0; i < xf86NumEntities; i++) {
|
||||
pEnt = xf86Entities[i];
|
||||
nprivs = xnfreallocarray(pEnt->entityPrivates,
|
||||
nprivs = XNFreallocarray(pEnt->entityPrivates,
|
||||
xf86EntityPrivateCount, sizeof(DevUnion));
|
||||
/* Zero the new private */
|
||||
memset(&nprivs[idx], 0, sizeof(DevUnion));
|
||||
|
|
|
@ -1014,7 +1014,7 @@ addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
|
|||
for (devs = list; devs && *devs; devs++)
|
||||
count++;
|
||||
|
||||
list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr));
|
||||
list = XNFreallocarray(list, count + 1, sizeof(InputInfoPtr));
|
||||
list[count] = NULL;
|
||||
|
||||
list[count - 1] = pInfo;
|
||||
|
|
|
@ -115,7 +115,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
|
|||
/* Allocate new structure occurrence */
|
||||
i = nDevToConfig++;
|
||||
DevToConfig =
|
||||
xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec));
|
||||
XNFreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec));
|
||||
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
|
||||
|
||||
DevToConfig[i].GDev.chipID =
|
||||
|
|
|
@ -81,7 +81,7 @@ xf86AddDriver(DriverPtr driver, void *module, int flags)
|
|||
xf86NumDrivers = 0;
|
||||
|
||||
xf86NumDrivers++;
|
||||
xf86DriverList = xnfreallocarray(xf86DriverList,
|
||||
xf86DriverList = XNFreallocarray(xf86DriverList,
|
||||
xf86NumDrivers, sizeof(DriverPtr));
|
||||
xf86DriverList[xf86NumDrivers - 1] = XNFalloc(sizeof(DriverRec));
|
||||
*xf86DriverList[xf86NumDrivers - 1] = *driver;
|
||||
|
@ -114,7 +114,7 @@ xf86AddInputDriver(InputDriverPtr driver, void *module, int flags)
|
|||
xf86NumInputDrivers = 0;
|
||||
|
||||
xf86NumInputDrivers++;
|
||||
xf86InputDriverList = xnfreallocarray(xf86InputDriverList,
|
||||
xf86InputDriverList = XNFreallocarray(xf86InputDriverList,
|
||||
xf86NumInputDrivers,
|
||||
sizeof(InputDriverPtr));
|
||||
xf86InputDriverList[xf86NumInputDrivers - 1] =
|
||||
|
@ -170,7 +170,7 @@ xf86AllocateScreen(DriverPtr drv, int flags)
|
|||
if (xf86GPUScreens == NULL)
|
||||
xf86NumGPUScreens = 0;
|
||||
i = xf86NumGPUScreens++;
|
||||
xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens,
|
||||
xf86GPUScreens = XNFreallocarray(xf86GPUScreens, xf86NumGPUScreens,
|
||||
sizeof(ScrnInfoPtr));
|
||||
xf86GPUScreens[i] = xnfcalloc(1, sizeof(ScrnInfoRec));
|
||||
pScrn = xf86GPUScreens[i];
|
||||
|
@ -181,7 +181,7 @@ xf86AllocateScreen(DriverPtr drv, int flags)
|
|||
xf86NumScreens = 0;
|
||||
|
||||
i = xf86NumScreens++;
|
||||
xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens,
|
||||
xf86Screens = XNFreallocarray(xf86Screens, xf86NumScreens,
|
||||
sizeof(ScrnInfoPtr));
|
||||
xf86Screens[i] = xnfcalloc(1, sizeof(ScrnInfoRec));
|
||||
pScrn = xf86Screens[i];
|
||||
|
@ -292,7 +292,7 @@ xf86AllocateScrnInfoPrivateIndex(void)
|
|||
idx = xf86ScrnInfoPrivateCount++;
|
||||
for (i = 0; i < xf86NumScreens; i++) {
|
||||
pScr = xf86Screens[i];
|
||||
nprivs = xnfreallocarray(pScr->privates,
|
||||
nprivs = XNFreallocarray(pScr->privates,
|
||||
xf86ScrnInfoPrivateCount, sizeof(DevUnion));
|
||||
/* Zero the new private */
|
||||
memset(&nprivs[idx], 0, sizeof(DevUnion));
|
||||
|
@ -300,7 +300,7 @@ xf86AllocateScrnInfoPrivateIndex(void)
|
|||
}
|
||||
for (i = 0; i < xf86NumGPUScreens; i++) {
|
||||
pScr = xf86GPUScreens[i];
|
||||
nprivs = xnfreallocarray(pScr->privates,
|
||||
nprivs = XNFreallocarray(pScr->privates,
|
||||
xf86ScrnInfoPrivateCount, sizeof(DevUnion));
|
||||
/* Zero the new private */
|
||||
memset(&nprivs[idx], 0, sizeof(DevUnion));
|
||||
|
@ -560,7 +560,7 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
|
|||
if (i == scrp->confScreen->numdisplays) {
|
||||
scrp->confScreen->numdisplays++;
|
||||
scrp->confScreen->displays =
|
||||
xnfreallocarray(scrp->confScreen->displays,
|
||||
XNFreallocarray(scrp->confScreen->displays,
|
||||
scrp->confScreen->numdisplays, sizeof(DispPtr));
|
||||
xf86DrvMsg(scrp->scrnIndex, X_INFO,
|
||||
"Creating default Display subsection in Screen section\n"
|
||||
|
@ -1329,7 +1329,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
|
|||
/*
|
||||
* we have a matching driver that wasn't claimed, yet
|
||||
*/
|
||||
pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
|
||||
pgdp = XNFreallocarray(pgdp, i + 2, sizeof(GDevPtr));
|
||||
pgdp[i++] = screensecptr->device;
|
||||
}
|
||||
for (k = 0; k < screensecptr->num_gpu_devices; k++) {
|
||||
|
@ -1352,7 +1352,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
|
|||
if (gdp->driver && !gdp->claimed &&
|
||||
!xf86NameCmp(gdp->driver, drivername)) {
|
||||
/* we have a matching driver that wasn't claimed yet */
|
||||
pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
|
||||
pgdp = XNFreallocarray(pgdp, i + 2, sizeof(GDevPtr));
|
||||
pgdp[i++] = gdp;
|
||||
}
|
||||
j++;
|
||||
|
|
|
@ -102,7 +102,7 @@ xf86PciProbe(void)
|
|||
while ((info = pci_device_next(iter)) != NULL) {
|
||||
if (PCIINFOCLASSES(info->device_class)) {
|
||||
num++;
|
||||
xf86PciVideoInfo = xnfreallocarray(xf86PciVideoInfo,
|
||||
xf86PciVideoInfo = XNFreallocarray(xf86PciVideoInfo,
|
||||
num + 1,
|
||||
sizeof(struct pci_device *));
|
||||
xf86PciVideoInfo[num] = NULL;
|
||||
|
@ -979,7 +979,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
|
|||
|
||||
/* Allocate an entry in the lists to be returned */
|
||||
numFound++;
|
||||
retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
|
||||
retEntities = XNFreallocarray(retEntities, numFound, sizeof(int));
|
||||
retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp,
|
||||
instances[i].chip,
|
||||
instances[i].dev,
|
||||
|
|
|
@ -65,7 +65,7 @@ struct xf86_platform_device *xf86_platform_devices;
|
|||
int
|
||||
xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned)
|
||||
{
|
||||
xf86_platform_devices = xnfreallocarray(xf86_platform_devices,
|
||||
xf86_platform_devices = XNFreallocarray(xf86_platform_devices,
|
||||
xf86_num_platform_devices + 1,
|
||||
sizeof(struct xf86_platform_device));
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ CheckSbusDevice(const char *device, int fbNum)
|
|||
if (!sbusDeviceTable[i].devId)
|
||||
return;
|
||||
xf86SbusInfo =
|
||||
xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp));
|
||||
XNFreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp));
|
||||
xf86SbusInfo[xf86nSbusInfo] = NULL;
|
||||
xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(1, sizeof(sbusDevice));
|
||||
psdp->devId = sbusDeviceTable[i].devId;
|
||||
|
@ -406,7 +406,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
|
|||
if (psdp->fd == -2)
|
||||
continue;
|
||||
++allocatedInstances;
|
||||
instances = xnfreallocarray(instances,
|
||||
instances = XNFreallocarray(instances,
|
||||
allocatedInstances, sizeof(struct Inst));
|
||||
instances[allocatedInstances - 1].sbus = psdp;
|
||||
instances[allocatedInstances - 1].dev = NULL;
|
||||
|
@ -532,7 +532,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
|
|||
|
||||
/* Allocate an entry in the lists to be returned */
|
||||
numFound++;
|
||||
retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
|
||||
retEntities = XNFreallocarray(retEntities, numFound, sizeof(int));
|
||||
retEntities[numFound - 1]
|
||||
= xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,
|
||||
instances[i].dev->active ? TRUE : FALSE);
|
||||
|
|
|
@ -872,7 +872,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus)
|
|||
if (!pppI2CBus)
|
||||
continue;
|
||||
|
||||
*pppI2CBus = xnfreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr));
|
||||
*pppI2CBus = XNFreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr));
|
||||
(*pppI2CBus)[n - 1] = pI2CBus;
|
||||
}
|
||||
|
||||
|
|
|
@ -440,7 +440,7 @@ sparcPromAssignNodes(void)
|
|||
for (i = 0, j = 0; i < 32; i++)
|
||||
if (devicePtrs[i] && devicePtrs[i]->fbNum == -1)
|
||||
j++;
|
||||
xf86SbusInfo = xnfreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp));
|
||||
xf86SbusInfo = XNFreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp));
|
||||
for (i = 0, psdpp = xf86SbusInfo; i < 32; i++)
|
||||
if (devicePtrs[i]) {
|
||||
if (devicePtrs[i]->fbNum == -1) {
|
||||
|
|
|
@ -204,7 +204,7 @@ xwl_dmabuf_get_formats_for_device(struct xwl_dmabuf_feedback *xwl_feedback, drmD
|
|||
struct xwl_device_formats *dev_formats = &xwl_feedback->dev_formats[i];
|
||||
|
||||
/* Append the formats from this tranche to the list */
|
||||
ret = xnfreallocarray(ret, count + dev_formats->num_formats, sizeof(CARD32));
|
||||
ret = XNFreallocarray(ret, count + dev_formats->num_formats, sizeof(CARD32));
|
||||
|
||||
for (int j = 0; j < dev_formats->num_formats; j++) {
|
||||
Bool found = FALSE;
|
||||
|
|
|
@ -216,7 +216,7 @@ xwl_glamor_xv_add_formats(XvAdaptorPtr pa)
|
|||
void *moreSpace;
|
||||
|
||||
totFormat *= 2;
|
||||
moreSpace = xnfreallocarray(pFormat, totFormat,
|
||||
moreSpace = XNFreallocarray(pFormat, totFormat,
|
||||
sizeof(XvFormatRec));
|
||||
pFormat = moreSpace;
|
||||
pf = pFormat + numFormat;
|
||||
|
|
|
@ -81,7 +81,6 @@ typedef struct _NewClientRec *NewClientPtr;
|
|||
#define xnfstrdup(s) XNFstrdup(s)
|
||||
|
||||
#define xallocarray(num, size) reallocarray(NULL, (num), (size))
|
||||
#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size))
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1034,9 +1034,9 @@ ListenOnOpenFD(int fd, int noxauth)
|
|||
|
||||
/* Allocate space to store it */
|
||||
ListenTransFds =
|
||||
xnfreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int));
|
||||
XNFreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int));
|
||||
ListenTransConns =
|
||||
xnfreallocarray(ListenTransConns, ListenTransCount + 1,
|
||||
XNFreallocarray(ListenTransConns, ListenTransCount + 1,
|
||||
sizeof(XtransConnInfo));
|
||||
|
||||
/* Store it */
|
||||
|
|
Loading…
Reference in New Issue