X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Fnodes%2Fpackable_tree.cpp;h=831538af81aa71978a6816a0129f36bfc747b417;hb=ef338226ccf699c8d8a149d9b74e9888175c7099;hp=a38f88ad86837f98d7fd8b6879636daa0e067e7b;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/nucleus/library/nodes/packable_tree.cpp b/nucleus/library/nodes/packable_tree.cpp index a38f88ad..831538af 100644 --- a/nucleus/library/nodes/packable_tree.cpp +++ b/nucleus/library/nodes/packable_tree.cpp @@ -82,18 +82,22 @@ packable_tree::packable_tree() : tree() {} 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) { -LOG(a_sprintf("packing node %x", current_node)); -LOG(a_sprintf("size A %d", packed_form.length())); +//LOG(a_sprintf("packing node %x", current_node)); +//LOG(a_sprintf("size A %d", packed_form.length())); FUNCDEF("packit"); if (!current_node) throw_error(static_class_name(), func, "current node is nil"); @@ -119,14 +123,14 @@ throw_error(current_node->class_name(), func, "failure calculating size"); } // stuff the command unit. command.pack(packed_form); -LOG(a_sprintf("size B %d", packed_form.length())); +//LOG(a_sprintf("size B %d", packed_form.length())); packed_form += temp_store; // main chunk is not packed, just added. -LOG(a_sprintf("size C %d", packed_form.length())); +//LOG(a_sprintf("size C %d", packed_form.length())); } 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); @@ -137,7 +141,7 @@ int packable_tree::recursive_packed_size() const 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); @@ -157,10 +161,10 @@ packable_tree *packable_tree::recursive_unpack(byte_array &packed_form, // get the first command out of the package. if (!cmd.unpack(packed_form)) { //complain. - return false; + 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