[PATCH:xscope 10/14] Make FDinfo dynamically allocated

Alan Coopersmith alan.coopersmith at ORACLE.COM
Sat Sep 24 08:48:28 PDT 2011


We still allocate one fdinfo struct for every possible FD up front
instead of resizing as needed, but they're much smaller now that
we just have a pointer to the 32k buffer instead of including it
directly in the fdinfo.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 fd.c    |    4 ++++
 scope.c |    2 +-
 scope.h |    2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fd.c b/fd.c
index 50c6f17..9bff364 100644
--- a/fd.c
+++ b/fd.c
@@ -109,6 +109,10 @@ InitializeFD(void)
   if (FDD == NULL) {
       panic("Can't allocate memory for file descriptor table");
   }
+  FDinfo = calloc(MaxFD, sizeof (struct fdinfo));
+  if (FDD == NULL) {
+      panic("Can't allocate memory for file descriptor info table");
+  }
 
   /* be sure all fd's are closed and marked not busy */
   for (i = 0; i < MaxFD; i++)
diff --git a/scope.c b/scope.c
index 686be80..f66def2 100644
--- a/scope.c
+++ b/scope.c
@@ -933,7 +933,7 @@ SetUpStdin (void)
 */
 
 static long clientNumber = 0;
-struct fdinfo   FDinfo[StaticMaxFD];
+struct fdinfo   *FDinfo;
 
 void
 SetUpPair(
diff --git a/scope.h b/scope.h
index 360cdc5..d14cfed 100644
--- a/scope.h
+++ b/scope.h
@@ -117,7 +117,7 @@ struct fdinfo
   Boolean writeblocked;
 };
 
-extern struct fdinfo   FDinfo[StaticMaxFD];
+extern struct fdinfo   *FDinfo;
 extern int littleEndian;
 extern char HandleSIGUSR1;
 extern char Leader[];
-- 
1.7.3.2



More information about the xorg-devel mailing list