summaryrefslogtreecommitdiffstats
path: root/src/H5Zdeflate.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-08-20 22:22:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-08-20 22:22:40 (GMT)
commit0b00c26b027b2d2afd3112d24573ceb767fc8376 (patch)
tree6dfeabd5453da487c6e6473bd24c82895b4496b5 /src/H5Zdeflate.c
parent2d7c01d1eb8254c3b5d4977428edcf1c2523bd5e (diff)
downloadhdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.zip
hdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.tar.gz
hdf5-0b00c26b027b2d2afd3112d24573ceb767fc8376.tar.bz2
[svn-r19274] Description:
Bring r19272 & 19273 from trunk to 1.8 branch: Close out various resource leaks and usages of uninitialized memory that were flagged by valgrind. [There's still some more valgrind warnings, but it's better now... :-/ ] Also clean up warnings and code formatting. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Mac OS X/32 10.6.4 (amazon) in debug mode Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'src/H5Zdeflate.c')
-rw-r--r--src/H5Zdeflate.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c
index 63e7b9a..598aa97 100644
--- a/src/H5Zdeflate.c
+++ b/src/H5Zdeflate.c
@@ -101,9 +101,9 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Set the uncompression parameters */
HDmemset(&z_strm, 0, sizeof(z_strm));
- z_strm.next_in = *buf;
+ z_strm.next_in = (Bytef *)*buf;
H5_ASSIGN_OVERFLOW(z_strm.avail_in,nbytes,size_t,unsigned);
- z_strm.next_out = outbuf;
+ z_strm.next_out = (Bytef *)outbuf;
H5_ASSIGN_OVERFLOW(z_strm.avail_out,nalloc,size_t,unsigned);
/* Initialize the uncompression routines */
@@ -155,7 +155,7 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
/* Finish uncompressing the stream */
(void)inflateEnd(&z_strm);
- }
+ } /* end if */
else {
/*
* Output; compress but fail if the result would be larger than the
@@ -172,19 +172,20 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
H5_ASSIGN_OVERFLOW(aggression,cd_values[0],unsigned,int);
/* Allocate output (compressed) buffer */
- if (NULL==(z_dst=outbuf=H5MM_malloc(z_dst_nbytes)))
+ if(NULL == (outbuf = H5MM_malloc(z_dst_nbytes)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate deflate destination buffer")
+ z_dst = (Bytef *)outbuf;
/* Perform compression from the source to the destination buffer */
- status = compress2 (z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
+ status = compress2(z_dst, &z_dst_nbytes, z_src, z_src_nbytes, aggression);
/* Check for various zlib errors */
- if (Z_BUF_ERROR==status)
+ if(Z_BUF_ERROR == status)
HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow")
- else if (Z_MEM_ERROR==status)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error")
- else if (Z_OK!=status)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, 0, "other deflate error")
+ else if(Z_MEM_ERROR == status)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "deflate memory error")
+ else if(Z_OK != status)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "other deflate error")
/* Successfully uncompressed the buffer */
else {
/* Free the input buffer */
@@ -195,8 +196,8 @@ H5Z_filter_deflate (unsigned flags, size_t cd_nelmts,
outbuf = NULL;
*buf_size = nbytes;
ret_value = z_dst_nbytes;
- }
- }
+ } /* end else */
+ } /* end else */
done:
if(outbuf)