i have a single list non-circular without sentinel and i want to duplicate every node of it. For example, i have 7,5,12,16 and i want to have : 7,7,5,5,12,12,16,16 but i can't create it.Below is my function code for duplicate the nodes(other parts of the program are correct).
    int duplicate_list(listT *list_head) {
    listT *current, *new_node;
    for(current = list_head; current != NULL; current = current->next,counter++) {
            new_node = (listT *)malloc(sizeof(listT));
            if(new_node == NULL) {
                printf("problem in new_node\n");
                free(new_node);
                exit(-1);
            }
            new_node->data = current->data;
            new_node->next = current;
    }
    return(1);
 }
Can someone help me?
 
    