Lines Matching refs:chain
49 * chain junk, and replace with dns_rbt_firstnode, _previousnode, _nextnode,
53 #define VALID_CHAIN(chain) ISC_MAGIC_VALID(chain, CHAIN_MAGIC)
136 #define ADD_LEVEL(chain, node) \
137 (chain)->levels[(chain)->level_count++] = (node)
314 chain_name(dns_rbtnodechain_t *chain, dns_name_t *name,
323 if (include_chain_end && chain->end != NULL) {
324 NODENAME(chain->end, &nodename);
331 for (i = (int)chain->level_count - 1; i >= 0; i--) {
332 NODENAME(chain->levels[i], &nodename);
342 move_chain_to_last(dns_rbtnodechain_t *chain, dns_rbtnode_t *node) {
354 ADD_LEVEL(chain, node);
358 chain->end = node;
378 dns_rbtnodechain_t chain;
407 dns_rbtnodechain_init(&chain, rbt->mctx);
486 ADD_LEVEL(&chain, current);
507 * XXXDCL Since chain ancestors were removed,
514 if (chain.level_count ==
515 (sizeof(chain.levels) /
516 sizeof(*chain.levels))) {
577 ADD_LEVEL(&chain, new_current);
677 dns_rbtnode_t **node, dns_rbtnodechain_t *chain,
698 * If there is a chain it needs to appear to be in a sane state,
699 * otherwise a chain is still needed to generate foundname and
702 if (chain == NULL) {
704 chain = &localchain;
705 dns_rbtnodechain_init(chain, rbt->mctx);
707 dns_rbtnodechain_reset(chain);
881 * Point the chain to the next level. This
888 * function needs the chain pointed to the
891 ADD_LEVEL(chain, current);
902 result = chain_name(chain,
906 dns_rbtnodechain_reset(chain);
956 chain->end = current;
957 chain->level_matches = chain->level_count;
960 result = chain_name(chain, foundname, ISC_TRUE);
976 * Unwind the chain to the partial match node
980 * chain->level_count is guaranteed to be at least 1
982 * the chain is pointed to at least the first subtree.
984 chain->level_matches = chain->level_count - 1;
986 while (chain->levels[chain->level_matches] != *node) {
987 INSIST(chain->level_matches > 0);
988 chain->level_matches--;
992 unsigned int saved_count = chain->level_count;
994 chain->level_count = chain->level_matches + 1;
996 result = chain_name(chain, foundname,
999 chain->level_count = saved_count;
1015 * chain to the exact match, but this is subject
1024 chain->end = current;
1028 * Ensure the chain points nowhere.
1030 chain->end = NULL;
1034 * Since there was no exact match, the chain argument
1047 INSIST(chain->level_count > 0);
1048 INSIST(chain->level_matches <
1049 chain->level_count);
1050 chain->end =
1051 chain->levels[--chain->level_count];
1121 * else in the tree, the chain is reset.
1130 ADD_LEVEL(chain, current);
1133 move_chain_to_last(chain,
1144 chain->end = current;
1149 chain->end = current;
1151 result2 = dns_rbtnodechain_prev(chain,
1161 dns_rbtnodechain_reset(chain);
1259 * Is a chain pointing to it? An iterator? Who knows! (Note that the
2206 dns_rbtnodechain_init(dns_rbtnodechain_t *chain, isc_mem_t *mctx) {
2208 * Initialize 'chain'.
2211 REQUIRE(chain != NULL);
2213 chain->mctx = mctx;
2214 chain->end = NULL;
2215 chain->level_count = 0;
2216 chain->level_matches = 0;
2217 memset(chain->levels, 0, sizeof(chain->levels));
2219 chain->magic = CHAIN_MAGIC;
2223 dns_rbtnodechain_current(dns_rbtnodechain_t *chain, dns_name_t *name,
2228 REQUIRE(VALID_CHAIN(chain));
2231 *node = chain->end;
2233 if (chain->end == NULL)
2237 NODENAME(chain->end, name);
2239 if (chain->level_count == 0) {
2256 if (chain->level_count > 0)
2257 result = chain_name(chain, origin, ISC_FALSE);
2266 dns_rbtnodechain_prev(dns_rbtnodechain_t *chain, dns_name_t *name,
2273 REQUIRE(VALID_CHAIN(chain) && chain->end != NULL);
2277 current = chain->end;
2327 ADD_LEVEL(chain, predecessor);
2342 } else if (chain->level_count > 0) {
2349 INSIST(chain->level_count > 0 && IS_ROOT(current));
2350 predecessor = chain->levels[--chain->level_count];
2359 (chain->level_count > 0 || OFFSETLEN(predecessor) > 1))
2364 chain->end = predecessor;
2367 result = dns_rbtnodechain_current(chain, name, origin,
2373 result = dns_rbtnodechain_current(chain, name, NULL,
2383 dns_rbtnodechain_down(dns_rbtnodechain_t *chain, dns_name_t *name,
2390 REQUIRE(VALID_CHAIN(chain) && chain->end != NULL);
2394 current = chain->end;
2402 if (chain->level_count > 0 ||
2406 ADD_LEVEL(chain, current);
2416 chain->end = successor;
2428 NODENAME(chain->end, name);
2432 result = chain_name(chain, origin, ISC_FALSE);
2447 dns_rbtnodechain_nextflat(dns_rbtnodechain_t *chain, dns_name_t *name) {
2451 REQUIRE(VALID_CHAIN(chain) && chain->end != NULL);
2455 current = chain->end;
2477 chain->end = successor;
2480 NODENAME(chain->end, name);
2490 dns_rbtnodechain_next(dns_rbtnodechain_t *chain, dns_name_t *name,
2497 REQUIRE(VALID_CHAIN(chain) && chain->end != NULL);
2501 current = chain->end;
2513 if (chain->level_count > 0 ||
2517 ADD_LEVEL(chain, current);
2552 if (chain->level_count == 0)
2555 current = chain->levels[--chain->level_count];
2574 chain->end = successor;
2586 NODENAME(chain->end, name);
2590 result = chain_name(chain, origin, ISC_FALSE);
2605 dns_rbtnodechain_first(dns_rbtnodechain_t *chain, dns_rbt_t *rbt,
2612 REQUIRE(VALID_CHAIN(chain));
2614 dns_rbtnodechain_reset(chain);
2616 chain->end = rbt->root;
2618 result = dns_rbtnodechain_current(chain, name, origin, NULL);
2627 dns_rbtnodechain_last(dns_rbtnodechain_t *chain, dns_rbt_t *rbt,
2634 REQUIRE(VALID_CHAIN(chain));
2636 dns_rbtnodechain_reset(chain);
2638 result = move_chain_to_last(chain, rbt->root);
2642 result = dns_rbtnodechain_current(chain, name, origin, NULL);
2652 dns_rbtnodechain_reset(dns_rbtnodechain_t *chain) {
2654 * Free any dynamic storage associated with 'chain', and then
2655 * reinitialize 'chain'.
2658 REQUIRE(VALID_CHAIN(chain));
2660 chain->end = NULL;
2661 chain->level_count = 0;
2662 chain->level_matches = 0;
2666 dns_rbtnodechain_invalidate(dns_rbtnodechain_t *chain) {
2668 * Free any dynamic storage associated with 'chain', and then
2669 * invalidate 'chain'.
2672 dns_rbtnodechain_reset(chain);
2674 chain->magic = 0;