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