| 9 | }; |
| 10 | |
| 11 | void push(Node** head_ref, int new_data) |
| 12 | { |
| 13 | /* allocate node */ |
| 14 | Node* new_node = new Node(); |
| 15 | |
| 16 | /* put in the data */ |
| 17 | new_node->data = new_data; |
| 18 | |
| 19 | /* link the old list off the new node */ |
| 20 | new_node->next = (*head_ref); |
| 21 | |
| 22 | /* move the head to point to the new node */ |
| 23 | (*head_ref) = new_node; |
| 24 | } |
| 25 | |
| 26 | int detectLoop(Node* list) |
| 27 | { |