Q:

Little bit confusing about free pointer inside function

some weeks ago I learn about proper way how pointers should be allocated and dealocated inside function so given in example linkedList:
typedef struct _node {
    void *data;
    struct _node *next;
} Node;

typedef struct _linkedList {
    Node *head;
    Node *tail;
    Node *current;
} LinkedList;

In My opinion right way to destroy queue is by using function that get pointer to pointer to node which I want to delete:
void destroy (Node ** node) 

Or in more real world example pointer to pointer and pointer to list to delete.
void destroy (LinkedList * list, Node ** node) 

but now I am reading book "Understanding C pointers" and I encounter to problem because In chapter 6 pointers to structures there is followed example of function destroyList:
void delete(LinkedList *list, Node *node) {
    if (node == list->head) {
        if (list->head->next == NULL) {
            list->head = list->tail = NULL;
        } else {
            list->head = list->head->next;
        }
    } else {
        Node *tmp = list->head;
        while (tmp != NULL && tmp->next != node) {
            tmp = tmp->next;
        }
       if (tmp != NULL) {
            tmp->next = node->next;
        }    
    }   
    free(node);  //free on pointer copy value not pointer
}

So in this example author run free on pointer that is passed by value, so in my opinion this shouldn't work. But I looked into errata and there is no notes about this example.
In this case I understand that List is function argument to use correct instance of list, but is should be rather that:
free(list->head) ; //It should work?

And then also free memory for allocated List.
Am I right? Because reading this example I have a feeling that I have a problem with good understanding of this topic.
Also I went to Linux Man Page and I saw free prototype:
 void free(void *ptr);    // http://linux.die.net/man/3/free

So why everybody told to pass pointer to pointer when You want to free memory but in standard library same free function take as parameter not pointer to pointer but pointer, how it work correctly?

A:

as you state correctly, free( void *p ) frees the memory p points to but as the address is passed by value it will remain unchanged for the caller. Thus you could run into problems like this:
int *p = malloc( sizeof *p );

*p = 1;
free( p );
...

if( p )
   *p = 2;     // Undefined Behaviour!!! although p is free()'d it's still != NULL

So you will often find
free( p );
p = NULL;

Nevertheless in my opinion it's ok to write a free() like function where you pass a pointer by value as long as the function's description states clearly that the pointer must not be used afterwards (no matter wht type of pointer that may be). But of course you're free to define the function with double pointers and set everything you have free()'d to NULL inside, like in this very simple example:
void myfree( void **pp )
{
   free( *p );
   *p = NULL;
}

...
int *p = malloc( sizeof *p );
...
myfree( &p );
// now p == NULL

