[PATCH 4/5] miinitext: avoid allocating a sentinel ExtensionModule

Emil Velikov emil.l.velikov at gmail.com
Wed Feb 5 08:20:16 PST 2014


With all the logic now in place there is no need to allocate a separate
ExtensionModule to be used as a sentinel.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 mi/miinitext.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mi/miinitext.c b/mi/miinitext.c
index ce2e4bc..b136818 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -331,7 +331,7 @@ InitExtensions(int argc, char *argv[])
 
     AddStaticExtensions();
 
-    for (i = 0; ExtensionModuleList[i].name != NULL; i++) {
+    for (i = 0; i < numExtensionModules; i++) {
         ext = &ExtensionModuleList[i];
         if (ext->initFunc != NULL &&
             (ext->disablePtr == NULL || !*ext->disablePtr)) {
@@ -352,14 +352,13 @@ NewExtensionModule(void)
 
     n = numExtensionModules + 1;
     ExtensionModuleList = realloc(ExtensionModuleList,
-                                  (n + 1) * sizeof(ExtensionModule));
+                                  n * sizeof(ExtensionModule));
     if (ExtensionModuleList == NULL) {
         ExtensionModuleList = save;
         return NULL;
     }
     else {
         numExtensionModules++;
-        ExtensionModuleList[numExtensionModules].name = NULL;
         return ExtensionModuleList + (numExtensionModules - 1);
     }
 }
-- 
1.8.5.2



More information about the xorg-devel mailing list