/**
* if has loop return 1 else return 0
*/
static int has_loop(List *list)
{
List *pFast;
List *pSlow;
pFast = pSlow = list;
if (pFast != NULL && pFast->next != NULL) {
pFast = pFast->next->next;
} else {
return 0;
}
while (pFast != pSlow) {
if (pFast != NULL && pFast->next != NULL)
pFast = pFast->next->next;
else
break;
pSlow = pSlow->next;
}
if (pFast == pSlow)
return 1;
else
return 0;
}