p->route_persistant = backwards;
- /* We build up head, then assign it to p->route when we're done */
+ /* Build a tailq, then assign it to p->route when done.
+ * If backwards, we add entries from the head so they end up
+ * in reverse order. However, we do need to maintain a correct
+ * tail pointer because the contact is always at the end.
+ */
head = NULL;
tail = head;
/* 1st we pass through all the hops in any Record-Route headers */
rr = __get_header(req, "Record-Route", &start);
if (*rr == '\0')
break;
- for (;;) {
- /* Each route entry */
- /* Find < */
- rr = strchr(rr, '<');
- if (!rr)
- break; /* No more hops */
+ for (; (rr = strchr(rr, '<')) ; rr += len) { /* Each route entry */
++rr;
len = strcspn(rr, ">") + 1;
/* Make a struct route */
thishop->next = head;
head = thishop;
/* If this was the first then it'll be the tail */
- if (!tail) tail = thishop;
+ if (!tail)
+ tail = thishop;
} else {
thishop->next = NULL;
/* Link in at the end */
tail = thishop;
}
}
- rr += len;
}
}