summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-04-30 06:10:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-04-30 06:10:38 (GMT)
commitbd33a9d6da4f56884eaf5dc750186a6c02c90446 (patch)
tree2bb71d0ed2ebbb447c28e8e77ecf55ce01340d9f /src
parentf63b2c50ac95fb8363a9b8143d3a3d5f50c58d35 (diff)
downloadhdf5-bd33a9d6da4f56884eaf5dc750186a6c02c90446.zip
hdf5-bd33a9d6da4f56884eaf5dc750186a6c02c90446.tar.gz
hdf5-bd33a9d6da4f56884eaf5dc750186a6c02c90446.tar.bz2
[svn-r29842] Description:
Bring [appropriate portions of] r29811, 29813, 29826, 29830, 29831 from revise_chunks branch to the trunk. Tested on: MacOSX/64 10.11.4 (amazon) w/serial, parallel & production (h5committest forthcoming)
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c6
-rw-r--r--src/H5B2int.c1
-rw-r--r--src/H5CS.c2
-rw-r--r--src/H5E.c9
-rw-r--r--src/H5Eint.c3
-rw-r--r--src/H5F.c48
-rw-r--r--src/H5FDdirect.c7
-rw-r--r--src/H5FDlog.c6
-rw-r--r--src/H5Fint.c61
-rw-r--r--src/H5Fprivate.h6
-rw-r--r--src/H5TS.c5
11 files changed, 96 insertions, 58 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 64edc87..6a71f29 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -941,7 +941,11 @@ done:
*/
herr_t
H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
- haddr_t new_addr, hid_t dxpl_id)
+ haddr_t new_addr, hid_t
+#ifndef H5_HAVE_PARALLEL
+H5_ATTR_UNUSED
+#endif /* H5_HAVE_PARALLEL */
+ dxpl_id)
{
#if H5AC__TRACE_FILE_ENABLED
char trace[128] = "";
diff --git a/src/H5B2int.c b/src/H5B2int.c
index 8bdde3e..e877a17 100644
--- a/src/H5B2int.c
+++ b/src/H5B2int.c
@@ -82,6 +82,7 @@ static herr_t H5B2__swap_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth,
static herr_t H5B2__create_internal(H5B2_hdr_t *hdr, hid_t dxpl_id,
H5B2_node_ptr_t *node_ptr, uint16_t depth);
#ifdef H5B2_DEBUG
+/* Don't label these with H5_ATTR_PURE or you'll get even more warnings... */
static herr_t H5B2__assert_leaf(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf);
static herr_t H5B2__assert_leaf2(const H5B2_hdr_t *hdr, const H5B2_leaf_t *leaf, const H5B2_leaf_t *leaf2);
static herr_t H5B2__assert_internal(hsize_t parent_all_nrec, const H5B2_hdr_t *hdr, const H5B2_internal_t *internal);
diff --git a/src/H5CS.c b/src/H5CS.c
index f1d3a8b..477b5f9 100644
--- a/src/H5CS.c
+++ b/src/H5CS.c
@@ -192,6 +192,8 @@ H5CS_push(const char *func_name)
/* Check if we need to expand the stack of records */
if(fstack->nused == fstack->nalloc) {
size_t na = MAX((fstack->nalloc * 2), H5CS_MIN_NSLOTS);
+
+ /* Don't use H5MM_realloc here */
const char **x = (const char **)HDrealloc(fstack->rec, na * sizeof(const char *));
/* (Avoid returning an error from this routine, currently -QAK) */
diff --git a/src/H5E.c b/src/H5E.c
index efa83e4..aa4511b 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -367,8 +367,12 @@ H5E_get_stack(void)
if(!estack) {
/* No associated value with current thread - create one */
#ifdef H5_HAVE_WIN_THREADS
- estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */
+ /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */
+ estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t));
#else
+ /* Use HDmalloc here since this has to match the HDfree in the
+ * destructor and we want to avoid the codestack there.
+ */
estack = (H5E_t *)HDmalloc(sizeof(H5E_t));
#endif /* H5_HAVE_WIN_THREADS */
HDassert(estack);
@@ -1418,6 +1422,9 @@ done:
if(va_started)
va_end(ap);
#ifdef H5_HAVE_VASPRINTF
+ /* Memory was allocated with HDvasprintf so it needs to be freed
+ * with HDfree
+ */
if(tmp)
HDfree(tmp);
#else /* H5_HAVE_VASPRINTF */
diff --git a/src/H5Eint.c b/src/H5Eint.c
index 6ed405f..8eea147 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -744,6 +744,9 @@ done:
if(va_started)
va_end(ap);
#ifdef H5_HAVE_VASPRINTF
+ /* Memory was allocated with HDvasprintf so it needs to be freed
+ * with HDfree
+ */
if(tmp)
HDfree(tmp);
#else /* H5_HAVE_VASPRINTF */
diff --git a/src/H5F.c b/src/H5F.c
index bf57daf..c96c419 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -140,7 +140,7 @@ H5F_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_PKG_INIT_VAR) {
- if(H5I_nmembers(H5I_FILE) > 0) {
+ if(H5I_nmembers(H5I_FILE) > 0) {
(void)H5I_clear_type(H5I_FILE, FALSE, FALSE);
n++; /*H5I*/
} /* end if */
@@ -149,12 +149,12 @@ H5F_term_package(void)
H5F_sfile_assert_num(0);
/* Destroy the file object id group */
- n += (H5I_dec_type_ref(H5I_FILE) > 0);
+ n += (H5I_dec_type_ref(H5I_FILE) > 0);
- /* Mark closed */
+ /* Mark closed */
if(0 == n)
H5_PKG_INIT_VAR = FALSE;
- } /* end else */
+ } /* end else */
} /* end if */
FUNC_LEAVE_NOAPI(n)
@@ -188,13 +188,13 @@ H5Fget_create_plist(hid_t file_id)
/* check args */
if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Create the property list object to return */
if((ret_value = H5P_copy_plist(plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties")
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties")
done:
FUNC_LEAVE_API(ret_value)
@@ -233,7 +233,7 @@ H5Fget_access_plist(hid_t file_id)
/* Check args */
if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
/* Retrieve the file's access property list */
if((ret_value = H5F_get_access_plist(f, TRUE)) < 0)
@@ -275,7 +275,7 @@ H5Fget_obj_count(hid_t file_id, unsigned types)
/* Perform the query */
if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
/* Set the return value */
ret_value = (ssize_t)obj_count;
@@ -481,18 +481,18 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
* reading and writing.
*/
if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)))
- flags |= H5F_ACC_EXCL; /*default*/
+ flags |= H5F_ACC_EXCL; /*default*/
flags |= H5F_ACC_RDWR | H5F_ACC_CREAT;
/*
* Create a new file or truncate an existing file.
*/
if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file")
/* Get an atom for the file */
if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
/* Keep this ID in file object structure */
new_file->file_id = ret_value;
@@ -558,11 +558,11 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
/* Check/fix arguments. */
if(!filename || !*filename)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name")
/* Reject undefined flags (~H5F_ACC_PUBLIC_FLAGS) and the H5F_ACC_TRUNC & H5F_ACC_EXCL flags */
if((flags & ~H5F_ACC_PUBLIC_FLAGS) ||
(flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags")
/* Verify access property list and get correct dxpl */
if(H5P_verify_apl_and_dxpl(&fapl_id, H5P_CLS_FACC, &dxpl_id, H5I_INVALID_HID, TRUE) < 0)
@@ -570,11 +570,11 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
/* Open the file */
if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file")
/* Get an atom for the file */
if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
/* Keep this ID in file object structure */
new_file->file_id = ret_value;
@@ -673,12 +673,12 @@ H5Fflush(hid_t object_id, H5F_scope_t scope)
} /* end switch */
if(!f) {
- if(!oloc)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file")
- f = oloc->file;
+ if(!oloc)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file")
+ f = oloc->file;
} /* end if */
if(!f)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file")
/* Flush the file */
/*
@@ -740,7 +740,7 @@ H5Fclose(hid_t file_id)
/* Check/fix arguments. */
if(H5I_FILE != H5I_get_type(file_id))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID")
/* Flush file if this is the last reference to this id and we have write
* intent, unless it will be flushed by the "shared" file being closed.
@@ -761,7 +761,7 @@ H5Fclose(hid_t file_id)
* be closed.
*/
if(H5I_dec_app_ref(file_id) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1178,7 +1178,7 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr,
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.")
if(cur_num_entries_ptr != NULL)
- *cur_num_entries_ptr = (int)cur_num_entries;
+ *cur_num_entries_ptr = (int)cur_num_entries;
done:
FUNC_LEAVE_API(ret_value)
@@ -1345,11 +1345,11 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo)
/* Get the size of the superblock and any superblock extensions */
if(H5F__super_size(f, H5AC_ind_read_dxpl_id, &finfo->super.super_size, &finfo->super.super_ext_size) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock sizes")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock sizes")
/* Get the size of any persistent free space */
if(H5MF_get_freespace(f, H5AC_ind_read_dxpl_id, &finfo->free.tot_space, &finfo->free.meta_size) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve free space information")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve free space information")
/* Check for SOHM info */
if(H5F_addr_defined(f->shared->sohm_addr))
diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c
index f88fb1e..2034ba0 100644
--- a/src/H5FDdirect.c
+++ b/src/H5FDdirect.c
@@ -526,6 +526,9 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd
* is to handle correctly the case that the file is in a different file system
* than the one where the program is running.
*/
+ /* NOTE: Use HDmalloc and HDfree here to ensure compatibility with
+ * HDposix_memalign.
+ */
buf1 = (int *)HDmalloc(sizeof(int));
if(HDposix_memalign(&buf2, file->fa.mboundary, file->fa.fbsize) != 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "HDposix_memalign failed")
@@ -992,6 +995,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
addr = (haddr_t)(((addr + size - 1) / _fbsize + 1) * _fbsize);
if(copy_buf) {
+ /* Free with HDfree since it came from posix_memalign */
HDfree(copy_buf);
copy_buf = NULL;
} /* end if */
@@ -1003,6 +1007,7 @@ H5FD_direct_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UN
done:
if(ret_value<0) {
+ /* Free with HDfree since it came from posix_memalign */
if(copy_buf)
HDfree(copy_buf);
@@ -1223,6 +1228,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U
buf = (const char*)buf + size;
if(copy_buf) {
+ /* Free with HDfree since it came from posix_memalign */
HDfree(copy_buf);
copy_buf = NULL;
} /* end if */
@@ -1236,6 +1242,7 @@ H5FD_direct_write(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_U
done:
if(ret_value<0) {
+ /* Free with HDfree since it came from posix_memalign */
if(copy_buf)
HDfree(copy_buf);
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 4bb72ce..d0c4647 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -416,7 +416,7 @@ done:
if(NULL == ret_value)
if(new_fa) {
if(new_fa->logfile)
- new_fa->logfile = H5MM_xfree(new_fa->logfile);
+ new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile);
H5MM_free(new_fa);
} /* end if */
@@ -445,7 +445,7 @@ H5FD_log_fapl_free(void *_fa)
/* Free the fapl information */
if(fa->logfile)
- fa->logfile = H5MM_xfree(fa->logfile);
+ fa->logfile = (char *)H5MM_xfree(fa->logfile);
H5MM_xfree(fa);
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -799,7 +799,7 @@ H5FD_log_close(H5FD_t *_file)
} /* end if */
if(file->fa.logfile)
- file->fa.logfile = H5MM_xfree(file->fa.logfile);
+ file->fa.logfile = (char *)H5MM_xfree(file->fa.logfile);
/* Release the file info */
file = H5FL_FREE(H5FD_log_t, file);
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 4da382b..f4e6550 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -568,12 +568,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
FUNC_ENTER_NOAPI_NOINIT
if(NULL == (f = H5FL_CALLOC(H5F_t)))
- HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
f->file_id = -1;
if(shared) {
HDassert(lf == NULL);
- f->shared = shared;
+ f->shared = shared;
} /* end if */
else {
H5P_genplist_t *plist; /* Property list */
@@ -586,18 +586,18 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
f->shared->flags = flags;
- f->shared->sohm_addr = HADDR_UNDEF;
- f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION;
+ f->shared->sohm_addr = HADDR_UNDEF;
+ f->shared->sohm_vers = HDF5_SHAREDHEADER_VERSION;
for(u = 0; u < NELMTS(f->shared->fs_addr); u++)
f->shared->fs_addr[u] = HADDR_UNDEF;
- f->shared->accum.loc = HADDR_UNDEF;
+ f->shared->accum.loc = HADDR_UNDEF;
f->shared->lf = lf;
- /*
- * Copy the file creation and file access property lists into the
- * new file handle. We do this early because some values might need
- * to change as the file is being opened.
- */
+ /*
+ * Copy the file creation and file access property lists into the
+ * new file handle. We do this early because some values might need
+ * to change as the file is being opened.
+ */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list")
f->shared->fcpl_id = H5P_copy_plist(plist, FALSE);
@@ -636,9 +636,9 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size")
if(H5P_get(plist, H5F_ACS_LATEST_FORMAT_NAME, &latest_format) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'latest format' flag")
- /* For latest format, activate all latest version support */
- if(latest_format)
- f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS;
+ /* For latest format, activate all latest version support */
+ if(latest_format)
+ f->shared->latest_flags |= H5F_LATEST_ALL_FLAGS;
if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get metadata cache size")
f->shared->meta_aggr.feature_flag = H5FD_FEAT_AGGREGATE_METADATA;
@@ -679,21 +679,21 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
*/
f->shared->use_tmp_space = !H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI);
- /*
- * Create a metadata cache with the specified number of elements.
- * The cache might be created with a different number of elements and
- * the access property list should be updated to reflect that.
- */
- if(H5AC_create(f, &(f->shared->mdc_initCacheCfg)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create metadata cache")
+ /*
+ * Create a metadata cache with the specified number of elements.
+ * The cache might be created with a different number of elements and
+ * the access property list should be updated to reflect that.
+ */
+ if(H5AC_create(f, &(f->shared->mdc_initCacheCfg)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create metadata cache")
/* Create the file's "open object" information */
if(H5FO_create(f) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object data structure")
/* Add new "shared" struct to list of open files */
if(H5F_sfile_add(f->shared) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to append to list of open files")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to append to list of open files")
} /* end else */
f->shared->nrefs++;
@@ -707,7 +707,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
done:
if(!ret_value && f) {
- if(!shared) {
+ if(!shared) {
/* Attempt to clean up some of the shared file structures */
if(f->shared->efc)
if(H5F_efc_destroy(f->shared->efc) < 0)
@@ -718,7 +718,7 @@ done:
f->shared = H5FL_FREE(H5F_file_t, f->shared);
} /* end if */
- f = H5FL_FREE(H5F_t, f);
+ f = H5FL_FREE(H5F_t, f);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -1544,6 +1544,10 @@ H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *na
char **actual_name/*out*/)
{
hid_t new_fapl_id = -1; /* ID for duplicated FAPL */
+#ifdef H5_HAVE_SYMLINK
+ /* This has to be declared here to avoid unfreed resources on errors */
+ char *realname = NULL; /* Fully resolved path name of file */
+#endif /* H5_HAVE_SYMLINK */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1575,9 +1579,12 @@ H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *na
int *fd; /* POSIX I/O file descriptor */
h5_stat_t st; /* Stat info from stat() call */
h5_stat_t fst; /* Stat info from fstat() call */
- char realname[PATH_MAX]; /* Fully resolved path name of file */
hbool_t want_posix_fd; /* Flag for retrieving file descriptor from VFD */
+ /* Allocate realname buffer */
+ if(NULL == (realname = (char *)H5MM_calloc((size_t)PATH_MAX * sizeof(char))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
/* Perform a sanity check that the file or link wasn't switched
* between when we opened it and when we called lstat(). This is
* according to the security best practices for lstat() documented
@@ -1634,6 +1641,10 @@ done:
if(new_fapl_id > 0)
if(H5I_dec_app_ref(new_fapl_id) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close duplicated FAPL")
+#ifdef H5_HAVE_SYMLINK
+ if(realname)
+ realname = (char *)H5MM_xfree(realname);
+#endif /* H5_HAVE_SYMLINK */
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F_build_actual_name() */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 3a92538..05c70d1 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -508,7 +508,7 @@
/* Size of signature information (on disk) */
/* (all on-disk signatures should be this length) */
-#define H5_SIZEOF_MAGIC 4
+#define H5_SIZEOF_MAGIC 4
/* v1 B-tree node signature */
#define H5B_MAGIC "TREE"
@@ -563,9 +563,9 @@
#define H5F_LATEST_FILL_MSG 0x0008
#define H5F_LATEST_PLINE_MSG 0x0010
#define H5F_LATEST_LAYOUT_MSG 0x0020
-#define H5F_LATEST_NO_MOD_TIME_MSG 0x0040
+#define H5F_LATEST_NO_MOD_TIME_MSG 0x0040
#define H5F_LATEST_STYLE_GROUP 0x0080
-#define H5F_LATEST_OBJ_HEADER 0x0100
+#define H5F_LATEST_OBJ_HEADER 0x0100
#define H5F_LATEST_SUPERBLOCK 0x0200
#define H5F_LATEST_ALL_FLAGS (H5F_LATEST_DATATYPE | H5F_LATEST_DATASPACE | H5F_LATEST_ATTRIBUTE | H5F_LATEST_FILL_MSG | H5F_LATEST_PLINE_MSG | H5F_LATEST_LAYOUT_MSG | H5F_LATEST_NO_MOD_TIME_MSG | H5F_LATEST_STYLE_GROUP | H5F_LATEST_OBJ_HEADER | H5F_LATEST_SUPERBLOCK)
diff --git a/src/H5TS.c b/src/H5TS.c
index 6a64a14..7d46e95 100644
--- a/src/H5TS.c
+++ b/src/H5TS.c
@@ -256,7 +256,10 @@ H5TS_cancel_count_inc(void)
if (!cancel_counter) {
/*
* First time thread calls library - create new counter and associate
- * with key
+ * with key.
+ *
+ * Don't use H5MM calls here since the destructor has to use HDfree in
+ * order to avoid codestack calls.
*/
cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t));