fixed a critical bug where data size was not calculated correctly and

column directory is now closed when column is closed
This commit is contained in:
Celine Mercier
2015-10-09 10:25:40 +02:00
parent ebc9f6f512
commit e114a3c9cb

View File

@ -907,8 +907,9 @@ OBIDMS_column_p obi_open_column(OBIDMS_p dms,
// TODO Check endianness?
// Compute data size from the informations in the header
data_size = ((column->header)->line_count) * sizeof((column->header)->data_type);
data_size = obi_array_sizeof((column->header)->data_type, (column->header)->line_count, (column->header)->nb_elements_per_line);
// Map the data
column->data = mmap(NULL,
data_size,
PROT_READ,
@ -1009,7 +1010,7 @@ int obi_close_column(OBIDMS_column_p column)
size_t data_size;
// Munmap data
data_size = (column->header)->line_count * (column->header)->nb_elements_per_line * sizeof((column->header)->data_type);
data_size = obi_array_sizeof((column->header)->data_type, (column->header)->line_count, (column->header)->nb_elements_per_line);
if (munmap(column->data, data_size) < 0)
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
@ -1025,6 +1026,8 @@ int obi_close_column(OBIDMS_column_p column)
return -1;
}
obi_close_column_directory(column->column_directory);
free(column);
return 0;