From 053ae6e11ee81b9ede8469dc906c1fa4c70d6228 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 22 Mar 2012 14:31:38 -0500 Subject: [svn-r22123] update the VOL GET callbacks to use var_args instead of argc & argv --- src/H5F.c | 44 ++++------ src/H5G.c | 69 ++++----------- src/H5O.c | 80 ++++++----------- src/H5VL.c | 39 ++++++--- src/H5VLnative.c | 254 ++++++++++++++++++++++++++++++++++-------------------- src/H5VLprivate.h | 8 +- src/H5VLpublic.h | 8 +- 7 files changed, 258 insertions(+), 244 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index 72ed989..eaffc82 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -193,7 +193,7 @@ H5Fget_create_plist(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", uid); - if(H5VL_file_get(uid, H5F_GET_FCPL, &ret_value, 0, NULL) < 0) + if(H5VL_file_get(uid, H5F_GET_FCPL, 1, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") done: @@ -230,7 +230,7 @@ H5Fget_access_plist(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", uid); - if(H5VL_file_get(uid, H5F_GET_FAPL, &ret_value, 0, NULL) < 0) + if(H5VL_file_get(uid, H5F_GET_FAPL, 1, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") done: @@ -752,7 +752,7 @@ H5Fget_vfd_handle(hid_t uid, hid_t fapl, void **file_handle) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") - if((ret_value = H5VL_file_get(uid, H5F_GET_VFD_HANDLE, &fapl, 1, file_handle)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_VFD_HANDLE, 2, file_handle, fapl)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle") done: @@ -1979,7 +1979,7 @@ H5Fget_intent(hid_t uid, unsigned *intent_flags) /* If no intent flags were passed in, exit quietly */ if(intent_flags) { - if((ret_value = H5VL_file_get(uid, H5F_GET_INTENT, (void *)intent_flags, 0, NULL)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_INTENT, 1, intent_flags)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file intent") } @@ -2402,7 +2402,7 @@ H5Fget_freespace(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", uid); - if(H5VL_file_get(uid, H5F_GET_FREE_SPACE, &ret_value, 0, NULL) < 0) + if(H5VL_file_get(uid, H5F_GET_FREE_SPACE, 1, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free space") done: @@ -2436,7 +2436,7 @@ H5Fget_filesize(hid_t uid, hsize_t *size) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", uid, size); - if((ret_value = H5VL_file_get(uid, H5F_GET_SIZE, (void *)size, 0, NULL)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_SIZE, 1, size)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file size") done: @@ -2474,7 +2474,7 @@ H5Fget_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") - if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_CONF, (void *)config_ptr, 0, NULL)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_CONF, 1, config_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get mdc config") done: @@ -2552,7 +2552,7 @@ H5Fget_mdc_hit_rate(hid_t uid, double *hit_rate_ptr) if(NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") - if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_HR, (void *)hit_rate_ptr, 0, NULL)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_HR, 1, hit_rate_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -2581,17 +2581,14 @@ herr_t H5Fget_mdc_size(hid_t uid, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, int *cur_num_entries_ptr) { - void *argv[3]; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*z*z*z*Is", uid, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr); - argv[0] = (void *)max_size_ptr; - argv[1] = (void *)min_clean_size_ptr; - argv[2] = (void *)cur_size_ptr; - if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_SIZE, (void *)cur_num_entries_ptr, 3, argv)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_MDC_SIZE, 4, max_size_ptr, + min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -2672,20 +2669,17 @@ done: ssize_t H5Fget_name(hid_t uid, char *name/*out*/, size_t size) { - void *argv[2]; /* arguments to the VOL callback */ ssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", uid, name, size); /* MSC - temp fix to handle later when all user level ids are of type UID */ - if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - argv[0] = &ret_value; - argv[1] = &size; - if(H5VL_file_get(uid, H5F_GET_NAME, (void *)name, 2, argv) < 0) + if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid) || + H5I_DATATYPE_PUBLIC == H5I_get_type(uid) || H5I_DATASET_PUBLIC == H5I_get_type(uid) || + H5I_ATTRIBUTE_PUBLIC == H5I_get_type(uid)) { + if(H5VL_file_get(uid, H5F_GET_NAME, 3, name, &ret_value, size) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") - - ret_value = *((ssize_t *)argv[0]); } else { H5F_t *f; /* Top file in mount hierarchy */ @@ -2752,7 +2746,7 @@ H5Fget_info2(hid_t uid, H5F_info2_t *finfo) if(!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if((ret_value = H5VL_file_get(uid, H5F_GET_INFO, (void *)finfo, 0, NULL)) < 0) + if((ret_value = H5VL_file_get(uid, H5F_GET_INFO, 1, finfo)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info") done: FUNC_LEAVE_API(ret_value) @@ -2778,7 +2772,6 @@ ssize_t H5Fget_free_sections(hid_t uid, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/) { - void *argv[3]; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2788,11 +2781,8 @@ H5Fget_free_sections(hid_t uid, H5F_mem_t type, size_t nsects, if(sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0") - argv[0] = &ret_value; - argv[1] = &type; - argv[2] = &nsects; - - if(H5VL_file_get(uid, H5F_GET_FREE_SECTIONS, (void *)sect_info, 3, argv) < 0) + if(H5VL_file_get(uid, H5F_GET_FREE_SECTIONS, 4, sect_info, &ret_value, + type, nsects) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5G.c b/src/H5G.c index 0ee943a..df50dd6 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -437,7 +437,7 @@ H5Gget_create_plist(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", uid); - if(H5VL_group_get(uid, H5G_GET_GCPL, &ret_value, 0, NULL) < 0) + if(H5VL_group_get(uid, H5G_GET_GCPL, 1, &ret_value) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group creation properties") done: @@ -459,15 +459,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info(hid_t uid, H5G_info_t *grp_info) +H5Gget_info(hid_t obj_id, H5G_info_t *grp_info) { + H5I_type_t id_type; /* Type of ID */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", uid, grp_info); + H5TRACE2("e", "i*x", obj_id, grp_info); - if((ret_value = H5VL_group_get(uid, H5G_GET_INFO, (void *)grp_info, 0, NULL)) < 0) + /* Check args */ + id_type = H5I_get_type(obj_id); + if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + if((ret_value = H5VL_group_get(obj_id, H5G_GET_INFO, 1, grp_info)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") + done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ @@ -490,19 +499,12 @@ herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, grp_info, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(!grp_info) @@ -513,24 +515,10 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); - - /* Find the group object */ - if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 3, grp_info, name, lapl_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - if(loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_name() */ @@ -553,11 +541,6 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -565,8 +548,6 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -581,25 +562,11 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + if((ret_value = H5VL_group_get(loc_id, H5G_GET_INFO, 6, grp_info, group_name, + idx_type, order, n, lapl_id)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_idx() */ diff --git a/src/H5O.c b/src/H5O.c index 1f94a14..23632b1 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -233,7 +233,6 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) hid_t ret_value = FAIL; void *location = NULL; /* a pointer to VOL specific token that indicates the location of the object */ - void *argv[2]; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, lapl_id); @@ -241,17 +240,19 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - argv[0] = (void *)name; - argv[1] = &lapl_id; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_NAME, &location, 2, argv) < 0) + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_NAME, 3, &location, name, lapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -284,7 +285,6 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { void *location = NULL; - void *argv[5]; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) @@ -303,14 +303,9 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - argv[0] = (void *)group_name; - argv[1] = &idx_type; - argv[2] = ℴ - argv[3] = &n; - argv[4] = &lapl_id; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_IDX, &location, 5, argv) < 0) + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_IDX, 6, &location, group_name, + idx_type, order, n, lapl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ @@ -318,6 +313,10 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -362,16 +361,13 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ void *location = NULL; - void *argv[1]; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("i", "ia", loc_id, addr); - argv[0] = &addr; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_ADDR, &location, 1, argv) < 0) + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_ADDR, 2, &location, addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ @@ -379,7 +375,10 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - + if (NULL != location) { + free (location); + location = NULL; + } FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ @@ -582,8 +581,6 @@ done: herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) { - void *argv[1]; - hid_t lapl_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -593,10 +590,7 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - lapl_id = H5P_LINK_ACCESS_DEFAULT; - argv[0] = &lapl_id; - - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 1, argv)) < 0) + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 1, oinfo)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: @@ -620,7 +614,6 @@ done: herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { - void *argv[2]; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -637,10 +630,9 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - argv[0] = &lapl_id; - argv[1] = (void *)name; - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 2, argv)) < 0) + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 3, oinfo, name, lapl_id)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name() */ @@ -664,7 +656,6 @@ herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) { - void *argv[5]; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -686,14 +677,10 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - argv[0] = (void *)group_name; - argv[1] = &idx_type; - argv[2] = ℴ - argv[3] = &n; - argv[4] = &lapl_id; - - if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 5, argv)) < 0) + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, 6, oinfo, group_name, idx_type, + order, n, lapl_id)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ @@ -804,19 +791,14 @@ done: ssize_t H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize) { - void *argv[2]; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", loc_id, comment, bufsize); - argv[0] = &ret_value; - argv[1] = &bufsize; - - if(H5VL_object_get(loc_id, H5O_GET_COMMENT, (void *)comment, 2, argv) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") + if(H5VL_object_get(loc_id, H5O_GET_COMMENT, 3, &ret_value, comment, bufsize) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") - ret_value = *((ssize_t *)argv[0]); done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment() */ @@ -842,7 +824,6 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - void *argv[4]; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -857,14 +838,9 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - argv[0] = &ret_value; - argv[1] = &bufsize; - argv[2] = (void *)name; - argv[3] = &lapl_id; - if(H5VL_object_get(loc_id, H5O_GET_COMMENT, (void *)comment, 4, argv) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") - - ret_value = *((ssize_t *)argv[0]); + if(H5VL_object_get(loc_id, H5O_GET_COMMENT, 5, &ret_value, comment, bufsize, + name, lapl_id) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5VL.c b/src/H5VL.c index 126a3b0..7f68356 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -740,15 +740,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, void *data, int argc, void **argv) +H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ + va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check/fix arguments. */ - if(H5I_FILE_PUBLIC != H5I_get_type(uid)) + if (H5I_FILE_PUBLIC != H5I_get_type(uid) && H5I_GROUP_PUBLIC != H5I_get_type(uid) && + H5I_DATATYPE_PUBLIC != H5I_get_type(uid) && H5I_DATASET_PUBLIC != H5I_get_type(uid) && + H5I_ATTRIBUTE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ @@ -757,8 +760,11 @@ H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, void *data, int argc, void ** if(NULL == uid_info->vol_plugin->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") - if((ret_value = (uid_info->vol_plugin->file_cls.get)(uid_info->obj_id, get_type, data, argc, argv)) < 0) + + va_start(arguments, num_args); + if((ret_value = (uid_info->vol_plugin->file_cls.get)(uid_info->obj_id, get_type, num_args, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end(arguments); done: FUNC_LEAVE_NOAPI(ret_value) @@ -928,9 +934,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, void *data, int argc, void **argv) +H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ + va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -945,8 +952,12 @@ H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, void *data, int argc, void if(NULL == uid_info->vol_plugin->group_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") - if((ret_value = (uid_info->vol_plugin->group_cls.get)(uid_info->obj_id, get_type, data, argc, argv)) < 0) + + va_start (arguments, num_args); + if((ret_value = (uid_info->vol_plugin->group_cls.get)(uid_info->obj_id, get_type, + num_args, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1100,9 +1111,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv) +H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ + va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1117,10 +1129,12 @@ H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, void **location, if(NULL == uid_info->vol_plugin->object_cls.lookup) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method") + + va_start (arguments, num_args); if((ret_value = (uid_info->vol_plugin->object_cls.lookup)(uid_info->obj_id, lookup_type, - location, argc, argv)) < 0) + num_args, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed") - + va_end (arguments); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_lookup() */ @@ -1141,9 +1155,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, void *data, int argc, void **argv) +H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, int num_args, ...) { H5I_t *uid_info; /* user id structure */ + va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1159,10 +1174,12 @@ H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, void *data, int argc, voi if(NULL == uid_info->vol_plugin->object_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") + + va_start (arguments, num_args); if((ret_value = (uid_info->vol_plugin->object_cls.get)(uid_info->obj_id, get_type, - data, argc, argv)) < 0) + num_args, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - + va_end (arguments); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_get() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index ae5ec4e..2fd48e6 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -61,7 +61,7 @@ static herr_t H5VL_native_file_close(hid_t fid); static hid_t H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); static herr_t H5VL_native_file_flush(hid_t fid, H5F_scope_t scope); static herr_t H5VL_native_file_get(hid_t file_id, H5VL_file_get_t get_type, - void *data, int argc, void **argv); + int num_args, va_list arguments); static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); @@ -80,15 +80,15 @@ static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl hid_t gcpl_id, hid_t gapl_id); static hid_t H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id); static herr_t H5VL_native_group_close(hid_t group_id); -static herr_t H5VL_native_group_get(hid_t file_id, H5VL_group_get_t get_type, - void *data, int argc, void **argv); +static herr_t H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, + int num_args, va_list arguments); static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id); static herr_t H5VL_native_object_close(hid_t object_id); -static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, - int argc, void **argv); +static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, + int num_args, va_list arguments); static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, - void **location, int argc, void **argv); + int num_args, va_list arguments); static const H5VL_class_t H5VL_native_g = { "native", /* name */ @@ -540,7 +540,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, void **argv) +H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, int num_args, va_list arguments) { H5F_t *f = NULL; /* File struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -564,65 +564,70 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int arg /* H5Fget_access_plist */ case H5F_GET_FAPL: { - hid_t plist_id; + hid_t *plist_id = va_arg (arguments, hid_t *); /* Retrieve the file's access property list */ - if((plist_id = H5F_get_access_plist(f, TRUE)) < 0) + if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") - *((hid_t *)data) = plist_id; break; } /* H5Fget_create_plist */ case H5F_GET_FCPL: { H5P_genplist_t *plist; /* Property list */ - hid_t plist_id; + hid_t *plist_id = va_arg (arguments, hid_t *); if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the property list object to return */ - if((plist_id = H5P_copy_plist(plist, TRUE)) < 0) + if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties") - *((hid_t *)data) = plist_id; + break; } /* H5Fget_filesize */ case H5F_GET_SIZE: { haddr_t eof; /* End of file address */ + hsize_t *ret = va_arg (arguments, hsize_t *); /* Go get the actual file size */ if(HADDR_UNDEF == (eof = H5FDget_eof(f->shared->lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - *((hsize_t *)data) = (hsize_t)eof; + *ret = (hsize_t)eof; break; } /* H5Fget_freespace */ case H5F_GET_FREE_SPACE: { hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = va_arg (arguments, hssize_t *); /* Go get the actual amount of free space in the file */ if(H5MF_get_freespace(f, H5AC_ind_dxpl_id, &tot_space, NULL) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *((hssize_t *)data) = (hssize_t)tot_space; + *ret = (hssize_t)tot_space; break; } case H5F_GET_FREE_SECTIONS: { + H5F_sect_info_t *sect_info = va_arg (arguments, H5F_sect_info_t *); + ssize_t *ret = va_arg (arguments, ssize_t *); + H5F_mem_t type = va_arg (arguments, H5F_mem_t); + size_t nsects = va_arg (arguments, size_t); + /* Go get the free-space section information in the file */ - if((*((ssize_t *)argv[0]) = H5MF_get_free_sections(f, H5AC_ind_dxpl_id, - *((H5F_mem_t *)argv[1]), - *((size_t *)argv[2]), - (H5F_sect_info_t *)data)) < 0) + if((*ret = H5MF_get_free_sections(f, H5AC_ind_dxpl_id, + type, nsects, sect_info)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") break; } /* H5Fget_info2 */ case H5F_GET_INFO: { - H5F_info2_t *finfo = (H5F_info2_t *)data; + H5F_info2_t *finfo = va_arg (arguments, H5F_info2_t *); + /* For file IDs, get the file object directly */ /* (This prevents the H5G_loc() call from returning the file pointer for * the top file in a mount hierarchy) @@ -656,22 +661,25 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int arg /* H5Fget_intent */ case H5F_GET_INTENT: { + unsigned *ret = va_arg (arguments, unsigned *); + /* HDF5 uses some flags internally that users don't know about. * Simplify things for them so that they only get either H5F_ACC_RDWR * or H5F_ACC_RDONLY. */ if(H5F_INTENT(f) & H5F_ACC_RDWR) - *((unsigned *)data) = H5F_ACC_RDWR; + *ret = H5F_ACC_RDWR; else - *((unsigned *)data) = H5F_ACC_RDONLY; + *ret = H5F_ACC_RDONLY; break; } /* H5Fget_name */ case H5F_GET_NAME: { - size_t len, size = *((size_t *)argv[1]); - ssize_t ret; - char *name = (char *)data; + char *name = va_arg (arguments, char *); + ssize_t *ret = va_arg (arguments, ssize_t *); + size_t size = va_arg (arguments, size_t); + size_t len; len = HDstrlen(H5F_OPEN_NAME(f)); @@ -682,50 +690,56 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int arg } /* end if */ /* Set the return value for the API call */ - ret = (ssize_t)len; - memcpy (argv[0], &ret, sizeof(ssize_t)); - + *ret = (ssize_t)len; break; } /* H5Fget_vfd_handle */ case H5F_GET_VFD_HANDLE: { - hid_t fapl; + void **file_handle = va_arg (arguments, void **); + hid_t fapl = va_arg (arguments, hid_t); - fapl = *((hid_t *)data); /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(f, fapl, argv) < 0) + if(H5F_get_vfd_handle(f, fapl, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") break; } /* H5Fget_mdc_config */ case H5F_GET_MDC_CONF: { + H5AC_cache_config_t *config_ptr = va_arg (arguments, H5AC_cache_config_t *); + /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(f->shared->cache, (H5AC_cache_config_t *)data) < 0) + if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") break; } /* H5Fget_mdc_hit_rate */ case H5F_GET_MDC_HR: { + double *hit_rate_ptr = va_arg (arguments, double *); + /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(f->shared->cache, (double *)data) < 0) + if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") break; } /* H5Fget_mdc_size */ case H5F_GET_MDC_SIZE: { - int32_t cur_num_entries; + size_t *max_size_ptr = va_arg (arguments, size_t *); + size_t *min_clean_size_ptr = va_arg (arguments, size_t *); + size_t *cur_size_ptr = va_arg (arguments, size_t *); + int *cur_num_entries_ptr = va_arg (arguments, int *); + int32_t cur_num_entries; /* Go get the size data */ - if(H5AC_get_cache_size(f->shared->cache, (size_t *)argv[0], (size_t *)argv[1], - (size_t *)argv[2], &cur_num_entries) < 0) + if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, + cur_size_ptr, &cur_num_entries) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - if(data != NULL) - *((int *)data) = (int)cur_num_entries; + if(cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; break; } default: @@ -899,10 +913,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, void *data, int argc, void **argv) +H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, int num_args, va_list arguments) { + H5G_loc_t grp_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + hid_t *new_gcpl_id, new_id = FAIL; herr_t ret_value = SUCCEED; /* Return value */ - hid_t new_gcpl_id = FAIL; + FUNC_ENTER_NOAPI_NOINIT switch (get_type) { @@ -916,7 +933,8 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, void *data, int a H5G_t *grp = NULL; H5P_genplist_t *gcpl_plist; H5P_genplist_t *new_plist; - + + new_gcpl_id = va_arg (arguments, hid_t *); /* Check args */ if(NULL == (grp = (H5G_t *)H5I_object_verify(obj_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") @@ -924,9 +942,9 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, void *data, int a /* Copy the default group creation property list */ if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") - if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) + if((new_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Retrieve any object creation properties */ @@ -973,43 +991,86 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, void *data, int a } /* end if */ /* Set the return value */ - *((hid_t *)data) = new_gcpl_id; + *new_gcpl_id = new_id; break; } /* H5Fget_info2 */ case H5G_GET_INFO: { - H5I_type_t id_type; /* Type of ID */ - H5G_loc_t loc; /* Location of group */ - H5G_info_t *grp_info = (H5G_info_t *)data; - - /* Check args */ - id_type = H5I_get_type(obj_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(!grp_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + H5G_loc_t loc; + H5G_info_t *grp_info = va_arg (arguments, H5G_info_t *); /* Get group location */ if(H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + /* Retrieve the object's information */ + if(1 == num_args) { + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else if(3 == num_args) { + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + char *name = va_arg (arguments, char *); + hid_t lapl_id = va_arg (arguments, hid_t); + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the group object */ + if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else if (6 == num_args) { + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + char *group_name = va_arg (arguments, char *); + H5_index_t idx_type = va_arg (arguments, H5_index_t); + H5_iter_order_t order = va_arg (arguments, H5_iter_order_t); + hsize_t n = va_arg (arguments, hsize_t); + hid_t lapl_id = va_arg (arguments, hid_t); + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the group's information */ + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } break; } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") } + done: if (H5G_GET_GCPL == get_type) { - if(*((hid_t *)data) < 0) { - if(new_gcpl_id > 0) - if(H5I_dec_app_ref(new_gcpl_id) < 0) + if(*new_gcpl_id < 0) { + if(new_id > 0) + if(H5I_dec_app_ref(new_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") } /* end if */ } + if (H5G_GET_INFO == get_type) { + if(loc_found && H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + } FUNC_LEAVE_NOAPI(ret_value) } @@ -1112,7 +1173,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, int argc, void **argv) +H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, int num_args, va_list arguments) { herr_t ret_value = SUCCEED; /* Return value */ H5G_loc_t loc; /* Location of group */ @@ -1128,27 +1189,29 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, int arg /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ case H5O_GET_INFO: { - H5O_info_t *obj_info = (H5O_info_t *)data; + H5O_info_t *obj_info = va_arg (arguments, H5O_info_t *); + /* Retrieve the object's information */ - if(1 == argc) { + if(1 == num_args) { if(H5G_loc_info(&loc, ".", TRUE, obj_info/*out*/, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - else if(2 == argc) { - hid_t lapl_id = *((hid_t *)argv[0]); - char *name = (char *)argv[1]; + else if(3 == num_args) { + char *name = va_arg (arguments, char *); + hid_t lapl_id = va_arg (arguments, hid_t); + if(H5G_loc_info(&loc, name, TRUE, obj_info/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - else if (5 == argc) { - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - char *group_name = (char *)argv[0]; - H5_index_t idx_type = *((H5_index_t *)argv[1]); - H5_iter_order_t order = *((H5_iter_order_t *)argv[2]); - hsize_t n = *((hsize_t *)argv[3]); - hid_t lapl_id = *((hid_t *)argv[4]); + else if (6 == num_args) { + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + char *group_name = va_arg (arguments, char *); + H5_index_t idx_type = va_arg (arguments, H5_index_t); + H5_iter_order_t order = va_arg (arguments, H5_iter_order_t); + hsize_t n = va_arg (arguments, hsize_t); + hid_t lapl_id = va_arg (arguments, hid_t); /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -1169,26 +1232,24 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, int arg /* H5Oget_comment / H5Oget_comment_by_name */ case H5O_GET_COMMENT: { - size_t bufsize = *((size_t *)argv[1]); - ssize_t ret; - char *comment = (char *)data; + ssize_t *ret = va_arg (arguments, ssize_t *); + char *comment = va_arg (arguments, char *); + size_t bufsize = va_arg (arguments, size_t); - if(2 == argc) { + if(3 == num_args) { /* Retrieve the object's comment */ - if((ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, + if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - else if(4 == argc) { - char *name = (char *) argv[2]; - hid_t lapl_id = *((hid_t *)argv[3]); + else if(5 == num_args) { + char *name = va_arg (arguments, char *); + hid_t lapl_id = va_arg (arguments, hid_t); /* Retrieve the object's comment */ - if((ret = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((*ret = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - - memcpy (argv[0], &ret, sizeof(ssize_t)); break; } default: @@ -1216,10 +1277,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv) +H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, + int num_args, va_list arguments) { H5G_loc_t loc; - H5G_loc_t *obj_loc; /* Location used to open group */ + H5G_loc_t *obj_loc, **location; /* Location used to open group */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1228,6 +1290,8 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void * if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + location = va_arg (arguments, H5G_loc_t **); + if (NULL == (*location = (H5G_loc_t *)malloc(sizeof(H5G_loc_t)))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "memory allocation failed for object location") @@ -1241,8 +1305,8 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void * switch (lookup_type) { case H5O_LOOKUP_BY_NAME: { - char *name = (char *)argv[0]; - hid_t lapl_id = *((hid_t *)argv[1]); + char *name = va_arg (arguments, char *); + hid_t lapl_id = va_arg (arguments, hid_t); HDassert(&loc); HDassert(name && *name); @@ -1255,11 +1319,11 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void * } case H5O_LOOKUP_BY_IDX: { - char *group_name = (char *)argv[0]; - H5_index_t idx_type = *((H5_index_t *)argv[1]); - H5_iter_order_t order = *((H5_iter_order_t *)argv[2]); - hsize_t n = *((hsize_t *)argv[3]); - hid_t lapl_id = *((hid_t *)argv[4]); + char *group_name = va_arg (arguments, char *); + H5_index_t idx_type = va_arg (arguments, H5_index_t); + H5_iter_order_t order = va_arg (arguments, H5_iter_order_t); + hsize_t n = va_arg (arguments, hsize_t); + hid_t lapl_id = va_arg (arguments, hid_t); /* Find the object's location, according to the order in the index */ if((ret_value = H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, @@ -1270,7 +1334,7 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void * } case H5O_LOOKUP_BY_ADDR: { - haddr_t addr = *((haddr_t *)argv[0]); + haddr_t addr = va_arg (arguments, haddr_t); if(!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 867a05c..71d0e8b 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -53,7 +53,7 @@ H5_DLL hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5VL_file_close(hid_t file_id); H5_DLL herr_t H5VL_file_flush(hid_t file_id, H5F_scope_t scope); -H5_DLL herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, void *data, int argc, void **argv); +H5_DLL herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, int num_args, ...); H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); H5_DLL hid_t H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id); @@ -67,12 +67,12 @@ H5_DLL hid_t H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id); H5_DLL hid_t H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id); H5_DLL herr_t H5VL_group_close(hid_t uid); -H5_DLL herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, void *data, int argc, void **argv); +H5_DLL herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, int num_args, ...); H5_DLL hid_t H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id); H5_DLL herr_t H5VL_object_close(hid_t uid); -H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, void *data, int argc, void **argv); -H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv); +H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, int num_args, ...); +H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, int num_args, ...); H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); H5_DLL herr_t H5VL_fapl_copy(hid_t vol_id, const void *fapl, void **copied_fapl); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index b374d78..06201cb 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -69,7 +69,7 @@ typedef struct H5VL_file_class_t { herr_t (*close) (hid_t file_id); hid_t (*create)(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); herr_t (*flush) (hid_t file_id, H5F_scope_t scope); - herr_t (*get) (hid_t file_id, H5VL_file_get_t get_type, void *data, int argc, void **argv); + herr_t (*get) (hid_t file_id, H5VL_file_get_t get_type, int num_args, va_list arguments); } H5VL_file_class_t; /* H5D routines */ @@ -120,7 +120,7 @@ typedef struct H5VL_group_class_t { hid_t (*create)(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); hid_t (*open) (hid_t loc_id, const char *name, hid_t gapl_id); herr_t (*close) (hid_t group_id); - herr_t (*get) (hid_t file_id, H5VL_group_get_t get_type, void *data, int argc, void **argv); + herr_t (*get) (hid_t file_id, H5VL_group_get_t get_type, int num_args, va_list arguments); } H5VL_group_class_t; /* H5O routines */ @@ -131,8 +131,8 @@ typedef struct H5VL_object_class_t { const char *dest_name, hid_t lcpl, hid_t lapl); herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id ); - herr_t (*lookup)(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv); - herr_t (*get) (hid_t loc_id, H5VL_object_get_t get_type, void *data, int argc, void **argv); + herr_t (*lookup)(hid_t loc_id, H5VL_object_lookup_t lookup_type, int num_args, va_list arguments); + herr_t (*get) (hid_t loc_id, H5VL_object_get_t get_type, int num_args, va_list arguments); } H5VL_object_class_t; /* Class information for each VOL driver */ -- cgit v0.12