not just for partial matches, for consistency.
set level_matches even when not forming foundname, since level_matches
is an aspect of the chain, not of whether the caller wanted the
name formed by dns_rbt_findnode().
comment updates.
newlength and oldlength from signed to unsigned in join_nodes().
Use dns_name_clone for minor efficiency gain in dns_rbt_addnode.
Use fixed names in dns_rbt_findnode() for minor efficiency gain.
the attributes of the joined name to correctly identify whether it
is absolute. (IE, when the first level is joined with the top level,
the node struct being used is from the first level, which is not
absolute, but the new name is absolute so the struct needs to be updated.)
level_count was decremented below zero because the found node had not
been put in the level history before the callback broke out of the search.
Added a bunch of INSISTS()s to try to catch something like that in the future.
It wasn't that chain->end was being included (it should have been) but
that the chain had already been expanded to point down a level before
the call to chain_name that needed the state of things before the
descent.
comparison is "subdomain" but the full name at the existing node is
not in common with the input name -- when the last label is a bitstring
with some common bits.
in a lot of places now. It _returns_ if it fails to get the necessary memory,
so any function using it should be returning a dns_result_t.
chain_name moved toward start of file, for inlining by findnode.
move_chain_to_last broke out some functionality of dns_rbtnodechain_last
(which now calls it), also for the benefit of findnode.
dns_rbtnodechain_init on the chain used by addnode.
All of the new_foundname concatenation gook was removed from findnode,
which now just sets foundname by using chain_name.
The chain set up by findnode points to the predecessor when the searched
for name is not found.
nodechain_current was changed to take name, origin and node parameters while
returning a dns_result_t. This allows the chain returned by findnode to
be named.
The nodechain_{first,last,prev} use nodechain_current to set their
names and origins. nodechain_next does not need it because it will never
have to do the "set the origin to '.' and remove '.' from names in the
root level" bit. The root level will never be more than one name, and
everything in the megatree is a successor to that node, so 'next' never
reaches the root level.
what happens at ".". For most origins, they do NOT include themself in
a zone file ... that is, the record for "rc" appears in the $ORIGIN for
".vix.com."
I added support for the full search algorithm to the RBT database
code. The database has some special needs in searching, in particular
certain nodes need to be examined before the DOWN pointer is followed.
I solved this problem by adding a 'callback' bit to the node structure.
When findnode is called, the caller can supply a callback. Before we go
DOWN at a node, we call the callback if the callback bit is set at the
node. If the callback returns DNS_R_CONTINUE, we proceed. Otherwise, we
will stop right there and return what the caller said to return. I
added an 'empty_data_ok' flag to findnode as well, so that nodes with
empty data can be made candidates for partial match status.
I also wanted to make dns_rbtnodechain_t public, so that a chain could
be allocated on the stack by the caller. I added two routines,
dns_rbtnodechain_init() and dns_rbtnodechain_reset() to work with them.
The latter routine frees any dynamically allocated memory associated with
the chain. The chain structure now contains the memory context. I also
moved get_ancestor_mem() and put_ancestor_mem() up in the file, so that
inlining could be more effective.
In the nits department, you wrote
*node = result == DNS_R_SUCCESS ? current : NULL;
In the future, please write this instead (the patch has this change in it):
if (result == DNS_R_SUCCESS)
*node = current;
else
*node = NULL;
is currently fine, because there are only two attribute flags a name
can have, one of which the node definitely needs to have set, and the
other of which is functionally irrelevant (because it happens to be set
by the NODENAME macro, namely the read-only flag). This might not
be the right thing to do in the future when more name attributes get
added, but we'll cross that bridge if we get to it. (_Some_ change was
necessary because the node's attributes was not properly initialized when
created, and under certain circumstances this ended up triggering an
exception in the dns_name_* functions.
Watch for level overflow during dns_rbt_addnode(). Returns DNS_R_NOSPACE,
which is probably not the right thing.
Comment cleanups.
returns a dns_result_t.
dns_rbt_created requires deleter_arg NULL if deleter is NULL.
dns_rbt_addnode always returns DNS_R_EXISTS if the node is found, regardless
of if it has data.
dns_rbt_addname will add the data and return SUCCESS if addnode says
EXISTS but there is no data at the node.
make sure memory is freed even when get_ancestor_mem to reallocate fails.
partialmatch returned by findnode must have data associated with it.
fixed up deletename; prematurely exited without freeing chain memory if
the node was not found. made deletename responsible for identifying whether
a node could be removed rather than zapnode.
turned a few of the print support functions static.
name attributes, name length, offset length, and number of bytes
of "padding" that are left over when a node is split.
adjusted node splitting algorithm to preserve the original location
of the lower portion of the split node (eg, when a node has "a.b" as
its name and is split into "a" and "b", "a" retains the same address
space as "a.b".)