Navigation Menu

Skip to content

Commit

Permalink
convert example to use SGStringList<char> and modify the
Browse files Browse the repository at this point in the history
get_modsel_names function to return a zero terminated string
  • Loading branch information
Soeren Sonnenburg committed Dec 23, 2011
1 parent 901e739 commit c1ce1b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -25,16 +25,16 @@ void print_message(FILE* target, const char* str)

void print_modsel_parameters(CSGObject* object)
{
SGVector<char*> modsel_params=object->get_modelsel_names();
SGStringList<char> modsel_params=object->get_modelsel_names();

SG_SPRINT("Parameters of %s available for model selection:\n",
object->get_name());

char* type_string=SG_MALLOC(char, 100);
for (index_t i=0; i<modsel_params.vlen; ++i)
for (index_t i=0; i<modsel_params.num_strings; ++i)
{
/* extract current name, ddescription and type, and print them */
const char* name=modsel_params.vector[i];
const char* name=modsel_params.strings[i].string;
index_t index=object->get_modsel_param_index(name);
TSGDataType type=object->m_model_selection_parameters->get_parameter(
index)->m_datatype;
Expand All @@ -44,7 +44,7 @@ void print_modsel_parameters(CSGObject* object)
}
SG_FREE(type_string);

modsel_params.destroy_vector();
modsel_params.destroy_list();
SG_SPRINT("\n");
}

Expand Down
3 changes: 2 additions & 1 deletion src/shogun/base/SGObject.cpp
Expand Up @@ -480,7 +480,8 @@ SGStringList<char> CSGObject::get_modelsel_names()
{
char* name=m_model_selection_parameters->get_parameter(i)->m_name;
index_t len=strlen(name);
result.strings[i]=SGString<char>(name, len);
// +1 to have a zero terminated string
result.strings[i]=SGString<char>(name, len+1);

if (len>max_string_length)
max_string_length=len;
Expand Down

0 comments on commit c1ce1b0

Please sign in to comment.