c++ function to convert a linear list to circular list

hi all,

i need a c++ function which converts a linear list to circular.
presently i am working with two files. i.e., one linear list file. and one circular list file to do some operations. i thought it will be helpful if there is a function that converts a linear list to circular n undo the same whenever required.....
Please help me........


typedef struct node {
   int list_data;
   struct node *next;
} NODE;

void Linear2Circular (NODE *list) {
   
   NODE *tmp = list;
   if(NULL != tmp) {
      /*
      ** The list has one or more nodes.
      */
      while (NULL != tmp->next)
         tmp = tmp->next;

      tmp->next = list;   //Converted into the circular formation.
   }
}