When you are moving items in a linked list, you have to adjust the VALUES of the pointers in the list. X = Y is just internal to your function.

Since this appears to be a double direction linked list, you'll have to set the next and prev of the one variable to the next and prev of the other while keeping those values. Then, you'll have to set the next of the prev to the Y for X and the prev of the next to the Y for X and the same for Y to X -- Keeping in mind that you'll need to preserve those values prior to changing them in the other.

All X=Y will do is change the name you have given the objects: the object you used to be calling Y is now also called X (and is still called Y), and the object you used to be calling X is now called --- well, fortunately for you, you kept that in temp! Therefore, your attempt later on to put Y->next and Y->prev into your placeholders is doomed, unless you change them to temp->next and temp->prev.