From: octo Date: Fri, 19 May 2006 14:47:06 +0000 (+0000) Subject: Reverse the ordering of the hosts. X-Git-Tag: liboping-0.2.0~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d402ce219071c433938e4ca88f67cb7e81e03673;p=liboping.git Reverse the ordering of the hosts. --- 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);