From 09006c25d399ff2080c0e8660d0d95ff3cd25455 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 28 Nov 1996 17:49:55 +0000 Subject: Save id pairs in the right order. svn path=/trunk/; revision=583 --- uid.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'uid.c') diff --git a/uid.c b/uid.c index 15a06ba3..b40d3e15 100644 --- a/uid.c +++ b/uid.c @@ -133,16 +133,18 @@ void free_uid_list(struct idlist **idl) void save_id_pair(struct idlist **idl, const char *str1, const char *str2) /* save an ID pair on the given list */ { - struct idlist *new; + struct idlist **end; + + /* do it nonrecursively so the list is in the right order */ + for (end = idl; *end; end = &(*end)->next) + continue; - new = (struct idlist *)xmalloc(sizeof(struct idlist)); - new->id = xstrdup(str1); + *end = (struct idlist *)xmalloc(sizeof(struct idlist)); + (*end)->id = xstrdup(str1); if (str2) - new->val.id2 = xstrdup(str2); + (*end)->val.id2 = xstrdup(str2); else - new->val.id2 = (char *)NULL; - new->next = *idl; - *idl = new; + (*end)->val.id2 = (char *)NULL; } #ifdef __UNUSED__ -- cgit v1.2.3