Skip to content

Commit

Permalink
fix a few crashers related to sgvector transition
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed May 4, 2012
1 parent 392ab41 commit f46645d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/shogun/evaluation/CrossValidation.cpp
Expand Up @@ -179,8 +179,6 @@ CrossValidationResult CCrossValidation::evaluate()
result.conf_int_up=0;
}

SG_FREE(results.vector);

/* unlock machine if it was locked in this method */
if (m_machine->is_data_locked() && m_do_unlock)
{
Expand Down Expand Up @@ -309,8 +307,5 @@ float64_t CCrossValidation::evaluate_one_run()
float64_t mean=CStatistics::mean(
SGVector <float64_t> (results, num_subsets));

/* clean up */
SG_FREE(results);

return mean;
}
12 changes: 5 additions & 7 deletions src/shogun/modelselection/ModelSelectionParameters.cpp
Expand Up @@ -139,8 +139,8 @@ void CModelSelectionParameters::build_values(EMSParamType value_type, void* min,
*((float64_t*)step),
*((float64_t*)type_base));

m_values.vector=(char*)values.vector;
m_values.vlen=values.vlen;
m_values = SGVector<char>((char*) values.vector, values.vlen);

}
else if (value_type==MSPT_INT32)
{
Expand All @@ -150,9 +150,7 @@ void CModelSelectionParameters::build_values(EMSParamType value_type, void* min,
type,
*((int32_t*)step),
*((int32_t*)type_base));

m_values.vector=(char*)values.vector;
m_values.vlen=values.vlen;
m_values = SGVector<char>((char*) values.vector, values.vlen);
}
else if (value_type==MSPT_NONE)
{
Expand Down Expand Up @@ -458,10 +456,10 @@ void CModelSelectionParameters::delete_values()
switch (m_value_type)
{
case MSPT_FLOAT64:
SG_FREE((float64_t*) m_values.vector);
m_values.unref();
break;
case MSPT_INT32:
SG_FREE((int32_t*) m_values.vector);
m_values.unref();
break;
case MSPT_NONE:
SG_ERROR("Value node has no type!\n");
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/modelselection/ModelSelectionParameters.h
Expand Up @@ -172,7 +172,7 @@ template <class T> SGVector<T> create_range_array(T min, T max,

/* create value vector */
index_t num_values=CMath::round(max-min)/step+1;
SGVector<T> result(num_values);
SGVector<T> result(num_values, false);

/* fill array */
for (index_t i=0; i<num_values; ++i)
Expand Down

0 comments on commit f46645d

Please sign in to comment.