From 413f2aaf6098c52bb9c8f9a421c70a617df35a17 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 7 Aug 2004 15:12:11 +0000 Subject: [PATCH] free-serverref-list-20040807 Freeing the cm_serverRef_t has proved to be a challenge to get it right. We now pass a pointer to a pointer to the first object in the list to the function. We must be very careful to not destroy the list as we walk the contents of the list with the extra level of indirection. On the other hand, when we are freeing members of the list which have reached a refCount of zero, we must be sure to maintain the fiction of the extra level of indirection. --- src/WINNT/afsd/cm_server.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/WINNT/afsd/cm_server.c b/src/WINNT/afsd/cm_server.c index 928adc020..fa1a72a6e 100644 --- a/src/WINNT/afsd/cm_server.c +++ b/src/WINNT/afsd/cm_server.c @@ -433,19 +433,21 @@ void cm_FreeServer(cm_server_t* server) void cm_FreeServerList(cm_serverRef_t** list) { cm_serverRef_t **current = list; - cm_serverRef_t **next = 0; + cm_serverRef_t **nextp = 0; + cm_serverRef_t * next = 0; lock_ObtainWrite(&cm_serverLock); while (*current) { - next = &(*current)->next; + nextp = &(*current)->next; if (--((*current)->refCount) == 0) { + next = *nextp; cm_FreeServer((*current)->server); free(*current); - *current = *next; + *current = next; } else { - current = next; + current = nextp; } } -- 2.39.5