aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-11-28 17:49:55 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-11-28 17:49:55 +0000
commit09006c25d399ff2080c0e8660d0d95ff3cd25455 (patch)
tree677d91cb6afc5877ceea01e859c630ae6a99d48e
parent7f52702a7fd4711e863af33beee1f370e4eccdbf (diff)
downloadfetchmail-09006c25d399ff2080c0e8660d0d95ff3cd25455.tar.gz
fetchmail-09006c25d399ff2080c0e8660d0d95ff3cd25455.tar.bz2
fetchmail-09006c25d399ff2080c0e8660d0d95ff3cd25455.zip
Save id pairs in the right order.
svn path=/trunk/; revision=583
-rw-r--r--uid.c16
1 files changed, 9 insertions, 7 deletions
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__