(submit/cleanup-alloc-funcs) xfree86: replace xnfreallocarray() calls by XNFreallocarray

The xnfallocarray 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>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-05-08 10:49:43 +02:00
parent de0e2e32e3
commit 68338c5f3f
3 changed files with 10 additions and 11 deletions

View File

@ -364,8 +364,8 @@ xf86ModulelistFromConfig(void ***optlist)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
modulearray = xnfallocarray(count + 1, sizeof(char *));
optarray = xnfallocarray(count + 1, sizeof(void *));
modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *));
optarray = XNFreallocarray(NULL, count + 1, sizeof(void *));
count = 0;
if (xf86configptr->conf_modules) {
modp = xf86configptr->conf_modules->mod_load_lst;
@ -432,7 +432,7 @@ xf86DriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
modulearray = xnfallocarray(count + 1, sizeof(char *));
modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *));
count = 0;
slp = xf86ConfigLayout.screens;
while (slp->screen) {
@ -500,7 +500,7 @@ xf86InputDriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
modulearray = xnfallocarray(count + 1, sizeof(char *));
modulearray = XNFreallocarray(NULL, count + 1, sizeof(char *));
count = 0;
idp = xf86ConfigLayout.inputs;
while (idp && *idp) {
@ -1554,7 +1554,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
}
DebugF("Found %d inactive devices in the layout section %s\n",
count, conf_layout->lay_identifier);
gdp = xnfallocarray(count + 1, sizeof(GDevRec));
gdp = XNFreallocarray(NULL, count + 1, sizeof(GDevRec));
gdp[count].identifier = NULL;
idp = conf_layout->lay_inactive_lst;
count = 0;
@ -1674,7 +1674,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
count++;
conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
}
adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec));
adaptor->ports = XNFreallocarray(NULL, count, sizeof(confXvPortRec));
adaptor->numports = count;
count = 0;
conf_port = conf_adaptor->va_port_lst;
@ -1805,7 +1805,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
}
screenp->displays = xnfallocarray(count, sizeof(DispPtr));
screenp->displays = XNFreallocarray(NULL, count, sizeof(DispPtr));
screenp->numdisplays = count;
for (count = 0, dispptr = conf_screen->scrn_display_lst;
@ -1834,7 +1834,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
}
screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec));
screenp->xvadaptors = XNFreallocarray(NULL, count, sizeof(confXvAdaptorRec));
screenp->numxvadaptors = 0;
conf_adaptor = conf_screen->scrn_adaptor_lst;
while (conf_adaptor) {
@ -2073,7 +2073,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
count++;
modep = (XF86ModePtr) modep->list.next;
}
displayp->modes = xnfallocarray(count + 1, sizeof(char *));
displayp->modes = XNFreallocarray(NULL, count + 1, sizeof(char *));
modep = conf_display->disp_mode_lst;
count = 0;
while (modep) {

View File

@ -682,7 +682,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
pci_iterator_destroy(iter);
instances = xnfallocarray(max_entries, sizeof(struct Inst));
instances = XNFreallocarray(NULL, max_entries, sizeof(struct Inst));
}
iter = pci_slot_match_iterator_create(NULL);

View File

@ -81,7 +81,6 @@ typedef struct _NewClientRec *NewClientPtr;
#define xnfstrdup(s) XNFstrdup(s)
#define xallocarray(num, size) reallocarray(NULL, (num), (size))
#define xnfallocarray(num, size) XNFreallocarray(NULL, (num), (size))
#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size))
#endif