From f60170dac7c491cc75120a6ebdfe73c13c0bab1d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 1 Jan 2016 01:28:04 -0500 Subject: [svn-r28761] Description: Clean up many mismatches between malloc/free and H5MM_malloc/H5MM_xfree in the library and tests (and use of H5free_memory and H5Dvlen_reclaim). Also make H5Ocopy use a private version of H5Lexists, which doesn't internally throw (and suppress) errors when an object (or the path to it) isn't found in the destination. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- fortran/src/H5Pf.c | 2 +- src/H5.c | 5 +- src/H5L.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/H5Lprivate.h | 2 + src/H5Ocopy.c | 24 ++----- src/H5TS.c | 17 +++-- src/H5Tvlen.c | 8 +-- src/H5Ztrans.c | 4 +- test/dtypes.c | 99 +++++++++++++++++++++++++--- test/fheap.c | 10 +-- test/file_image.c | 4 +- test/links.c | 57 ++++++++++------ test/objcopy.c | 150 ++++++++++++++++++++++++++++++++++++------ test/tgenprop.c | 4 +- test/tmisc.c | 16 ++++- test/tvlstr.c | 11 ++-- tools/h5ls/h5ls.c | 5 +- 17 files changed, 482 insertions(+), 122 deletions(-) diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 523ed0b..3989512 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -5273,7 +5273,7 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) *buf_len_ptr=(size_t_f)c_buf_len_ptr; ret_value = 0; - if(c_buf_ptr) HDfree(c_buf_ptr); + if(c_buf_ptr) H5free_memory(c_buf_ptr); return ret_value; } diff --git a/src/H5.c b/src/H5.c index 33ac340..2086ce8 100644 --- a/src/H5.c +++ b/src/H5.c @@ -942,7 +942,6 @@ H5allocate_memory(size_t size, hbool_t clear) ret_value = H5MM_malloc(size); FUNC_LEAVE_API(ret_value) - } /* end H5allocate_memory() */ @@ -981,7 +980,6 @@ H5resize_memory(void *mem, size_t size) ret_value = H5MM_realloc(mem, size); FUNC_LEAVE_API(ret_value) - } /* end H5resize_memory() */ @@ -1004,10 +1002,9 @@ H5free_memory(void *mem) H5TRACE1("e", "*x", mem); /* At this time, it is impossible for this to fail. */ - HDfree(mem); + H5MM_xfree(mem); FUNC_LEAVE_API(SUCCEED) - } /* end H5free_memory() */ diff --git a/src/H5L.c b/src/H5L.c index a1f3b6e..9daf948 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -93,6 +93,17 @@ typedef struct { hid_t dxpl_id; /* Dataset transfer property list */ } H5L_trav_mv2_t; +/* User data for path traversal routine for checking if a link exists */ +typedef struct { + /* Down */ + char *sep; /* Pointer to next separator in the string */ + hid_t lapl_id; /* Link access property list */ + hid_t dxpl_id; /* Dataset transfer property list */ + + /* Up */ + hbool_t exists; /* Whether the link exists or not */ +} H5L_trav_le_t; + /* User data for path traversal routine for getting link value */ typedef struct { size_t size; /* Size of user buffer */ @@ -170,10 +181,13 @@ static herr_t H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, static herr_t H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L_exists_cb(H5G_loc_t *grp_loc/*in*/, const char *name, +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, +static htri_t H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, @@ -827,7 +841,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Check for the existence of the link */ - if((ret_value = H5L_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5L__exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: @@ -2716,9 +2730,10 @@ done: /*------------------------------------------------------------------------- - * Function: H5L_exists_cb + * Function: H5L__exists_final_cb * - * Purpose: Callback for checking whether a link exists + * Purpose: Callback for checking whether a link exists, as the final + * component of a path * * Return: Non-negative on success/Negative on failure * @@ -2728,30 +2743,162 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { - hbool_t *udata = (hbool_t *)_udata; /* User data passed in */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check if the name in this group resolved to a valid link */ - *udata = (hbool_t)(lnk != NULL); + udata->exists = (hbool_t)(lnk != NULL); /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5L_exists_cb() */ +} /* end H5L__exists_final_cb() */ /*------------------------------------------------------------------------- - * Function: H5L_exists + * Function: H5L__exists_inter_cb + * + * Purpose: Callback for checking whether a link exists, as an intermediate + * component of a path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/) +{ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if(lnk != NULL) { + /* Check for more components to the path */ + if(udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *next; /* Pointer to next component name */ + + /* Look for another separator */ + next = udata->sep; + if(NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata->sep = '\0'; + udata->sep++; + } while('/' == *udata->sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + if(H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata, udata->lapl_id, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + } /* end if */ + else + udata->exists = TRUE; + } /* end if */ + else + udata->exists = FALSE; + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__exists_inter_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5L_exists_tolerant * * Purpose: Returns whether a link exists in a group * + * Note: Same as H5L_exists, except that missing links are reported + * as 'FALSE' instead of causing failures + * + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +htri_t +H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +{ + H5L_trav_le_t udata; /* User data for traversal */ + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *name_copy = NULL; /* Duplicate of name */ + char *name_trav; /* Name to traverse */ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(loc); + HDassert(name); + + /* Copy the name and skip leading '/'s */ + name_trav = name_copy = H5MM_strdup(name); + while('/' == *name_trav) + name_trav++; + + /* A path of "/" will always exist in a file */ + if('\0' == *name_trav) + HGOTO_DONE(TRUE) + + /* Set up user data & correct callback */ + udata.lapl_id = lapl_id; + udata.dxpl_id = dxpl_id; + udata.exists = FALSE; + if(NULL == (udata.sep = HDstrchr(name_trav, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata.sep = '\0'; + udata.sep++; + } while('/' == *udata.sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + + /* Traverse the group hierarchy to locate the link to check */ + if(H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + + /* Set return value */ + ret_value = (htri_t)udata.exists; + +done: + /* Release duplicated string */ + H5MM_xfree(name_copy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_exists_tolerant() */ + + +/*------------------------------------------------------------------------- + * Function: H5L__exists + * + * Purpose: Returns whether a link exists in a group + * + * Note: Same as H5L_exists_tolerant, except that missing links are reported + * as failures + * * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * * Programmer: Quincey Koziol @@ -2760,23 +2907,28 @@ H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static htri_t -H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - hbool_t exists = FALSE; /* Whether the link exists in the group */ + H5L_trav_le_t udata; /* User data for traversal */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + + /* A path of "/" will always exist in a file */ + if(0 == HDstrcmp(name, "/")) + HGOTO_DONE(TRUE) /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_exists_cb, &exists, lapl_id, dxpl_id) < 0) + udata.exists = FALSE; + if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ - ret_value = (htri_t)exists; + ret_value = (htri_t)udata.exists; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_exists() */ +} /* H5L__exists() */ /*------------------------------------------------------------------------- diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index f3079bc..1c8690b 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -81,6 +81,8 @@ H5_DLL hid_t H5L_get_default_lcpl(void); H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id); +H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, + hid_t dxpl_id); H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 02c72e7..6f42a88 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -213,10 +213,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* for opening the destination object */ H5G_name_t src_path; /* Opened source object hier. path */ H5O_loc_t src_oloc; /* Opened source object object location */ + htri_t dst_exists; /* Does destination name exist already? */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hbool_t obj_open = FALSE; /* Entry at 'name' found */ - - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, @@ -233,22 +233,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") /* check if destination name already exists */ - { - H5G_name_t tmp_path; - H5O_loc_t tmp_oloc; - H5G_loc_t tmp_loc; - - /* Set up group location */ - tmp_loc.oloc = &tmp_oloc; - tmp_loc.path = &tmp_path; - H5G_loc_reset(&tmp_loc); - - /* Check if object already exists in destination */ - if(H5G_loc_find(&dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_ind_dxpl_id) >= 0) { - H5G_name_free(&tmp_path); - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "destination object already exists") - } /* end if */ - } + if((dst_exists = H5L_exists_tolerant(&dst_loc, dst_name, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") + if(TRUE == dst_exists) + HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") /* Set up opened group location to fill in */ src_loc.oloc = &src_oloc; diff --git a/src/H5TS.c b/src/H5TS.c index 987bead..6a64a14 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -255,19 +255,18 @@ H5TS_cancel_count_inc(void) if (!cancel_counter) { /* - * First time thread calls library - create new counter and associate + * First time thread calls library - create new counter and associate * with key */ - cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); - if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", - __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); - return FAIL; - } + if (!cancel_counter) { + H5E_push_stack(NULL, "H5TS_cancel_count_inc", __FILE__, __LINE__, + H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); + return FAIL; + } - ret_value = pthread_setspecific(H5TS_cancel_key_g, - (void *)cancel_counter); + ret_value = pthread_setspecific(H5TS_cancel_key_g, (void *)cancel_counter); } if (cancel_counter->cancel_count == 0) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 2abdf6f..0ed8209 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -465,7 +465,7 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(vl.p=H5MM_malloc(len))) + if(NULL == (vl.p = HDmalloc(len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -691,7 +691,7 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(t = (char *)H5MM_malloc((seq_len+1)*base_size))) + if(NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -1073,14 +1073,14 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi if(free_func != NULL) (*free_func)(vl->p, free_info); else - H5MM_xfree(vl->p); + HDfree(vl->p); } /* end if */ } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ if(free_func != NULL) (*free_func)(*(char **)elem, free_info); else - H5MM_xfree(*(char **)elem); + HDfree(*(char **)elem); } else { HDassert(0 && "Invalid VL type"); } /* end else */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 0a9a4da..2627a29 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -1032,7 +1032,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size /* Free the temporary arrays we used */ if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i=0; idat_val_pointers->num_ptrs; i++) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end else */ done: @@ -1042,7 +1042,7 @@ done: if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) if(data_xform_prop->dat_val_pointers->ptr_dat_val[i]) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/test/dtypes.c b/test/dtypes.c index 326294f..984b6c6 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1789,6 +1789,13 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(H5Dclose(dset_id) < 0) goto error; if(H5Tclose(cmpd_tid) < 0) @@ -1815,6 +1822,12 @@ test_compound_9(void) goto error; } /* end if */ + if((space_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); AT(); + printf("Can't get space\n"); + goto error; + } /* end if */ + if((cmpd_tid = H5Dget_type(dset_id)) < 0) { H5_FAILED(); AT(); printf("cannot open dataset\n"); @@ -1842,10 +1855,19 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(rdata.str) HDfree(rdata.str); if(H5Dclose(dset_id) < 0) goto error; + if(H5Sclose(space_id) < 0) + goto error; if(H5Tclose(cmpd_tid) < 0) goto error; if(H5Tclose(dup_tid) < 0) @@ -2020,12 +2042,17 @@ test_compound_10(void) printf("incorrect VL read data\n"); goto error; } - - HDfree(t1); - HDfree(t2); - HDfree(wdata[i].str); - HDfree(rdata[i].str); } /* end for */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &wdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ if(H5Dclose(dset_id) < 0) goto error; @@ -2090,6 +2117,8 @@ test_compound_11(void) hid_t big_tid, little_tid; /* Datatype IDs for type conversion */ hid_t big_tid2, little_tid2; /* Datatype IDs for type conversion */ hid_t opaq_src_tid, opaq_dst_tid; /* Datatype IDs for type conversion */ + hid_t space_id; /* Dataspace for buffer elements */ + hsize_t dim[1]; /* Dimensions for dataspace */ void *buf = NULL; /* Conversion buffer */ void *buf_orig = NULL; /* Copy of original conversion buffer */ void *bkg = NULL; /* Background buffer */ @@ -2138,6 +2167,13 @@ test_compound_11(void) /* Make copy of buffer before conversion */ HDmemcpy(buf_orig,buf,sizeof(big_t)*NTESTELEM); + dim[0] = NTESTELEM; + if((space_id = H5Screate_simple(1, dim, NULL)) < 0) { + H5_FAILED(); AT(); + printf("Can't create space\n"); + goto error; + } /* end if */ + /* Make copies of the 'big' and 'little' datatypes, so the type * conversion routine doesn't use the same ones this time and next time */ @@ -2169,8 +2205,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid2, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Build source and destination types for conversion routine */ if((opaq_src_tid=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) TEST_ERROR @@ -2209,8 +2249,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Unregister the conversion routine */ if(H5Tunregister(H5T_PERS_HARD, "opaq_test", opaq_src_tid, opaq_dst_tid, convert_opaque) < 0) TEST_ERROR @@ -2243,12 +2287,17 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Free everything */ for(u=0; udel_dir == FHEAP_DEL_FORWARD) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - forward)"); + str = H5MM_strdup("(all - forward)"); else - str = HDstrdup("(half, refill, all - forward)"); + str = H5MM_strdup("(half, refill, all - forward)"); else if(tparam->del_dir == FHEAP_DEL_REVERSE) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - reverse)"); + str = H5MM_strdup("(all - reverse)"); else - str = HDstrdup("(half, refill, all - reverse)"); + str = H5MM_strdup("(half, refill, all - reverse)"); else - str = HDstrdup("(all - deleting heap)"); + str = H5MM_strdup("(all - deleting heap)"); return(str); } /* get_del_string() */ diff --git a/test/file_image.c b/test/file_image.c index 52d0b28..6d1845f 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -156,8 +156,8 @@ error: if(H5Pclose(fapl_1) < 0) retval = 1; if(H5Pclose(fapl_2) < 0) retval = 1; HDfree(buffer); - HDfree(temp); - HDfree(temp2); + H5free_memory(temp); + H5free_memory(temp2); if(retval == 0) PASSED(); diff --git a/test/links.c b/test/links.c index 2886304..c87d2b6 100644 --- a/test/links.c +++ b/test/links.c @@ -136,7 +136,7 @@ const char *FILENAME[] = { #define H5L_DIM1 100 #define H5L_DIM2 100 -#define FILTER_FILESIZE_MAX_FRACTION 0.9F +#define FILTER_FILESIZE_MAX_FRACTION (double)0.9F /* Creation order macros */ #define CORDER_GROUP_NAME "corder_group" @@ -548,8 +548,27 @@ cklinks(hid_t fapl, hbool_t new_format) HDputs(" expected file location."); TEST_ERROR } /* end if */ + if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + H5E_BEGIN_TRY { + status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ + H5E_BEGIN_TRY { + status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ /* Symbolic link */ if(H5Oget_info_by_name(file, "grp1/soft", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -10985,6 +11004,7 @@ link_info_by_idx(hid_t fapl) char filename[NAME_BUF_SIZE];/* File name */ char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11026,9 +11046,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { @@ -11068,9 +11088,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { @@ -11110,9 +11130,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -11167,6 +11187,7 @@ link_info_by_idx_old(hid_t fapl) char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11278,9 +11299,9 @@ link_info_by_idx_old(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Verify state of group */ if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR @@ -12038,7 +12059,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12066,11 +12087,11 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12111,7 +12132,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; @@ -12468,7 +12489,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; @@ -12488,7 +12509,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12516,11 +12537,11 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12561,7 +12582,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; diff --git a/test/objcopy.c b/test/objcopy.c index f3806cd..cd978f2 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -197,7 +197,7 @@ addr_insert(H5O_info_t *oi) * *------------------------------------------------------------------------- */ -static hbool_t +static H5_ATTR_PURE hbool_t addr_lookup(H5O_info_t *oi) { size_t n; @@ -512,8 +512,12 @@ test_copy_attach_attribute_vl(hid_t loc_id) ret_value = 0; done: - if(tid >0 && sid > 0) - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + if(tid >0 && sid > 0) { + hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); + H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL); + H5Dvlen_reclaim(tid, sid, dxpl_id, buf); + H5Pclose(dxpl_id); + } if(sid > 0) H5Sclose(sid); if(tid > 0) @@ -4028,6 +4032,7 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ hid_t tid = -1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4111,7 +4116,12 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4127,6 +4137,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4158,6 +4169,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -4250,7 +4262,12 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4266,6 +4283,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4297,6 +4316,7 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4387,7 +4407,12 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4403,6 +4428,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4550,6 +4576,7 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t tid = -1; /* Datatype ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ hsize_t dim2d[2]; /* Dataset dimensions */ hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */ hvl_t buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ @@ -4649,7 +4676,12 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4668,6 +4700,7 @@ error: H5Dclose(did); H5Pclose(pid); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -6357,6 +6390,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6456,7 +6490,12 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6473,6 +6512,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6504,6 +6544,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t tid = -1, tid_copy=-1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6596,7 +6637,12 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6612,6 +6658,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6644,6 +6691,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6744,7 +6792,12 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6761,6 +6814,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6793,6 +6847,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6894,7 +6949,12 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6911,6 +6971,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6943,6 +7004,7 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7049,7 +7111,12 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7066,6 +7133,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7098,6 +7167,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7203,7 +7273,12 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7220,6 +7295,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7252,6 +7329,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7359,7 +7437,12 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7377,6 +7460,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7409,6 +7493,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7516,7 +7601,12 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7534,6 +7624,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7576,6 +7667,7 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t did = -1; /* Dataset ID */ hid_t did2 = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7665,7 +7757,12 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7682,6 +7779,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7714,6 +7812,7 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -7811,7 +7910,12 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7828,6 +7932,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7860,6 +7966,7 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7956,7 +8063,12 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7973,6 +8085,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); diff --git a/test/tgenprop.c b/test/tgenprop.c index c4f3a3f..b670c0d 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -1780,7 +1780,7 @@ test_genprop_path(void) CHECK_PTR(path, "H5P_get_class_path_test"); if(HDstrcmp(path,CLASS1_PATH)!=0) TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); - HDfree(path); + H5free_memory(path); /* Create another new generic class, derived from first class */ cid2 = H5Pcreate_class(cid1,CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1805,7 +1805,7 @@ test_genprop_path(void) VERIFY(ret, 1, "H5Pequal"); /* Release the path string */ - HDfree(path); + H5free_memory(path); /* Close class */ ret = H5Pclose_class(cid3); diff --git a/test/tmisc.c b/test/tmisc.c index 1298f6b..011486a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -462,7 +462,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att1, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att1); CHECK(ret, FAIL, "HAclose"); @@ -487,7 +488,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att2, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att2); CHECK(ret, FAIL, "HAclose"); @@ -514,6 +516,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name { hid_t file, root, att; hid_t type; + hid_t space; herr_t ret; misc2_struct data_check; @@ -528,10 +531,17 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name att = H5Aopen(root, att_name, H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); + space = H5Aget_space(att); + CHECK(space, FAIL, "H5Aget_space"); + ret = H5Aread(att, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); + + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); diff --git a/test/tvlstr.c b/test/tvlstr.c index 02bd59d..dbc3083 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -604,7 +604,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -626,7 +626,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; /* The attribute string written is freed below, in the test_read_vl_string_attribute() test */ @@ -687,7 +687,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -704,7 +704,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; } @@ -762,7 +762,8 @@ static void read_scalar_dset(hid_t file, hid_t type, hid_t space, char *name, ch if(HDstrcmp(data, data_read)) TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read); - HDfree(data_read); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_read); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); } /**************************************************************** diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index cce5f3d..98468c9 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -973,7 +973,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) /* Release resources */ for(i = 0; i < (unsigned)nmembs; i++) - HDfree(name[i]); + H5free_memory(name[i]); HDfree(name); HDfree(value); } @@ -1856,13 +1856,10 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) if (vmaps) { size_t next; - ssize_t ssize_out; h5tools_str_append(&buffer, " %-10s {%ld} Source {\n", "Maps:", vmaps); for (next = 0; next < (unsigned) vmaps; next++) { - ssize_out = H5Pget_virtual_filename(dcpl, next, NULL, 0); H5Pget_virtual_filename(dcpl, next, f_name, sizeof(f_name)); - ssize_out = H5Pget_virtual_dsetname(dcpl, next, NULL, 0); H5Pget_virtual_dsetname(dcpl, next, dset_name, sizeof(dset_name)); h5tools_str_append(&buffer, " %-10s ", " "); print_string(&buffer, f_name, TRUE); -- cgit v0.12