summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2010-11-19 20:34:29 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2010-11-19 20:34:29 (GMT)
commit27fdd5c09cbcf32cb78816ceca4f9aabe8037cae (patch)
tree074394f73f59680ff9fce12c51bbe99e63a94591 /src
parent2f883f088135c00c8bfc24e19a89c696ee61937b (diff)
downloadhdf5-27fdd5c09cbcf32cb78816ceca4f9aabe8037cae.zip
hdf5-27fdd5c09cbcf32cb78816ceca4f9aabe8037cae.tar.gz
hdf5-27fdd5c09cbcf32cb78816ceca4f9aabe8037cae.tar.bz2
[svn-r19833] Bug fix - In the code of N-bit filter, one line (the last line of H5Znbit.c in H5Z_nbit_compress -
"*buffer_size = j + 1;" was mistakenly taken out by someone. It is necessary to update the new size. I put it back and made 2 test cases for integer and float to verify the correct dataset size. I'm bringing the fix from 1.8 branch. The changes to configure.in, tools/misc, config, Makefile.am are only property changes. Tested on jam. But I tested 1.8 on jam, heiwa, and amani.
Diffstat (limited to 'src')
-rw-r--r--src/H5Znbit.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/H5Znbit.c b/src/H5Znbit.c
index bcdd549..263b2cd 100644
--- a/src/H5Znbit.c
+++ b/src/H5Znbit.c
@@ -1365,17 +1365,17 @@ static void H5Z_nbit_compress_one_compound(unsigned char *data, size_t data_offs
static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer,
size_t *buffer_size, const unsigned parms[])
{
- /* i: index of data, j: index of buffer,
+ /* i: index of data, new_size: index of buffer,
buf_len: number of bits to be filled in current byte */
- size_t i, j, size;
+ size_t i, size;
+ size_t new_size = 0;
int buf_len;
parms_atomic p;
/* must initialize buffer to be zeros */
- for(j = 0; j < *buffer_size; j++) buffer[j] = 0;
+ HDmemset(buffer, 0, *buffer_size);
/* initialization before the loop */
- j = 0;
buf_len = sizeof(unsigned char) * 8;
switch(parms[3]) {
@@ -1387,14 +1387,14 @@ static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned c
p.offset = parms[7];
for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_atomic(data, i*p.size, buffer, &j, &buf_len, p);
+ H5Z_nbit_compress_one_atomic(data, i*p.size, buffer, &new_size, &buf_len, p);
}
break;
case H5Z_NBIT_ARRAY:
size = parms[4];
parms_index = 4;
for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_array(data, i*size, buffer, &j, &buf_len, parms);
+ H5Z_nbit_compress_one_array(data, i*size, buffer, &new_size, &buf_len, parms);
parms_index = 4;
}
break;
@@ -1402,10 +1402,14 @@ static void H5Z_nbit_compress(unsigned char *data, unsigned d_nelmts, unsigned c
size = parms[4];
parms_index = 4;
for(i = 0; i < d_nelmts; i++) {
- H5Z_nbit_compress_one_compound(data, i*size, buffer, &j, &buf_len, parms);
+ H5Z_nbit_compress_one_compound(data, i*size, buffer, &new_size, &buf_len, parms);
parms_index = 4;
}
break;
} /* end switch */
+
+ /* Update the size to the new value after compression. If there are any bits hanging over in
+ * the last byte, increment the value by 1. */
+ *buffer_size = new_size + 1;
}
#endif /* H5_HAVE_FILTER_NBIT */