diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-06 03:24:42 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-06 03:24:42 (GMT) |
commit | ff845ed8b156097fd8574be4809f11dbc684e042 (patch) | |
tree | f564359ab09ae660be620733d4144f6b78ac7ce5 /tools/h5repack | |
parent | 299ac26d98a27cb309c87eafeb0ff7ac53eeb94b (diff) | |
download | hdf5-ff845ed8b156097fd8574be4809f11dbc684e042.zip hdf5-ff845ed8b156097fd8574be4809f11dbc684e042.tar.gz hdf5-ff845ed8b156097fd8574be4809f11dbc684e042.tar.bz2 |
[svn-r20052] Description:
Clean up Coverity warnings, and fix some style issues:
r19735:
Fix for memory leak in test/mf found by valgrind.
r19736:
Fix memory leak in h5repack. The buffer in copy_objects, when copying the
entire dataset at once, was not checked for the presence of a vlen, and vlen
storage was never reclaimed. Added check and call to H5D_vlen_reclaim().
r19772:
Change H5assert() to
if (H5T_VLEN != src->shared->type || H5T_VLEN != dst->shared->type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype")
r19774:
removed unused priv.
r19775:
removed unused variables
r19778:
Fix memory leak comparing for variable length data types.
r19834:
Fixed memory leaks found by valgrind. Memory errors remain for another day.
Tested on:
Mac OS X/32 10.6.6 (amazon) w/debug & production
(h5committested on branch)
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 7d2c929..f849697 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -543,23 +543,23 @@ int do_copy_objects(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in=-1; /* group ID */ - hid_t grp_out=-1; /* group ID */ - hid_t dset_in=-1; /* read dataset ID */ - hid_t dset_out=-1; /* write dataset ID */ - hid_t gcpl_in=-1; /* group creation property list */ - hid_t gcpl_out=-1; /* group creation property list */ - hid_t type_in=-1; /* named type ID */ - hid_t type_out=-1; /* named type ID */ - hid_t dcpl_id=-1; /* dataset creation property list ID */ - hid_t dcpl_out=-1; /* dataset creation property list ID */ - hid_t f_space_id=-1; /* file space ID */ - hid_t ftype_id=-1; /* file type ID */ - hid_t wtype_id=-1; /* read/write type ID */ - named_dt_t *named_dt_head=NULL; /* Pointer to the stack of named datatypes copied */ + hid_t grp_in = -1; /* group ID */ + hid_t grp_out = -1; /* group ID */ + hid_t dset_in = -1; /* read dataset ID */ + hid_t dset_out = -1; /* write dataset ID */ + hid_t gcpl_in = -1; /* group creation property list */ + hid_t gcpl_out = -1; /* group creation property list */ + hid_t type_in = -1; /* named type ID */ + hid_t type_out = -1; /* named type ID */ + hid_t dcpl_id = -1; /* dataset creation property list ID */ + hid_t dcpl_out = -1; /* dataset creation property list ID */ + hid_t f_space_id = -1; /* file space ID */ + hid_t ftype_id = -1; /* file type ID */ + hid_t wtype_id = -1; /* read/write type ID */ + named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ size_t msize; /* size of type */ hsize_t nelmts; /* number of elements in dataset */ - H5D_space_status_t *space_status; /* determines whether space has been allocated for the dataset */ + H5D_space_status_t space_status; /* determines whether space has been allocated for the dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ hsize_t dsize_in; /* input dataset size before filter */ @@ -748,14 +748,12 @@ int do_copy_objects(hid_t fidin, if(H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) goto error; - if(H5Dget_space_status(dset_in, &space_status) <0) + if(H5Dget_space_status(dset_in, &space_status) < 0) goto error; nelmts = 1; - for ( j = 0; j < rank; j++) - { + for(j = 0; j < rank; j++) nelmts *= dims[j]; - } /* wtype_id will have already been set if using a named dtype */ if(!is_named) { @@ -839,20 +837,25 @@ int do_copy_objects(hid_t fidin, * read/write *------------------------------------------------------------------------- */ - if (nelmts>0 && space_status!=H5D_SPACE_STATUS_NOT_ALLOCATED) + if(nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) { - size_t need = (size_t)(nelmts*msize); /* bytes needed */ + size_t need = (size_t)(nelmts * msize); /* bytes needed */ /* have to read the whole dataset if there is only one element in the dataset */ - if ( need < H5TOOLS_MALLOCSIZE ) + if(need < H5TOOLS_MALLOCSIZE) buf = HDmalloc(need); - if (buf != NULL ) - { - if (H5Dread(dset_in,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) + if(buf != NULL) { + if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; - if (H5Dwrite(dset_out,wtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0) + if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; + + /* Check if we have VL data in the dataset's + * datatype that must be reclaimed */ + if(TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) + if(H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) + goto error; } else /* possibly not enough memory, read/write by hyperslabs */ { @@ -1370,7 +1373,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) } /* end while */ /* Update size of userblock left to transfer */ - size -= nread; + size = size - (hsize_t)nread; } /* end while */ done: |