bool HostLookup::MatchNext(HostLookupState* s, void** opaque_ptr) Searches our tree and updates argresult for each element matching arg hostname
| 895 | // arg hostname |
| 896 | // |
| 897 | bool |
| 898 | HostLookup::MatchNext(HostLookupState *s, void **opaque_ptr) |
| 899 | { |
| 900 | HostBranch *cur = s->cur; |
| 901 | |
| 902 | // Check to see if there is any work to be done |
| 903 | if (leaf_array.size() <= 0) { |
| 904 | return false; |
| 905 | } |
| 906 | |
| 907 | while (s->table_level <= HOST_TABLE_DEPTH) { |
| 908 | if (MatchArray(s, opaque_ptr, cur->leaf_indices, s->hostname_stub.empty())) { |
| 909 | return true; |
| 910 | } |
| 911 | // Check to see if we run out of tokens in the hostname |
| 912 | if (s->hostname_stub.empty()) { |
| 913 | break; |
| 914 | } |
| 915 | // Check to see if there are any lower levels |
| 916 | if (cur->type == HostBranch::HOST_TERMINAL) { |
| 917 | break; |
| 918 | } |
| 919 | |
| 920 | TextView name{s->hostname_stub}; |
| 921 | auto token = name.take_suffix_at('.'); |
| 922 | s->hostname_stub = name; |
| 923 | cur = FindNextLevel(cur, token, true); |
| 924 | |
| 925 | if (cur == nullptr) { |
| 926 | break; |
| 927 | } else { |
| 928 | s->cur = cur; |
| 929 | s->array_index = -1; |
| 930 | ++(s->table_level); |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | return false; |
| 935 | } |
| 936 | |
| 937 | // void HostLookup::AllocateSpace(int num_entries) |
| 938 | // |
no test coverage detected