From d402ce219071c433938e4ca88f67cb7e81e03673 Mon Sep 17 00:00:00 2001 From: octo Date: Fri, 19 May 2006 14:47:06 +0000 Subject: [PATCH] Reverse the ordering of the hosts. --- src/liboping.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/liboping.c b/src/liboping.c index 2892beb..ea4fc74 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -1048,8 +1048,26 @@ int ping_host_add (pingobj_t *obj, const char *host) return (-1); } - ph->next = obj->head; - obj->head = ph; + /* + * Adding in the front is much easier, but then the iterator will + * return the host that was added last as first host. That's just not + * nice. -octo + */ + if (obj->head == NULL) + { + obj->head = ph; + } + else + { + pinghost_t *hptr; + + hptr = obj->head; + while (hptr->next != NULL) + hptr = hptr->next; + + assert ((hptr != NULL) && (hptr->next == NULL)); + hptr->next = ph; + } ping_set_ttl (ph, obj->ttl); -- 2.30.2