2012-04-25から1日間の記事一覧

単連結リストの整列 #3 リスト末尾付近をきちんと扱う

C

関数node_swapに与えた要素がリストの末尾近辺の場合のバグの修正は簡単である。 test_node.c ...snip static void node_swap(node_t *current) { node_t *p, *q; if (current == NULL || (p = current->next) == NULL || (q = p->next) == NULL) return; cu…