To get some practice in C, I'm writing some basic functions for operating on a linked list of ints. I started out with functions that accepted as a "list" a pointer to the head node. Now, I find myself running into more and more occasions when I either need to limit the spec of the function more than I would like, or I need to use a pointer to a pointer to the head node to allow for alteration/removal of the head node in a way that is consistent with the way I alter/remove other nodes.
Is it preferable to have all functions accept a "list" in the same form, as a pointer to a pointer, rather than having some accept just a pointer to the node? Or should I perhaps change the way I think about altering/removing the head node to avoid needing to change the head pointer?
For example, if I write a remove function that removes all instances of the given int, and the head node's value is that int, I see a few obvious choices:
I can pass in a pointer to a pointer and move the head pointer to the next node not being removed.
I can pass in a pointer and I can move the value of the next node not being removed, say node x, into the head node and remove node x along with any other nodes that hold the value to be removed. This fails in the case that the list consists of only a single node that contains the value, and so I have to limit the spec to exclude this case.
In the case that I pass in a pointer to a pointer for this function, should I now change all other functions to accept a pointer to a pointer?
Are there standards for things like this or is it up to me? (Pretending of course that this code matters in some fashion to someone other than me and would, in that fantasy land, be used by other people without knowledge of the inner workings of the functions, beyond their signatures.)