more bugs
authorBrian Demsky <bdemsky@uci.edu>
Wed, 19 Sep 2012 08:19:39 +0000 (01:19 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Wed, 19 Sep 2012 08:19:39 +0000 (01:19 -0700)
nodestack.cc
schedule.cc

index 2e170b9..b79863e 100644 (file)
@@ -32,11 +32,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 (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);
                memcpy(enabled_array, enabled, sizeof(bool)*num_threads);
-       else 
+       else {
                for(int i=0;i<num_threads;i++)
                        enabled_array[i]=false;
                for(int i=0;i<num_threads;i++)
                        enabled_array[i]=false;
+       }
 }
 
 /** @brief Node desctructor */
 }
 
 /** @brief Node desctructor */
@@ -347,7 +348,7 @@ ModelAction * NodeStack::explore_action(ModelAction *act, bool * is_enabled)
 
        /* Record action */
        get_head()->explore_child(act);
 
        /* 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;
        total_nodes++;
        iter++;
        return NULL;
index c30b0f3..8883d2a 100644 (file)
@@ -16,9 +16,11 @@ void Scheduler::set_enabled(Thread *t, bool enabled_status) {
        int threadid=id_to_int(t->get_id());
        if (threadid>=enabled_len) {
                bool * new_enabled=(bool *)malloc(sizeof(bool)*(threadid+1));
        int threadid=id_to_int(t->get_id());
        if (threadid>=enabled_len) {
                bool * new_enabled=(bool *)malloc(sizeof(bool)*(threadid+1));
-               memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
                memset(&new_enabled[enabled_len], 0, (threadid+1-enabled_len)*sizeof(bool));
                memset(&new_enabled[enabled_len], 0, (threadid+1-enabled_len)*sizeof(bool));
-               free(is_enabled);
+               if (is_enabled != NULL) {
+                       memcpy(new_enabled, is_enabled, enabled_len*sizeof(bool));
+                       free(is_enabled);
+               }
                is_enabled=new_enabled;
                enabled_len=threadid+1;
        }
                is_enabled=new_enabled;
                enabled_len=threadid+1;
        }