From 20a1be81c938a2f89b95e5e4436124bd3fa6aa43 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 6 Mar 2005 15:27:56 +0000 Subject: Make free_str_list iterative, to reduce stack usage. Suggested by Manfred Weihs. svn path=/trunk/; revision=4022 --- uid.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/uid.c b/uid.c index 01a33137..fbb314e3 100644 --- a/uid.c +++ b/uid.c @@ -298,13 +298,15 @@ struct idlist *save_str(struct idlist **idl, const char *str, flag st) void free_str_list(struct idlist **idl) /* free the given UID list */ { - if (*idl == (struct idlist *)NULL) - return; + struct idlist *i = *idl; - free_str_list(&(*idl)->next); - free ((*idl)->id); - free(*idl); - *idl = (struct idlist *)NULL; + while(i) { + struct idlist *t = i->next; + free(i->id); + free(i); + i = t; + } + *idl = 0; } void save_str_pair(struct idlist **idl, const char *str1, const char *str2) -- cgit v1.2.3