model: fixup style
[model-checker.git] / nodestack.cc
index 2e170b9f35eb8e424db6949754bb32d8146a0ba2..86d7f6bbc61a5f88caeb56ff54810e255514a0fd 100644 (file)
@@ -1,3 +1,5 @@
+#include <string.h>
+
 #include "nodestack.h"
 #include "action.h"
 #include "common.h"
@@ -32,11 +34,12 @@ Node::Node(ModelAction *act, Node *par, int nthreads, bool *enabled)
        if (act)
                act->set_node(this);
        enabled_array=(bool *)MYMALLOC(sizeof(bool)*num_threads);
-       if (enabled)
+       if (enabled != NULL)
                memcpy(enabled_array, enabled, sizeof(bool)*num_threads);
-       else 
+       else {
                for(int i=0;i<num_threads;i++)
                        enabled_array[i]=false;
+       }
 }
 
 /** @brief Node desctructor */
@@ -223,6 +226,12 @@ bool Node::is_enabled(Thread *t)
        return thread_id < num_threads && enabled_array[thread_id];
 }
 
+bool Node::is_enabled(thread_id_t tid)
+{
+       int thread_id=id_to_int(tid);
+       return thread_id < num_threads && enabled_array[thread_id];
+}
+
 /**
  * Add an action to the may_read_from set.
  * @param act is the action to add
@@ -347,7 +356,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act, bool * is_enabled)
 
        /* Record action */
        get_head()->explore_child(act);
-       node_list.push_back(new Node(act, get_head(), model->get_num_threads()));
+       node_list.push_back(new Node(act, get_head(), model->get_num_threads(), is_enabled));
        total_nodes++;
        iter++;
        return NULL;