From 43f3c69a40edb972e63de95b314d88ea3f6ed261 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Wed, 21 Sep 2016 17:50:21 +0200 Subject: [PATCH] Fixed bug when cloning column with line selection --- src/obidmscolumn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/obidmscolumn.c b/src/obidmscolumn.c index dfedaaf..3f00fc9 100644 --- a/src/obidmscolumn.c +++ b/src/obidmscolumn.c @@ -1057,7 +1057,7 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms, { line_size = obi_sizeof((new_column->header)->stored_data_type) * (new_column->header)->nb_elements_per_line; // Copy each line at the right index to the new column - for (i=0; iheader)->lines_used); i++) { // Get the index in the line selection column index = obi_column_get_index(line_selection, i); @@ -1135,6 +1135,14 @@ int obi_truncate_column(OBIDMS_column_p column) // TODO is it necessary to unmap int column_file_descriptor; char* column_file_name; + // Check if the column is read-only + if (!(column->writable)) + { + obi_set_errno(OBICOL_UNKNOWN_ERROR); + obidebug(1, "\nError trying to truncate a read-only column"); + return -1; + } + // Compute the new line count = the number of lines used rounded to the nearest greater multiple of page size greater than 0 multiple = ceil((double) (ONE_IF_ZERO((column->header)->lines_used) * (column->header)->nb_elements_per_line * obi_sizeof((column->header)->stored_data_type)) / (double) getpagesize()); new_line_count = floor((((int) multiple) * getpagesize()) / ((column->header)->nb_elements_per_line * obi_sizeof((column->header)->stored_data_type)));