I've created this function that destroys a linked list, `head` is the head of the linked list.

```
void destroy(node** head){

    node* current = NULL;
    while(*head != NULL){
        current = *head;
        free(current);
        *head = (*head)->next;
    }

}

```

I thought that this code won't work because `head` and `current` point to the same address in memory, and since it was freed, you can't access `(*head)->next`. But when I ran the program it worked fine, when I checked the list was empty. 

I even ran a valgrind test on the program, there was no memory leaks, although there is few cryptic errors.

Why is this code working ? It does not seem intuitive.