Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. void backup(int *first)
  2. {
  3. list *newfirst, *current, *currentprev, *oldcurrent;
  4. newfirst = (list*)malloc(sizeof(list));
  5. newfirst->undop = first;
  6. first->redop = newfirst;
  7. newfirst->val = first -> val;
  8. currentprev = newfirst;
  9. oldcurrent = first->next;
  10. while(oldcurrent!=NULL)
  11. {
  12. current = (list*)malloc(sizeof list);
  13. current -> val = oldcurrent -> val;
  14. current -> prev = currentprev;
  15. currentprev -> next = current;
  16. current->next = NULL;
  17. currentprev = current;
  18. oldcurrent = oldcurrent->next;
  19. }
  20. first = newfirst;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement