Commit 43064f52 authored by Geoff Simmons's avatar Geoff Simmons

Add some source code comments.

parent 971b9ed1
......@@ -41,6 +41,23 @@
#include "patricia.h"
/*
* A trie is comprised by a tree of pt_y nodes and an array of strings,
* both of which are owned by a VMOD object. Both are passed in to the
* PT_* functions.
*
* idx is an index to the strings array, and the region of the string
* represented at a node is strings[idx][off] to strings[idx][len],
* inclusive.
*
* Terminating nulls form a part of the target string. So "foo\0" and
* "foobar\0" differ at the fourth byte, and the critical bit at that byte
* is the most significant 1-bit in 'b'.
*
* bitmask is set at the critical bit in the differing byte, and
* determines whether searches continue into leaf[0] or leaf[1].
*/
struct pt_y {
unsigned magic;
#define PT_Y_MAGIC 0xfa564d14
......@@ -176,7 +193,7 @@ PT_Insert(struct pt_y * * restrict root, unsigned idx,
if (i == y->len) {
/*
* The string to be inserted has a prefix that is
* already in the tree.
* already in the trie.
*/
bit = (y->bitmask & *c) != 0;
assert(bit < 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment