The score tables stores in one of its columns a pointer to
a row in the audio file table. This means for each admissible
file we're allocating space for a void* pointer to store the
aft pointer.
It's simpler and probably faster to store the afs pointer directly,
but of course that pointer must not be freed by the osl.
static struct osl_column_description score_cols[] = {
[SCORECOL_AFT_ROW] = {
.storage_type = OSL_NO_STORAGE,
static struct osl_column_description score_cols[] = {
[SCORECOL_AFT_ROW] = {
.storage_type = OSL_NO_STORAGE,
- .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE | OSL_UNIQUE,
+ .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE | OSL_UNIQUE | OSL_DONT_FREE,
.name = "aft_row",
.compare_function = ptr_compare,
.data_size = sizeof(void *)
.name = "aft_row",
.compare_function = ptr_compare,
.data_size = sizeof(void *)
assert(aft_row);
size = score_table_desc.column_descriptions[SCORECOL_AFT_ROW].data_size;
assert(aft_row);
size = score_table_desc.column_descriptions[SCORECOL_AFT_ROW].data_size;
- score_objs[SCORECOL_AFT_ROW].data = para_malloc(size);
+ score_objs[SCORECOL_AFT_ROW].data = aft_row;
score_objs[SCORECOL_AFT_ROW].size = size;
score_objs[SCORECOL_AFT_ROW].size = size;
- *(const void **)(score_objs[SCORECOL_AFT_ROW].data) = aft_row;
size = score_table_desc.column_descriptions[SCORECOL_SCORE].data_size;
score_objs[SCORECOL_SCORE].data = para_malloc(size);
size = score_table_desc.column_descriptions[SCORECOL_SCORE].data_size;
score_objs[SCORECOL_SCORE].data = para_malloc(size);
ret = osl_add_row(score_table, score_objs);
if (ret < 0) {
PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
ret = osl_add_row(score_table, score_objs);
if (ret < 0) {
PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
- free(score_objs[SCORECOL_AFT_ROW].data);
free(score_objs[SCORECOL_SCORE].data);
}
return ret;
free(score_objs[SCORECOL_SCORE].data);
}
return ret;
struct osl_row *row;
long new_score;
unsigned n, new_pos;
struct osl_row *row;
long new_score;
unsigned n, new_pos;
- struct osl_object obj = {.data = &aft_row, .size = sizeof(void **)};
+ struct osl_object obj = {.data = aft_row, .size = sizeof(aft_row)};
int ret = osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, &row);
if (ret < 0)
int ret = osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, &row);
if (ret < 0)
ret = osl_get_object(score_table, score_row, SCORECOL_AFT_ROW, &obj);
if (ret < 0)
return ret;
ret = osl_get_object(score_table, score_row, SCORECOL_AFT_ROW, &obj);
if (ret < 0)
return ret;
- *aft_row = *(void **)obj.data;
return 1;
}
static int get_score_row_from_aft_row(const struct osl_row *aft_row,
struct osl_row **score_row)
{
return 1;
}
static int get_score_row_from_aft_row(const struct osl_row *aft_row,
struct osl_row **score_row)
{
- struct osl_object obj = {.data = &aft_row, .size = sizeof(void **)};
+ struct osl_object obj = {.data = aft_row, .size = sizeof(aft_row)};
return osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, score_row);
}
return osl_get_row(score_table, SCORECOL_AFT_ROW, &obj, score_row);
}
ret = osl_get_object(score_table, row, SCORECOL_AFT_ROW, &obj);
if (ret < 0)
return ret;
ret = osl_get_object(score_table, row, SCORECOL_AFT_ROW, &obj);
if (ret < 0)
return ret;
- *aft_row = *(void **)obj.data;
return get_score_of_row(row, score);
}
return get_score_of_row(row, score);
}