* Allocate a bigger ID hash. */
| 1011 | * Allocate a bigger ID hash. |
| 1012 | */ |
| 1013 | static void |
| 1014 | ng_ID_rehash() |
| 1015 | { |
| 1016 | struct nodehash *new; |
| 1017 | uint32_t hash; |
| 1018 | u_long hmask; |
| 1019 | node_p node, node2; |
| 1020 | int i; |
| 1021 | |
| 1022 | new = hashinit_flags((V_ng_ID_hmask + 1) * 2, M_NETGRAPH_NODE, &hmask, |
| 1023 | HASH_NOWAIT); |
| 1024 | if (new == NULL) |
| 1025 | return; |
| 1026 | |
| 1027 | for (i = 0; i <= V_ng_ID_hmask; i++) |
| 1028 | LIST_FOREACH_SAFE(node, &V_ng_ID_hash[i], nd_idnodes, node2) { |
| 1029 | #ifdef INVARIANTS |
| 1030 | LIST_REMOVE(node, nd_idnodes); |
| 1031 | #endif |
| 1032 | hash = (node->nd_ID % (hmask + 1)); |
| 1033 | LIST_INSERT_HEAD(&new[hash], node, nd_idnodes); |
| 1034 | } |
| 1035 | |
| 1036 | hashdestroy(V_ng_ID_hash, M_NETGRAPH_NODE, V_ng_name_hmask); |
| 1037 | V_ng_ID_hash = new; |
| 1038 | V_ng_ID_hmask = hmask; |
| 1039 | } |
| 1040 | |
| 1041 | /************************************************************************ |
| 1042 | Hook routines |
no test coverage detected