MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rn_inithead

Function rn_inithead

freebsd/net/radix.c:1121–1158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119/* Functions used by 'struct radix_node_head' users */
1120
1121int
1122rn_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
1160static int
1161rn_freeentry(struct radix_node *rn, void *arg)

Callers 5

pfr_create_ktableFunction · 0.85
ta_init_radixFunction · 0.85
lradix4_initFunction · 0.85
lradix6_initFunction · 0.85
vfs_create_addrlist_afFunction · 0.85

Calls 1

rn_inithead_internalFunction · 0.85

Tested by

no test coverage detected