diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2011-02-08 15:55:31 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2011-02-08 15:55:31 (GMT) |
commit | f3ee1cc38d0604116afbffe72cd98dabfe1014a7 (patch) | |
tree | b7b11d751b526c91b0e0695d34c66991b80d74b3 /src/H5Znbit.c | |
parent | e1cd1485b8bb78b4a99ca4246c522bbaf3c0ed76 (diff) | |
parent | a6d5fa2c7db165fa2cecee86bdbd201339349968 (diff) | |
download | hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.zip hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.gz hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.bz2 |
[svn-r20063] Merge changes from trunk from revision 19519 to 20062 into open_file_pool branch. No testing needed as the branch is currently identical to the trunk.
Diffstat (limited to 'src/H5Znbit.c')
-rw-r--r-- | src/H5Znbit.c | 18 |
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 */ |