summaryrefslogtreecommitdiffstats
path: root/src/H5Zscaleoffset.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-23 20:40:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-23 20:40:14 (GMT)
commite40557304fcfc662bb1a445abca516ee4b246d94 (patch)
treec9f1692443a62e0c481c7c0278e39d7b83d1b419 /src/H5Zscaleoffset.c
parent1062b4f9d7080a3e439df7d3d527aee43f96d085 (diff)
downloadhdf5-e40557304fcfc662bb1a445abca516ee4b246d94.zip
hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.gz
hdf5-e40557304fcfc662bb1a445abca516ee4b246d94.tar.bz2
[svn-r12803] Description:
Finish new version of the I/O pipeline message, which is much smaller than the previous version. This version is used with the "use the latest version of the format" flag. Closed several memory leaks/overruns (found with valgrind). Also, lots of compiler & formatting cleanups. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Zscaleoffset.c')
-rw-r--r--src/H5Zscaleoffset.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c
index 20f0c6e..fe82e9c 100644
--- a/src/H5Zscaleoffset.c
+++ b/src/H5Zscaleoffset.c
@@ -45,7 +45,7 @@ static herr_t H5Z_scaleoffset_set_parms_fillval(hid_t dcpl_id, hid_t type_id,
static herr_t H5Z_set_local_scaleoffset(hid_t dcpl_id, hid_t type_id, hid_t space_id);
static size_t H5Z_filter_scaleoffset(unsigned flags, size_t cd_nelmts,
const unsigned cd_values[], size_t nbytes, size_t *buf_size, void **buf);
-static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size);
+static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size);
static unsigned H5Z_scaleoffset_log2(unsigned long_long num);
static void H5Z_scaleoffset_precompress_i(void *data, unsigned d_nelmts,
enum H5Z_scaleoffset_type type, unsigned filavail, const void *filval_buf,
@@ -632,7 +632,7 @@ done:
static enum H5Z_scaleoffset_type
H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign)
{
- enum H5Z_scaleoffset_type type; /* integer type */
+ enum H5Z_scaleoffset_type type = t_bad; /* integer type */
enum H5Z_scaleoffset_type ret_value; /* return value */
FUNC_ENTER_NOAPI_NOINIT(H5Z_scaleoffset_get_type)
@@ -1182,21 +1182,22 @@ done:
/* change byte order of input buffer either from little-endian to big-endian
* or from big-endian to little-endian 2/21/2005
*/
-static void H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, unsigned dtype_size)
+static void
+H5Z_scaleoffset_convert(void *buf, unsigned d_nelmts, size_t dtype_size)
{
- unsigned i, j;
- unsigned char *buffer, temp;
-
- if(dtype_size == 1) return;
-
- buffer = buf;
- for(i = 0; i < d_nelmts * dtype_size; i += dtype_size)
- for(j = 0; j < dtype_size/2; j++) {
- /* swap pair of bytes */
- temp = buffer[i+j];
- buffer[i+j] = buffer[i+dtype_size-1-j];
- buffer[i+dtype_size-1-j] = temp;
- }
+ if(dtype_size > 1) {
+ unsigned i, j;
+ unsigned char *buffer, temp;
+
+ buffer = buf;
+ for(i = 0; i < d_nelmts * dtype_size; i += dtype_size)
+ for(j = 0; j < dtype_size/2; j++) {
+ /* swap pair of bytes */
+ temp = buffer[i+j];
+ buffer[i+j] = buffer[i+dtype_size-1-j];
+ buffer[i+dtype_size-1-j] = temp;
+ }
+ } /* end if */
}
/* Round a floating-point value to the nearest integer value 4/19/05 */