using namespace basis;
using namespace structures;
-#define DEBUG_PACKABLE_TREE
+//#define DEBUG_PACKABLE_TREE
// uncomment for noisy debugging.
#undef LOG
void packable_tree::calcit(int &size_accumulator, const packable_tree *current_node)
{
-LOG(a_sprintf("calcing node %x", current_node));
FUNCDEF("calcit");
+#ifdef DEBUG_PACKABLE_TREE
+ LOG(a_sprintf("calcing node %x", current_node));
+#endif
if (!current_node) throw_error(static_class_name(), func, "current node is nil");
tree_command_unit temp;
size_accumulator += current_node->packed_size() + temp.packed_size();
-LOG(a_sprintf("len A %d", size_accumulator));
+#ifdef DEBUG_PACKABLE_TREE
+ LOG(a_sprintf("len A %d", size_accumulator));
+#endif
}
void packable_tree::packit(byte_array &packed_form, const packable_tree *current_node)
int packable_tree::recursive_packed_size() const
{
- packable_tree *curr = NIL;
+ packable_tree *curr = NULL_POINTER;
int accum = 0; // where we accumulate the length of the packed form.
for (iterator zip2 = start(postfix); (curr = (packable_tree *)zip2.next()); )
calcit(accum, curr);
void packable_tree::recursive_pack(byte_array &packed_form) const
{
- packable_tree *curr = NIL;
+ packable_tree *curr = NULL_POINTER;
for (iterator zip2 = start(postfix); (curr = (packable_tree *)zip2.next()); )
packit(packed_form, curr);
// get the first command out of the package.
if (!cmd.unpack(packed_form)) {
//complain.
- return NIL;
+ return NULL_POINTER;
}
- packable_tree *new_branch = NIL;
+ packable_tree *new_branch = NULL_POINTER;
bool failure = false; // set to true if errors occurred.
// the packed tree is traversed by grabbing a command and then doing what