From fafdfa0e1a54e19f11e220340df0557c794fabc6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 30 Sep 2011 20:19:44 -0700 Subject: Make ReplyQ dynamically allocated 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 Reviewed-by: Jeremy Huddleston --- decode11.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'decode11.c') 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) -- cgit v1.2.1