return false;
}
+/**
+ * Create a new clock vector for this action. Note that this function allows a
+ * user to clobber (and leak) a ModelAction's existing clock vector. A user
+ * should ensure that the vector has already either been rolled back
+ * (effectively "freed") or freed.
+ *
+ * @param parent A ModelAction from which to inherit a ClockVector
+ */
void ModelAction::create_cv(const ModelAction *parent)
{
- if (cv)
- delete cv;
-
if (parent)
cv = new ClockVector(parent->cv, this);
else
ClockVector::ClockVector(ClockVector *parent, ModelAction *act)
{
num_threads = model->get_num_threads();
- clock = (modelclock_t *)MYMALLOC(num_threads * sizeof(int));
- memset(clock, 0, num_threads * sizeof(int));
+ clock = (modelclock_t *)snapshot_calloc(num_threads, sizeof(int));
if (parent)
std::memcpy(clock, parent->clock, parent->num_threads * sizeof(modelclock_t));
/** @brief Destructor */
ClockVector::~ClockVector()
{
- MYFREE(clock);
+ snapshot_free(clock);
}
/**
if (cv->num_threads > num_threads) {
resize = true;
- clk = (modelclock_t *)MYMALLOC(cv->num_threads * sizeof(modelclock_t));
+ clk = (modelclock_t *)snapshot_malloc(cv->num_threads * sizeof(modelclock_t));
}
/* Element-wise maximum */
for (int i = num_threads; i < cv->num_threads; i++)
clk[i] = cv->clock[i];
num_threads = cv->num_threads;
- MYFREE(clock);
+ snapshot_free(clock);
}
clock = clk;
}