int fix_loop(struct node **start)// pass start as a pass by reference argument
{
struct node *temp,**ma;
int count = 0,i;
temp = *start;
ma = calloc(sizeof(struct node *),20);
while(1)
{
if(!(temp->next))
{
printf(“there is no loop\n”);
return -1;
}
for(i=0; i<count; i++)
{
if(temp->next == *(ma+i))// create a master array which contains all the unique addresses
goto o;
// printf(“i = %d\n”,i);
}
printf(” count = %d\n”,count);
*(ma+(count)) = temp;
count++;
// ma = realloc(ma,count+1);
temp = temp->next;
}
o: temp->next= NULL;
printf(“loop!! fixed\n”);
free(ma);
return 0;
}