[PATCH:xscope 08/14] Make ReplyQ dynamically allocated

Alan Coopersmith alan.coopersmith at oracle.com
Sat Sep 24 08:48:26 PDT 2011


We still allocate a QueueHeader (a struct containing 2 pointers) for
every possible FD, instead of allocating only as needed.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 decode11.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/decode11.c b/decode11.c
index a23fa30..f4d721c 100644
--- a/decode11.c
+++ b/decode11.c
@@ -135,19 +135,16 @@ struct QueueHeader
   struct QueueEntry  *Tail;
 };
 
-static struct QueueHeader  ReplyQ[StaticMaxFD];
+static struct QueueHeader  *ReplyQ;
 
 /* ************************************************************ */
 
 void
 InitReplyQ (void)
 {
-  short   i;
-  for (i = 0; i < StaticMaxFD; i++)
-    {
-      ReplyQ[i].Head = NULL;
-      ReplyQ[i].Tail = NULL;
-    }
+  ReplyQ = calloc(MaxFD, sizeof(struct QueueHeader));
+  if (ReplyQ == NULL)
+    panic("unable to allocate ReplyQ");
 }
 
 void
@@ -211,7 +208,7 @@ SequencedReplyExpected (
 
   /* find the server associated with this client */
   fd = FDPair(fd);
-  if (fd < 0 || fd >= StaticMaxFD) return;
+  if (fd < 0 || fd >= MaxFD) return;
 
   /* attach the new queue entry to the end of the queue for the Server */
   if (ReplyQ[fd].Tail != NULL)
-- 
1.7.3.2



More information about the xorg-devel mailing list