In this implementation of linked list insertion, the author uses double pointer to pass the linked list to the method.
I couldn't understand why he didn't use single pointer. Could you explain the reason for using double pointer?
void insert_list(list **l, item_type x)
{
list *p; /* temporary pointer */
p = malloc( sizeof(list) );
p->item = x;
p->next = *l;
*l = p;
}
In other words, what would be wrong with the following implementation?
void insert_list(list *l, item_type x)
{
list *p; /* temporary pointer */
p = malloc( sizeof(list) );
p->item = x;
p->next = l;
l = p;
}