| 1119 | /* Functions used by 'struct radix_node_head' users */ |
| 1120 | |
| 1121 | int |
| 1122 | rn_inithead(void **head, int off) |
| 1123 | { |
| 1124 | struct radix_node_head *rnh; |
| 1125 | struct radix_mask_head *rmh; |
| 1126 | |
| 1127 | rnh = *head; |
| 1128 | rmh = NULL; |
| 1129 | |
| 1130 | if (*head != NULL) |
| 1131 | return (1); |
| 1132 | |
| 1133 | R_Zalloc(rnh, struct radix_node_head *, sizeof (*rnh)); |
| 1134 | R_Zalloc(rmh, struct radix_mask_head *, sizeof (*rmh)); |
| 1135 | if (rnh == NULL || rmh == NULL) { |
| 1136 | if (rnh != NULL) |
| 1137 | R_Free(rnh); |
| 1138 | if (rmh != NULL) |
| 1139 | R_Free(rmh); |
| 1140 | return (0); |
| 1141 | } |
| 1142 | |
| 1143 | /* Init trees */ |
| 1144 | rn_inithead_internal(&rnh->rh, rnh->rnh_nodes, off); |
| 1145 | rn_inithead_internal(&rmh->head, rmh->mask_nodes, 0); |
| 1146 | *head = rnh; |
| 1147 | rnh->rh.rnh_masks = rmh; |
| 1148 | |
| 1149 | /* Finally, set base callbacks */ |
| 1150 | rnh->rnh_addaddr = rn_addroute; |
| 1151 | rnh->rnh_deladdr = rn_delete; |
| 1152 | rnh->rnh_matchaddr = rn_match; |
| 1153 | rnh->rnh_lookup = rn_lookup; |
| 1154 | rnh->rnh_walktree = rn_walktree; |
| 1155 | rnh->rnh_walktree_from = rn_walktree_from; |
| 1156 | |
| 1157 | return (1); |
| 1158 | } |
| 1159 | |
| 1160 | static int |
| 1161 | rn_freeentry(struct radix_node *rn, void *arg) |
no test coverage detected