return value 1 means no loop zero indicates loop
| 639 | // return value 1 means no loop |
| 640 | // zero indicates loop |
| 641 | int |
| 642 | dir_bucket_loop_check(CacheDirEntry *start_dir, CacheDirEntry *seg) |
| 643 | { |
| 644 | if (start_dir == nullptr) { |
| 645 | return 1; |
| 646 | } |
| 647 | |
| 648 | CacheDirEntry *p1 = start_dir; |
| 649 | CacheDirEntry *p2 = start_dir; |
| 650 | |
| 651 | while (p2) { |
| 652 | // p1 moves by one entry per iteration |
| 653 | ink_assert(p1); |
| 654 | p1 = next_dir(p1, seg); |
| 655 | // p2 moves by two entries per iteration |
| 656 | p2 = next_dir(p2, seg); |
| 657 | if (p2) { |
| 658 | p2 = next_dir(p2, seg); |
| 659 | } else { |
| 660 | return 1; |
| 661 | } |
| 662 | |
| 663 | if (p2 == p1) { |
| 664 | return 0; // we have a loop |
| 665 | } |
| 666 | } |
| 667 | return 1; |
| 668 | } |
| 669 | #endif |
| 670 | |
| 671 | int |
nothing calls this directly
no test coverage detected