From 68338c5f3fc861b5a651a4f826671ba3c8c42480 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 8 May 2024 10:49:43 +0200 Subject: [PATCH] (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: ae75d50395fdd7a6bc382ba73e923c460764c702 Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86Config.c | 18 +++++++++--------- hw/xfree86/common/xf86pciBus.c | 2 +- include/os.h | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 15310dc35..d64138bb4 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -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) { diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c index 68e3f35fc..15c304d26 100644 --- a/hw/xfree86/common/xf86pciBus.c +++ b/hw/xfree86/common/xf86pciBus.c @@ -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); diff --git a/include/os.h b/include/os.h index 4b6bcaac9..1048bc287 100644 --- a/include/os.h +++ b/include/os.h @@ -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