Can someone explain 2 last lines of TAILQ_INSERT_TAIL macro:
#define TAILQ_INSERT_TAIL(head, elm, field) do {
(elm)->field.tqe_next = NULL; /
(elm)->field.tqe_prev = (head)->tqh_last; /
*(head)->tqh_last = (elm); /
(head)->tqh_last = &(elm)->field.tqe_next; /
} while (/*CONSTCOND*/0)
I understand, that, in generally, for insert in the tail of queue some node we need to do 4 things: 1) In node null pointer to next node. (first line of macro) 2) In last element of queue add pointer to node (second line of macro) 3) In node link pointer to previous node to last element in queue. 4) Update in queue head structure pointer to last element from last element in queue to our node.
1 and 2 points i understand clearly in macro, but 3 and 4 takes some misunderstanding, especially, i can not understand code like:
*(head)->tqh_last = (elm);
Call up last node in queue and overwrite it by current node? What will be with last node?