contributed by <hsiehong
>
進階電腦系統理論與實作
add_entry
AA1 : assert(new_node);
AA2 : *indirect = new_node;
assert(new_node)
在 C Library中,此 macro 會比較參數與0。相同的話錯誤訊息會被寫入 standard error device 且會呼叫abortnew_node
能分配到空間*indirect
會從 head 走訪 linked list 的所有節點,在迴圈結束時會停在最後一個節點,此時會將新的節點 new_node
assign 給*indirect
,即插入串列尾。swap_pair
BB1 : node = &(*node)->next->next
BB2 : *node = (*node)->next
dereference 與 reference 概念不清楚, pointer to pointer 概念混亂, 還需要去多找一些資料閱讀
reverse
CCC : head->next = cursor; cursor = head
cursor
在每一個 iteration 中,初始都會在原 linked list 中 head
的前一個 node ,next
則永遠是 head
的下一項,並且將 head->next 指向 cursor (反轉的動作),再將 cursor 指向 head