Reversing a doubly linked list in C Looking for feedback on this code to reverse a double linked list. Things I am potentially looking for but missed -&gt; redundant operations, extra / unnecessary arithmetic, improvement in code style. Thank yoU!

typedef struct Node {
    int data;
    struct Node* next;
    struct Node* prev;
} Node;


void reverse(Node** head) {

    Node* curr = *head;
    Node* prev_ptr = NULL;
    Node* next_ptr = NULL;
    while (curr != NULL) {
        prev_ptr = curr-&gt;prev;
        next_ptr = curr-&gt;next;
        curr-&gt;prev = next_ptr;
        curr-&gt;next = prev_ptr;
        (*head) = curr;
        curr = next_ptr;

    }

}
You don't need to reverse a doubly linked list, which is an O(n) operation.
Just define a structure that will hold the head and tail of the list.
struct List
{
  Node* head;
  Node* tail;
  unsigned int count; // you can also keep track of number of nodes to access the count in O(1)
}

Functions manipulating the list shall now accept List* list rather then Node** head. They will also have to contain logic that checks and assigns the tail, but none of the operations should get any more complex in terms of its big-O time complexity.
Now traversing the list in reversed order is just matter of traversing the list from tail to head, rather then head to tail direction.
Doubly linked list without a tail is basically a singly linked list with capability to traverse back from where you already traversed forward, but never directly from the tail towards the head (without additional effort).