2 ms·
The 2nd one would be significantly more readable with explicit typing (to make it clear that you're dealing with a pointer to pointer). Though I think putting
by ummonk 8y ago
The 2nd one would be significantly more readable with explicit typing (to make it clear that you're dealing with a pointer to pointer).
Though I think putting the head check at the beginning like you said will make the first example very reasonable (and relatively compact too).
remove_list_entry(entry)
{
if (head == entry) {
head = entry->next;
} else {
prev = head;
while (prev->next != entry) {
prev = prev->next;
}
prev->next = entry->next;
}
}