diff options
-rw-r--r-- | release_docs/RELEASE.txt | 4 | ||||
-rw-r--r-- | src/H5A.c | 474 | ||||
-rw-r--r-- | src/H5D.c | 24 | ||||
-rw-r--r-- | src/H5Fmount.c | 252 | ||||
-rw-r--r-- | src/H5Fprivate.h | 4 | ||||
-rw-r--r-- | src/H5G.c | 1318 | ||||
-rw-r--r-- | src/H5Gent.c | 249 | ||||
-rw-r--r-- | src/H5Gname.c | 244 | ||||
-rw-r--r-- | src/H5Gnode.c | 362 | ||||
-rw-r--r-- | src/H5Gpkg.h | 47 | ||||
-rw-r--r-- | src/H5Gprivate.h | 47 | ||||
-rw-r--r-- | src/H5Gstab.c | 66 | ||||
-rw-r--r-- | src/H5Gtest.c | 221 | ||||
-rw-r--r-- | src/H5Gtraverse.c | 717 | ||||
-rw-r--r-- | src/H5I.c | 28 | ||||
-rw-r--r-- | src/H5O.c | 2 | ||||
-rw-r--r-- | src/H5Oattr.c | 34 | ||||
-rw-r--r-- | src/H5Odtype.c | 4 | ||||
-rw-r--r-- | src/H5Sprivate.h | 2 | ||||
-rw-r--r-- | src/H5T.c | 8 | ||||
-rw-r--r-- | src/H5Tcommit.c | 205 | ||||
-rw-r--r-- | src/H5private.h | 8 | ||||
-rw-r--r-- | src/Makefile.in | 4 | ||||
-rw-r--r-- | test/getname.c | 1862 | ||||
-rw-r--r-- | test/tfile.c | 2 |
25 files changed, 1916 insertions, 4272 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 54fe993..bcbc065 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -44,6 +44,7 @@ New Features Source code distribution: ------------------------- + Library: -------- @@ -55,6 +56,7 @@ New Features F90 API: -------- + C++ API: -------- @@ -71,6 +73,8 @@ Bug Fixes since HDF5-1.6.5 Release Library ------- + - Fixed various problems with retrieving names of objects, especially + with mounted files. QAK - 2005/12/25 Configuration ------------- @@ -23,6 +23,7 @@ #include "H5Apkg.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace functions */ @@ -70,7 +71,7 @@ DESCRIPTION static herr_t H5A_init_interface(void) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_init_interface) @@ -108,8 +109,8 @@ H5A_term_interface(void) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5A_term_interface) - if (H5_interface_initialize_g) { - if ((n=H5I_nmembers(H5I_ATTR))>0) { + if(H5_interface_initialize_g) { + if((n = H5I_nmembers(H5I_ATTR))>0) { (void)H5I_clear_group(H5I_ATTR, FALSE); } else { (void)H5I_destroy_group(H5I_ATTR); @@ -136,8 +137,6 @@ H5A_term_interface(void) RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function creates an attribute which is attached to the object specified with 'location_id'. The name specified with 'name' for each @@ -154,11 +153,7 @@ H5A_term_interface(void) attribute is reduced to zero. The location object may be either a group or a dataset, both of which may have any sort of attribute. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a committed datatype. - * + --------------------------------------------------------------------------*/ /* ARGSUSED */ hid_t @@ -174,20 +169,20 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5TRACE5("i","isiii",loc_id,name,type_id,space_id,plist_id); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if (NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) + if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Go do the real work for attaching the attribute to the dataset */ - if ((ret_value=H5A_create(ent,name,type,space, H5AC_dxpl_id))<0) - HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + if((ret_value = H5A_create(ent,name,type,space, H5AC_dxpl_id))<0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") done: FUNC_LEAVE_API(ret_value) @@ -211,11 +206,6 @@ done: * Programmer: Quincey Koziol * April 2, 1998 * - * Modifications: - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added a deep copy of the symbol table entry - * *------------------------------------------------------------------------- */ static hid_t @@ -229,45 +219,45 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, FUNC_ENTER_NOAPI_NOINIT(H5A_create) /* check args */ - assert(ent); - assert(name); - assert(type); - assert(space); + HDassert(ent); + HDassert(name); + HDassert(type); + HDassert(space); /* Iterate over the existing attributes to check for duplicates */ - cb.name=name; - cb.idx=(-1); - if((ret_value=H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&cb,dxpl_id))<0) + cb.name = name; + cb.idx = (-1); + if((ret_value = H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&cb,dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") - if(ret_value>0) + if(ret_value > 0) HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, FAIL, "attribute already exists") /* Check if the dataspace has an extent set (or is NULL) */ - if( !(H5S_has_extent(space)) ) + if(!(H5S_has_extent(space))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") /* Build the attribute information */ - if((attr = H5FL_CALLOC(H5A_t))==NULL) + if((attr = H5FL_CALLOC(H5A_t)) == NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info") /* Copy the attribute name */ - attr->name=HDstrdup(name); + attr->name = HDstrdup(name); /* Copy the attribute's datatype */ - attr->dt=H5T_copy(type, H5T_COPY_ALL); + attr->dt = H5T_copy(type, H5T_COPY_ALL); /* Mark any VL datatypes as being on disk now */ if (H5T_vlen_mark(attr->dt, ent->file, H5T_VLEN_DISK)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* Copy the dataspace for the attribute */ - attr->ds=H5S_copy(space, FALSE); + attr->ds = H5S_copy(space, FALSE); /* Mark it initially set to initialized */ attr->initialized = TRUE; /*for now, set to false later*/ /* Deep copy of the symbol table entry */ - if (H5G_ent_copy(&(attr->ent),ent,H5G_COPY_DEEP)<0) + if(H5G_ent_copy(&(attr->ent), ent, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Compute the size of pieces on disk */ @@ -286,29 +276,29 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, } /* end if */ else attr->dt_size=H5O_raw_size(H5O_DTYPE_ID,attr->ent.file,type); - assert(attr->dt_size>0); - attr->ds_size=H5S_raw_size(attr->ent.file,space); - assert(attr->ds_size>0); - H5_ASSIGN_OVERFLOW(attr->data_size,H5S_GET_EXTENT_NPOINTS(attr->ds)*H5T_get_size(attr->dt),hssize_t,size_t); + HDassert(attr->dt_size > 0); + attr->ds_size = H5S_raw_size(attr->ent.file,space); + HDassert(attr->ds_size > 0); + H5_ASSIGN_OVERFLOW(attr->data_size, H5S_GET_EXTENT_NPOINTS(attr->ds) * H5T_get_size(attr->dt), hssize_t, size_t); /* Hold the symbol table entry (and file) open */ - if (H5O_open(&(attr->ent)) < 0) + if(H5O_open(&(attr->ent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") attr->ent_opened=1; /* Create the attribute message and save the attribute index */ - if (H5O_modify(&(attr->ent), H5O_ATTR_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, attr, dxpl_id) < 0) + if(H5O_modify(&(attr->ent), H5O_ATTR_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Register the new attribute and get an ID for it */ - if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0) + if((ret_value = H5I_register(H5I_ATTR, attr)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") /* Now it's safe to say it's uninitialized */ attr->initialized = FALSE; done: - if (ret_value < 0) { + if(ret_value < 0) { if(attr) (void)H5A_close(attr); } /* end if */ @@ -330,8 +320,6 @@ done: RETURNS Non-negative on success, negative on failure - ERRORS - DESCRIPTION This function determines if an attribute matches the name to search for (from the 'op_data') and sets the index value in the 'op_data'. @@ -353,7 +341,7 @@ H5A_find_idx_by_name(const void *_mesg, unsigned idx, void *_op_data) * callback info if names are the same. */ if(HDstrcmp(mesg->name,op_data->name)==0) { - op_data->idx=idx; + op_data->idx = idx; ret_value=1; } /* end if */ else @@ -375,8 +363,6 @@ H5A_find_idx_by_name(const void *_mesg, unsigned idx, void *_op_data) RETURNS non-negative on success, negative on failure - ERRORS - DESCRIPTION This function determines the index of the attribute within an object header. This is not stored in the attribute structure because it is only @@ -386,20 +372,20 @@ H5A_find_idx_by_name(const void *_mesg, unsigned idx, void *_op_data) static int H5A_get_index(H5G_entry_t *ent, const char *name, hid_t dxpl_id) { - H5A_iter_cb1 cb; /* Iterator callback */ - int ret_value=FAIL; /* Return value */ + H5A_iter_cb1 udata; /* Iterator callback info */ + int ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_get_index) - assert(ent); - assert(name); + HDassert(ent); + HDassert(name); - cb.name=name; - cb.idx=(-1); - if((ret_value=H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&cb,dxpl_id))<0) + udata.name = name; + udata.idx = (-1); + if((ret_value=H5O_iterate(ent,H5O_ATTR_ID,H5A_find_idx_by_name,&udata,dxpl_id))<0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error iterating over attributes") - if(ret_value>0) - ret_value=cb.idx; + if(ret_value > 0) + ret_value = udata.idx; else HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found") @@ -420,8 +406,6 @@ done: RETURNS ID of attribute on success, negative on failure - ERRORS - DESCRIPTION This function opens an existing attribute for access. The attribute name specified is used to look up the corresponding attribute for the @@ -429,27 +413,23 @@ done: H5Aclose or resource leaks will develop. The location object may be either a group or a dataset, both of which may have any sort of attribute. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a named (committed) datatype. --------------------------------------------------------------------------*/ hid_t H5Aopen_name(hid_t loc_id, const char *name) { H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute*/ - int idx=0; + int idx; hid_t ret_value; FUNC_ENTER_API(H5Aopen_name, FAIL) H5TRACE2("i","is",loc_id,name); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Look up the attribute for the object */ @@ -477,8 +457,6 @@ done: RETURNS ID of attribute on success, negative on failure - ERRORS - DESCRIPTION This function opens an existing attribute for access. The attribute index specified is used to look up the corresponding attribute for the @@ -486,11 +464,6 @@ done: H5Aclose or resource leaks will develop. The location object may be either a group or a dataset, both of which may have any sort of attribute. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a named (committed) datatype. - * --------------------------------------------------------------------------*/ hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) @@ -502,7 +475,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) H5TRACE2("i","iIu",loc_id,idx); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") @@ -531,11 +504,6 @@ done: * Programmer: Quincey Koziol * April 2, 1998 * - * Modifications: - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added a deep copy of the symbol table entry - * *------------------------------------------------------------------------- */ static hid_t @@ -547,32 +515,38 @@ H5A_open(H5G_entry_t *ent, unsigned idx, hid_t dxpl_id) FUNC_ENTER_NOAPI_NOINIT(H5A_open) /* check args */ - assert(ent); + HDassert(ent); /* Read in attribute with H5O_read() */ H5_CHECK_OVERFLOW(idx,unsigned,int); - if (NULL==(attr=H5O_read(ent, H5O_ATTR_ID, (int)idx, NULL, dxpl_id))) + if(NULL==(attr=H5O_read(ent, H5O_ATTR_ID, (int)idx, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header") - attr->initialized=1; + attr->initialized = TRUE; + +#if defined(H5_USING_PURIFY) || !defined(NDEBUG) + /* Clear entry */ + if(H5G_ent_reset(&(attr->ent)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to reset path") +#endif /* H5_USING_PURIFY */ /* Deep copy of the symbol table entry */ - if (H5G_ent_copy(&(attr->ent),ent,H5G_COPY_DEEP)<0) + if(H5G_ent_copy(&(attr->ent), ent, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") /* Hold the symbol table entry (and file) open */ - if (H5O_open(&(attr->ent)) < 0) + if(H5O_open(&(attr->ent)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open") - attr->ent_opened=1; + attr->ent_opened = TRUE; /* Register the new attribute and get an ID for it */ - if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0) + if((ret_value = H5I_register(H5I_ATTR, attr)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") done: - if (ret_value < 0) { + if(ret_value < 0) { if(attr) (void)H5A_close(attr); - } + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5A_open() */ @@ -591,8 +565,6 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ @@ -607,15 +579,15 @@ H5Awrite(hid_t attr_id, hid_t type_id, const void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (NULL == buf) + if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") /* Go write the actual data to the attribute */ - if ((ret_value=H5A_write(attr,mem_type,buf, H5AC_dxpl_id))<0) + if((ret_value = H5A_write(attr,mem_type,buf, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: @@ -636,8 +608,6 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function writes a complete attribute to disk. --------------------------------------------------------------------------*/ @@ -658,41 +628,41 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) FUNC_ENTER_NOAPI_NOINIT(H5A_write) - assert(attr); - assert(mem_type); - assert(buf); + HDassert(attr); + HDassert(mem_type); + HDassert(buf); /* Create buffer for data to store on disk */ - if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) - HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,size_t); + if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->ds)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + H5_ASSIGN_OVERFLOW(nelmts, snelmts, hssize_t, size_t); - if(nelmts>0) { + if(nelmts > 0) { /* Get the memory and file datatype sizes */ src_type_size = H5T_get_size(mem_type); dst_type_size = H5T_get_size(attr->dt); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ - if (NULL == (tpath = H5T_path_find(mem_type, attr->dt, NULL, NULL, dxpl_id))) + if(NULL == (tpath = H5T_path_find(mem_type, attr->dt, NULL, NULL, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if (!H5T_path_noop(tpath)) { - if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0 || - (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0) + if(!H5T_path_noop(tpath)) { + if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL))) < 0 || + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL))) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ - buf_size=nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5FL_BLK_MALLOC (attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + buf_size = nelmts * MAX(src_type_size, dst_type_size); + if(NULL == (tconv_buf = H5FL_BLK_MALLOC (attr_buf, buf_size)) || NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the user's data into the buffer for conversion */ - HDmemcpy(tconv_buf,buf,(src_type_size*nelmts)); + HDmemcpy(tconv_buf, buf, (src_type_size * nelmts)); /* Perform datatype conversion */ - if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id)<0) + if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Free the previous attribute data buffer, if there is one */ @@ -700,19 +670,19 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) H5FL_BLK_FREE(attr_buf, attr->data); /* Set the pointer to the attribute data to the converted information */ - attr->data=tconv_buf; + attr->data = tconv_buf; } /* end if */ /* No type conversion necessary */ else { - HDassert(dst_type_size==src_type_size); + HDassert(dst_type_size == src_type_size); /* Allocate the attribute buffer, if there isn't one */ - if(attr->data==NULL) - if (NULL==(attr->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size*nelmts))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(attr->data == NULL) + if(NULL == (attr->data = H5FL_BLK_MALLOC(attr_buf, dst_type_size * nelmts))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the user's buffer */ - HDmemcpy(attr->data,buf,(dst_type_size*nelmts)); + HDmemcpy(attr->data, buf, (dst_type_size * nelmts)); } /* end else */ /* Look up the attribute for the object */ @@ -725,15 +695,15 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) } /* end if */ /* Indicate the the attribute doesn't need fill-values */ - attr->initialized=TRUE; + attr->initialized = TRUE; done: /* Release resources */ - if (src_id >= 0) + if(src_id >= 0) (void)H5I_dec_ref(src_id); - if (dst_id >= 0) + if(dst_id >= 0) (void)H5I_dec_ref(dst_id); - if (bkg_buf) + if(bkg_buf) H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) @@ -753,8 +723,6 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ @@ -769,15 +737,15 @@ H5Aread(hid_t attr_id, hid_t type_id, void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (NULL == buf) + if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") /* Go write the actual data to the attribute */ - if ((ret_value=H5A_read(attr,mem_type,buf,H5AC_dxpl_id))<0) + if((ret_value = H5A_read(attr,mem_type,buf,H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: @@ -798,8 +766,6 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function reads a complete attribute from disk. --------------------------------------------------------------------------*/ @@ -824,8 +790,8 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) assert(buf); /* Create buffer for data to store on disk */ - if((snelmts=H5S_GET_EXTENT_NPOINTS(attr->ds))<0) - HGOTO_ERROR (H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") + if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->ds)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,size_t); if(nelmts>0) { @@ -844,21 +810,21 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) HGOTO_ERROR(H5E_ATTR, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dst datatypes") /* Check for type conversion required */ - if (!H5T_path_noop(tpath)) { - if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0 || - (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0) + if(!H5T_path_noop(tpath)) { + if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL))) < 0 || + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL))) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Get the maximum buffer size needed and allocate it */ - buf_size=nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + buf_size = nelmts*MAX(src_type_size,dst_type_size); + if(NULL == (tconv_buf = H5FL_BLK_MALLOC(attr_buf, buf_size)) || NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Copy the attribute data into the buffer for conversion */ HDmemcpy(tconv_buf,attr->data,(src_type_size*nelmts)); /* Perform datatype conversion. */ - if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id)<0) + if(H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Copy the converted data into the user's buffer */ @@ -866,7 +832,7 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) } /* end if */ /* No type conversion necessary */ else { - HDassert(dst_type_size==src_type_size); + HDassert(dst_type_size == src_type_size); /* Copy the attribute data into the user's buffer */ HDmemcpy(buf,attr->data,(dst_type_size*nelmts)); @@ -876,13 +842,13 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) done: /* Release resources */ - if (src_id >= 0) + if(src_id >= 0) (void)H5I_dec_ref(src_id); - if (dst_id >= 0) + if(dst_id >= 0) (void)H5I_dec_ref(dst_id); - if (tconv_buf) + if(tconv_buf) H5FL_BLK_FREE(attr_buf, tconv_buf); - if (bkg_buf) + if(bkg_buf) H5FL_BLK_FREE(attr_buf, bkg_buf); FUNC_LEAVE_NOAPI(ret_value) @@ -900,8 +866,6 @@ done: RETURNS A dataspace ID on success, negative on failure - ERRORS - DESCRIPTION This function retrieves a copy of the dataspace for an attribute. The dataspace ID returned from this function must be released with H5Sclose @@ -918,16 +882,16 @@ H5Aget_space(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Copy the attribute's dataspace */ - if (NULL==(dst=H5S_copy (attr->ds, FALSE))) - HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace") + if(NULL == (dst = H5S_copy (attr->ds, FALSE))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace") /* Atomize */ - if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + if((ret_value = H5I_register (H5I_DATASPACE, dst)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: FUNC_LEAVE_API(ret_value) @@ -945,19 +909,10 @@ done: RETURNS A datatype ID on success, negative on failure - ERRORS - DESCRIPTION This function retrieves a copy of the datatype for an attribute. The datatype ID returned from this function must be released with H5Tclose or resource leaks will develop. - * - * Modifications: - * Robb Matzke, 4 Jun 1998 - * The datatype is reopened if it's a named type before returning it to - * the application. The datatypes returned by this function are always - * read-only. If an error occurs when atomizing the return datatype - * then the datatype is closed. --------------------------------------------------------------------------*/ hid_t H5Aget_type(hid_t attr_id) @@ -970,7 +925,7 @@ H5Aget_type(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* @@ -978,21 +933,21 @@ H5Aget_type(hid_t attr_id) * reopen the type before returning it to the user. Make the type * read-only. */ - if (NULL==(dst=H5T_copy(attr->dt, H5T_COPY_REOPEN))) + if(NULL == (dst = H5T_copy(attr->dt, H5T_COPY_REOPEN))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy datatype") /* Mark any VL datatypes as being in memory now */ - if (H5T_vlen_mark(dst, NULL, H5T_VLEN_MEMORY)<0) + if(H5T_vlen_mark(dst, NULL, H5T_VLEN_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") - if (H5T_lock(dst, FALSE)<0) + if(H5T_lock(dst, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype") /* Atomize */ - if ((ret_value=H5I_register(H5I_DATATYPE, dst))<0) + if((ret_value = H5I_register(H5I_DATATYPE, dst)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype atom") done: - if(ret_value<0) { + if(ret_value < 0) { if(dst!=NULL) (void)H5T_close(dst); } /* end if */ @@ -1015,8 +970,6 @@ done: This function returns the length of the attribute's name (which may be longer than 'buf_size') on success or negative for failure. - ERRORS - DESCRIPTION This function retrieves the name of an attribute for an attribute ID. Up to 'buf_size' characters are stored in 'buf' followed by a '\0' string @@ -1035,9 +988,9 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) H5TRACE3("Zs","izs",attr_id,buf_size,buf); /* check arguments */ - if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if (!buf && buf_size) + if(!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") /* get the real attribute length */ @@ -1085,14 +1038,14 @@ done: hsize_t H5Aget_storage_size(hid_t attr_id) { - H5A_t *attr=NULL; + H5A_t *attr = NULL; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(H5Aget_storage_size, 0) H5TRACE1("h","i",attr_id); /* Check args */ - if (NULL==(attr=H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Set return value */ @@ -1148,15 +1101,9 @@ H5A_get_storage_size(const H5A_t *attr) RETURNS Number of attributes on success, negative on failure - ERRORS - DESCRIPTION This function returns the number of attributes attached to a dataset or group, 'location_id'. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a named (committed) datatype. --------------------------------------------------------------------------*/ int H5Aget_num_attrs(hid_t loc_id) @@ -1169,7 +1116,7 @@ H5Aget_num_attrs(hid_t loc_id) H5TRACE1("Is","i",loc_id); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if(NULL == (obj = H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") @@ -1185,7 +1132,7 @@ H5Aget_num_attrs(hid_t loc_id) ent = H5G_entof ((H5G_t*)obj); break; default: - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target") } /*lint !e788 All appropriate cases are covered */ /* Look up the attribute for the object */ @@ -1202,35 +1149,33 @@ done: * Purpose: Rename an attribute * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Raymond Lu * October 23, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ - herr_t ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Arename, FAIL) H5TRACE3("e","iss",loc_id,old_name,new_name); /* check arguments */ - if (!old_name || !new_name) + if(!old_name || !new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private function */ - ret_value = H5A_rename(ent, old_name, new_name, H5AC_dxpl_id); + if(H5A_rename(ent, old_name, new_name, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") done: FUNC_LEAVE_API(ret_value) @@ -1243,46 +1188,43 @@ done: * Purpose: Private function for H5Arename. Rename an attribute * * Return: Success: Non-negative - * * Failure: Negative * * Programmer: Raymond Lu * October 23, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t dxpl_id) { - int seq, idx=FAIL; /* Index of attribute being querried */ - H5A_t found_attr; /* Attribute with OLD_NAME */ - herr_t ret_value=SUCCEED; /* Return value */ + int seq, idx = FAIL; /* Index of attribute being querried */ + H5A_t found_attr; /* Attribute with OLD_NAME */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5A_rename) /* Check arguments */ - assert(ent); - assert(old_name); - assert(new_name); + HDassert(ent); + HDassert(old_name); + HDassert(new_name); /* Read in the existing attributes to check for duplicates */ - seq=0; - while(H5O_read(ent, H5O_ATTR_ID, seq, &found_attr, dxpl_id)!=NULL) { + seq = 0; + while(H5O_read(ent, H5O_ATTR_ID, seq, &found_attr, dxpl_id) != NULL) { /* * Compare found attribute name. */ - if(HDstrcmp(found_attr.name,old_name)==0) { + if(HDstrcmp(found_attr.name, old_name) == 0) { idx = seq; break; } - if(H5O_reset (H5O_ATTR_ID, &found_attr)<0) + if(H5O_reset(H5O_ATTR_ID, &found_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info") seq++; - } - H5E_clear (); - if(idx<0) + } /* end while */ + H5E_clear(); + if(idx < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "attribute cannot be found") /* Copy the attribute name. */ @@ -1293,20 +1235,20 @@ H5A_rename(H5G_entry_t *ent, const char *old_name, const char *new_name, hid_t d HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "String copy failed") /* Indicate entry is not opened and the attribute doesn't need fill-values. */ - found_attr.ent_opened=FALSE; - found_attr.initialized=TRUE; + found_attr.ent_opened = FALSE; + found_attr.initialized = TRUE; /* Modify the attribute message */ if (H5O_modify(ent, H5O_ATTR_ID, idx, 0, H5O_UPDATE_TIME, &found_attr, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages") /* Close the attribute */ - if(H5A_free(&found_attr)<0) + if(H5A_free(&found_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close renamed attribute") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5A_rename() */ /*-------------------------------------------------------------------------- @@ -1324,8 +1266,6 @@ done: Returns a negative value if something is wrong, the return value of the last operator if it was non-zero, or zero if all attributes were processed. - ERRORS - DESCRIPTION This function interates over the attributes of dataset or group specified with 'loc_id'. For each attribute of the object, the @@ -1345,29 +1285,20 @@ done: C. Negative causes the iterator to immediately return that value, indicating failure. The iterator can be restarted at the next attribute. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a named (committed) datatype. - * - * Robb Matzke, 5 Jun 1998 - * Like the group iterator, if ATTR_NUM is the null pointer then all - * attributes are processed. - * --------------------------------------------------------------------------*/ herr_t H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) { H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */ H5A_t found_attr; + int idx, start_idx; herr_t ret_value = 0; - int idx, start_idx; FUNC_ENTER_API(H5Aiterate, FAIL) H5TRACE4("e","i*Iuxx",loc_id,attr_num,op,op_data); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") @@ -1377,29 +1308,29 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data) * reasonable. */ start_idx = idx = (attr_num ? (int)*attr_num : 0); - if (idx<0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") + if(idx < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") if(idx<H5O_count(ent, H5O_ATTR_ID, H5AC_dxpl_id)) { while(H5O_read(ent, H5O_ATTR_ID, idx++, &found_attr, H5AC_dxpl_id)!=NULL) { /* * Compare found attribute name to new attribute name reject * creation if names are the same. */ - if((ret_value=(op)(loc_id,found_attr.name,op_data))!=0) { - if(H5O_reset (H5O_ATTR_ID, &found_attr)<0) + if((ret_value = (op)(loc_id,found_attr.name,op_data)) != 0) { + if(H5O_reset(H5O_ATTR_ID, &found_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info") break; - } - if(H5O_reset (H5O_ATTR_ID, &found_attr)<0) + } /* end if */ + if(H5O_reset(H5O_ATTR_ID, &found_attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't release attribute info") - } - H5E_clear (); - } + } /* end while */ + H5E_clear(); + } /* end if */ else if(start_idx>0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") - if (attr_num) + if(attr_num) *attr_num = (unsigned)idx; done: @@ -1419,18 +1350,11 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function removes the named attribute from a dataset or group. This function should not be used when attribute IDs are open on 'loc_id' as it may cause the internal indexes of the attributes to change and future writes to the open attributes to produce incorrect results. - * - * Modifications: - * Robb Matzke, 5 Jun 1998 - * The LOC_ID can also be a named (committed) datatype. - * --------------------------------------------------------------------------*/ herr_t H5Adelete(hid_t loc_id, const char *name) @@ -1443,11 +1367,11 @@ H5Adelete(hid_t loc_id, const char *name) H5TRACE2("e","is",loc_id,name); /* check arguments */ - if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id)) + if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (NULL==(ent=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Look up the attribute index for the object */ @@ -1474,8 +1398,6 @@ done: RETURNS Non-negative on success/Negative on failure - ERRORS - DESCRIPTION This function releases an attribute from use. Further use of the attribute ID will result in undefined behavior. @@ -1483,17 +1405,17 @@ done: herr_t H5Aclose(hid_t attr_id) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Aclose, FAIL) H5TRACE1("e","i",attr_id); /* check arguments */ - if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) + if(NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Decrement references to that atom (and close it) */ - if(H5I_dec_ref (attr_id)<0) + if(H5I_dec_ref (attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: @@ -1520,9 +1442,9 @@ done: H5A_t * H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr, unsigned update_flags) { - H5A_t *new_attr=NULL; - hbool_t allocated_attr=FALSE; /* Whether the attribute was allocated */ - H5A_t *ret_value=NULL; /* Return value */ + H5A_t *new_attr = NULL; + hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */ + H5A_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(H5A_copy, NULL) @@ -1530,13 +1452,13 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr, unsigned update_flags) assert(old_attr); /* get space */ - if(_new_attr==NULL) { + if(_new_attr == NULL) { /* Sanity check - We should not be only updating data if we don'y have anything */ HDassert(!(update_flags&H5O_UPDATE_DATA_ONLY)); - if (NULL==(new_attr = H5FL_MALLOC(H5A_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - allocated_attr=TRUE; + if(NULL == (new_attr = H5FL_MALLOC(H5A_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + allocated_attr = TRUE; } /* end if */ else new_attr=_new_attr; @@ -1546,26 +1468,26 @@ H5A_copy(H5A_t *_new_attr, const H5A_t *old_attr, unsigned update_flags) *new_attr = *old_attr; /* Don't open the object header for a copy */ - new_attr->ent_opened=0; + new_attr->ent_opened = FALSE; /* Copy the guts of the attribute */ - new_attr->name=HDstrdup(old_attr->name); - new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL); - new_attr->ds=H5S_copy(old_attr->ds, FALSE); + new_attr->name = HDstrdup(old_attr->name); + new_attr->dt = H5T_copy(old_attr->dt, H5T_COPY_ALL); + new_attr->ds = H5S_copy(old_attr->ds, FALSE); } /* end if */ if(old_attr->data) { - if(!(update_flags&H5O_UPDATE_DATA_ONLY) || new_attr->data==NULL) { - if (NULL==(new_attr->data=H5FL_BLK_MALLOC(attr_buf,old_attr->data_size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + if(!(update_flags&H5O_UPDATE_DATA_ONLY) || new_attr->data == NULL) { + if(NULL == (new_attr->data = H5FL_BLK_MALLOC(attr_buf,old_attr->data_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ HDmemcpy(new_attr->data,old_attr->data,old_attr->data_size); } /* end if */ /* Set the return value */ - ret_value=new_attr; + ret_value = new_attr; done: - if(ret_value==NULL) { + if(ret_value == NULL) { if(new_attr!=NULL && allocated_attr) (void)H5A_close(new_attr); } /* end if */ @@ -1592,7 +1514,7 @@ done: herr_t H5A_free(H5A_t *attr) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5A_free, FAIL) @@ -1602,10 +1524,10 @@ H5A_free(H5A_t *attr) if(attr->name) H5MM_xfree(attr->name); if(attr->dt) - if(H5T_close(attr->dt)<0) + if(H5T_close(attr->dt) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info") if(attr->ds) - if(H5S_close(attr->ds)<0) + if(H5S_close(attr->ds) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info") if(attr->data) H5FL_BLK_FREE(attr_buf, attr->data); @@ -1632,20 +1554,20 @@ done: herr_t H5A_close(H5A_t *attr) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5A_close, FAIL) - assert(attr); + HDassert(attr); /* Check if the attribute has any data yet, if not, fill with zeroes */ if(attr->ent_opened && !attr->initialized) { - uint8_t *tmp_buf=H5FL_BLK_CALLOC(attr_buf, attr->data_size); - if (NULL == tmp_buf) + uint8_t *tmp_buf = H5FL_BLK_CALLOC(attr_buf, attr->data_size); + if(NULL == tmp_buf) HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed for attribute fill-value") /* Go write the fill data to the attribute */ - if (H5A_write(attr,attr->dt,tmp_buf,H5AC_dxpl_id)<0) + if(H5A_write(attr, attr->dt, tmp_buf, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") /* Free temporary buffer */ @@ -1653,7 +1575,7 @@ H5A_close(H5A_t *attr) } /* end if */ /* Free dynamicly allocated items */ - if(H5A_free(attr)<0) + if(H5A_free(attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") /* Close the object's symbol-table entry */ @@ -1661,6 +1583,10 @@ H5A_close(H5A_t *attr) if(H5O_close(&(attr->ent))<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info") + /* Release the group hier. path for the object the attribute is on */ + if(H5G_name_free(&(attr->ent)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release group hier. path") + H5FL_FREE(H5A_t, attr); done: @@ -1676,14 +1602,11 @@ done: * belongs, not the attribute itself. * * Return: Success: Ptr to entry - * * Failure: NULL * * Programmer: Robb Matzke * Thursday, August 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ H5G_entry_t * @@ -1692,7 +1615,8 @@ H5A_entof(H5A_t *attr) H5G_entry_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5A_entof, NULL) - assert(attr); + + HDassert(attr); /* Set return value */ ret_value=&(attr->ent); @@ -1166,7 +1166,7 @@ done: } /* end if */ else { if(ent_found && ent.header) - H5G_free_ent_name(&ent); + H5G_name_free(&ent); } /* end else */ } /* end if */ FUNC_LEAVE_API(ret_value) @@ -1190,7 +1190,7 @@ done: herr_t H5Dclose(hid_t dset_id) { - H5D_t *dset = NULL; /* Dataset object to release */ + H5D_t *dset; /* Dataset object to release */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dclose, FAIL) @@ -1199,8 +1199,6 @@ H5Dclose(hid_t dset_id) /* Check args */ if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if (NULL == dset->ent.file) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* * Decrement the counter on the dataset. It will be freed if the count @@ -2320,14 +2318,14 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id) /* Allocate the dataset structure */ if(NULL == (dataset = H5FL_CALLOC(H5D_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for dataset") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the group entry object */ - if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0) + if(H5G_ent_copy(&(dataset->ent), ent, H5_COPY_SHALLOW) < 0) HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry") /* Check if dataset was already open */ - if((shared_fo=H5FO_opened(dataset->ent.file, dataset->ent.header))==NULL) { + if((shared_fo = H5FO_opened(dataset->ent.file, dataset->ent.header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); @@ -2625,7 +2623,6 @@ done: if(H5I_dec_ref(dataset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ - dataset->ent.file = NULL; } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_open_oid() */ @@ -2751,11 +2748,11 @@ H5D_close(H5D_t *dataset) if(H5FO_top_count(dataset->ent.file, dataset->ent.header) == 0) if(H5O_close(&(dataset->ent)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close") - - if(H5G_free_ent_name(&dataset->ent)<0) - free_failed=TRUE; } /* end else */ + if(H5G_name_free(&dataset->ent)<0) + free_failed=TRUE; + H5FL_FREE(H5D_t,dataset); if (free_failed) @@ -2841,7 +2838,7 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ - if(dataset->shared->alloc_time==H5D_ALLOC_TIME_EARLY) + if(dataset->shared->alloc_time == H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset, H5D_ALLOC_EXTEND, TRUE, FALSE)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ @@ -2857,7 +2854,6 @@ done: * Purpose: Returns a pointer to the entry for a dataset. * * Return: Success: Ptr to entry - * * Failure: NULL * * Programmer: Robb Matzke @@ -3009,6 +3005,8 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo assert(layout->u.compact.size>0); if (NULL==(layout->u.compact.buf=H5MM_malloc(layout->u.compact.size))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for compact dataset") + if(!full_overwrite) + HDmemset(layout->u.compact.buf, 0, layout->u.compact.size); layout->u.compact.dirty = TRUE; /* Indicate that we set the storage addr */ diff --git a/src/H5Fmount.c b/src/H5Fmount.c index c876b15..6f63866 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -28,6 +28,9 @@ #include "H5MMprivate.h" /* Memory management */ /* PRIVATE PROTOTYPES */ +static herr_t H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, + hid_t plist_id, hid_t dxpl_id); +static herr_t H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id); /*-------------------------------------------------------------------------- @@ -62,8 +65,6 @@ H5F_init_mount_interface(void) * Programmer: Quincey Koziol * Saturday, July 2, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -108,14 +109,6 @@ done: * Programmer: Robb Matzke * Tuesday, October 6, 1998 * - * Modifications: - * - * Robb Matzke, 1998-10-14 - * The reference count for the mounted H5F_t is incremented. - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added `id to name' support. - * *------------------------------------------------------------------------- */ static herr_t @@ -123,42 +116,48 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, hid_t UNUSED plist_id, hid_t dxpl_id) { H5G_t *mount_point = NULL; /*mount point group */ - H5G_entry_t *mp_ent = NULL; /*mount point symbol table entry*/ H5F_t *ancestor = NULL; /*ancestor files */ H5F_t *parent = NULL; /*file containing mount point */ unsigned lt, rt, md; /*binary search indices */ int cmp; /*binary search comparison value*/ - H5G_entry_t *ent = NULL; /*temporary symbol table entry */ - H5G_entry_t mp_open_ent; /* entry of moint point to be opened */ - H5RS_str_t *name_r; /* Ref-counted version of name */ + H5G_entry_t *mp_ent = NULL; /*mount point symbol table entry*/ + H5G_entry_t mp_open_ent; /*entry of moint point to be opened */ + H5G_entry_t *root_ent; /* Symbol table for root of file to mount */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_mount) - assert(loc); - assert(name && *name); - assert(child); - assert(TRUE==H5P_isa_class(plist_id,H5P_MOUNT)); + HDassert(loc); + HDassert(name && *name); + HDassert(child); + HDassert(TRUE == H5P_isa_class(plist_id,H5P_MOUNT)); /* * Check that the child isn't mounted, that the mount point exists, that * the parent & child files have the same file close degree, and * that the mount wouldn't introduce a cycle in the mount tree. */ - if (child->mtab.parent) + if(child->mtab.parent) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") - if (H5G_find(loc, name, &mp_open_ent/*out*/, H5AC_dxpl_id) < 0) + if(H5G_find(loc, name, &mp_open_ent/*out*/, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - if (NULL==(mount_point=H5G_open(&mp_open_ent, dxpl_id))) + if(NULL == (mount_point = H5G_open(&mp_open_ent, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") + /* Retrieve information from the mount point group */ + /* (Some of which we had before but was reset in mp_loc when the group + * "took over" the group location - QAK) + */ parent = H5G_fileof(mount_point); + HDassert(parent); mp_ent = H5G_entof(mount_point); - for (ancestor=parent; ancestor; ancestor=ancestor->mtab.parent) { - if (ancestor==child) + HDassert(mp_ent); + for(ancestor = parent; ancestor; ancestor = ancestor->mtab.parent) { + if(ancestor == child) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") - } + } /* end for */ + /* Make certain that the parent & child files have the same "file close degree" */ if(parent->shared->fc_degree != child->shared->fc_degree) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mounted file has different file close degree than parent") @@ -168,62 +167,63 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, * `md' will be the index where the child should be inserted. */ lt = md = 0; - rt=parent->mtab.nmounts; + rt = parent->mtab.nmounts; cmp = -1; - while (lt<rt && cmp) { - md = (lt+rt)/2; + while(lt < rt && cmp) { + H5G_entry_t *ent; /*temporary symbol table entry */ + + md = (lt + rt) / 2; ent = H5G_entof(parent->mtab.child[md].group); cmp = H5F_addr_cmp(mp_ent->header, ent->header); - if (cmp<0) { + if(cmp < 0) rt = md; - } else if (cmp>0) { - lt = md+1; - } - } - if (cmp>0) + else if(cmp > 0) + lt = md + 1; + } /* end while */ + if(cmp > 0) md++; - if (!cmp) + if(!cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ - if (parent->mtab.nmounts>=parent->mtab.nalloc) { + if(parent->mtab.nmounts>=parent->mtab.nalloc) { unsigned n = MAX(16, 2*parent->mtab.nalloc); H5F_mount_t *x = H5MM_realloc(parent->mtab.child, - n*sizeof(parent->mtab.child[0])); + n * sizeof(parent->mtab.child[0])); if (!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") parent->mtab.child = x; parent->mtab.nalloc = n; - } + } /* end if */ /* Insert into table */ - HDmemmove(parent->mtab.child+md+1, parent->mtab.child+md, - (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); + HDmemmove(parent->mtab.child + md + 1, parent->mtab.child + md, + (parent->mtab.nmounts-md) * sizeof(parent->mtab.child[0])); parent->mtab.nmounts++; parent->mtab.child[md].group = mount_point; parent->mtab.child[md].file = child; child->mtab.parent = parent; /* Set the group's mountpoint flag */ - if(H5G_mount(parent->mtab.child[md].group)<0) + if(H5G_mount(parent->mtab.child[md].group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to set group mounted flag") + /* Get the group location for the root group in the file to unmount */ + if(NULL == (root_ent = H5G_entof(child->shared->root_grp))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get entry for root group") + /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ - name_r=H5RS_wrap(name); - assert(name_r); - if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0) + if(H5G_name_replace(H5G_UNKNOWN, mp_ent, NULL, root_ent, H5G_NAME_MOUNT) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") - if(H5RS_decr(name_r)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string") done: - if (ret_value<0 && mount_point) - if(H5G_close(mount_point)<0) + if(ret_value < 0 && mount_point) + if(H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5F_mount() */ /*------------------------------------------------------------------------- @@ -242,14 +242,6 @@ done: * Programmer: Robb Matzke * Tuesday, October 6, 1998 * - * Modifications: - * - * Robb Matzke, 1998-10-14 - * The ref count for the child is decremented by calling H5F_close(). - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added `id to name' support. - * *------------------------------------------------------------------------- */ static herr_t @@ -257,35 +249,35 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) { H5G_t *mounted = NULL; /*mount point group */ H5G_t *child_group = NULL; /* Child's group in parent mtab */ - H5F_t *child_file = NULL; /* Child's file in parent mtab */ - H5G_entry_t *mnt_ent = NULL; /*mounted symbol table entry */ H5F_t *child = NULL; /*mounted file */ H5F_t *parent = NULL; /*file where mounted */ + H5G_entry_t *mnt_ent = NULL; /*mounted symbol table entry */ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ H5G_entry_t mnt_open_ent; /* entry used to open mount point*/ + H5G_entry_t *root_ent; /* Symbol table for root of file to mount */ int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI_NOINIT(H5F_unmount) - assert(loc); - assert(name && *name); + HDassert(loc); + HDassert(name && *name); /* * Get the mount point, or more precisely the root of the mounted file. * If we get the root group and the file has a parent in the mount tree, * then we must have found the mount point. */ - if (H5G_find(loc, name, &mnt_open_ent/*out*/, H5AC_dxpl_id) < 0) + if(H5G_find(loc, name, &mnt_open_ent/*out*/, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - if (NULL==(mounted=H5G_open(&mnt_open_ent, dxpl_id))) + if(NULL == (mounted = H5G_open(&mnt_open_ent, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") child = H5G_fileof(mounted); mnt_ent = H5G_entof(mounted); ent = H5G_entof(child->shared->root_grp); child_idx = -1; - if (child->mtab.parent && H5F_addr_eq(mnt_ent->header, ent->header)) { + if(child->mtab.parent && H5F_addr_eq(mnt_ent->header, ent->header)) { unsigned u; /*counters */ /* @@ -293,15 +285,15 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) * lookup in the parent's mount table to find the correct entry. */ parent = child->mtab.parent; - for (u=0; u<parent->mtab.nmounts; u++) { - if (parent->mtab.child[u].file==child) { + for(u = 0; u < parent->mtab.nmounts; u++) { + if(parent->mtab.child[u].file == child) { /* Found the correct index */ child_idx = u; break; - } - } + } /* end if */ + } /* end for */ } else { - unsigned lt, rt, md=0; /*binary search indices */ + unsigned lt, rt, md = 0; /*binary search indices */ int cmp; /*binary search comparison value*/ /* @@ -312,57 +304,59 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) lt = 0; rt = parent->mtab.nmounts; cmp = -1; - while (lt<rt && cmp) { - md = (lt+rt)/2; + while(lt < rt && cmp) { + md = (lt + rt) / 2; ent = H5G_entof(parent->mtab.child[md].group); cmp = H5F_addr_cmp(mnt_ent->header, ent->header); - if (cmp<0) { + if (cmp<0) rt = md; - } else { - lt = md+1; - } - } - if (cmp) + else + lt = md + 1; + } /* end while */ + if(cmp) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") - /* Found the correct index */ + /* Found the correct index, set the info about the child */ child_idx = md; mnt_ent = ent; - } - + child = parent->mtab.child[child_idx].file; + } /* end else */ HDassert(child_idx >= 0); - /* Search the open IDs replace names to reflect unmount operation */ - if (H5G_replace_name(H5G_UNKNOWN, mnt_ent, mnt_ent->user_path_r, NULL, NULL, NULL, OP_UNMOUNT )<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ") - /* Save the information about the child from the mount table */ child_group = parent->mtab.child[child_idx].group; - child_file = parent->mtab.child[child_idx].file; + + /* Get the group location for the root group in the file to unmount */ + if(NULL == (root_ent = H5G_entof(child->shared->root_grp))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get entry for root group") + + /* Search the open IDs replace names to reflect unmount operation */ + if(H5G_name_replace(H5G_UNKNOWN, mnt_ent, NULL, root_ent, H5G_NAME_UNMOUNT )<0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ - HDmemmove(parent->mtab.child+child_idx, parent->mtab.child+child_idx+1, - (parent->mtab.nmounts-child_idx)*sizeof(parent->mtab.child[0])); + HDmemmove(parent->mtab.child + child_idx, parent->mtab.child + child_idx + 1, + (parent->mtab.nmounts-child_idx) * sizeof(parent->mtab.child[0])); parent->mtab.nmounts -= 1; /* Unmount the child file from the parent file */ - if(H5G_unmount(child_group)<0) + if(H5G_unmount(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to reset group mounted flag") - if(H5G_close(child_group)<0) + if(H5G_close(child_group) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close unmounted group") /* Detach child file from parent & see if it should close */ - child_file->mtab.parent = NULL; - if(H5F_try_close(child_file)<0) + child->mtab.parent = NULL; + if(H5F_try_close(child) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") done: - if (mounted) - if(H5G_close(mounted)<0 && ret_value>=0) + if(mounted) + if(H5G_close(mounted) < 0 && ret_value >= 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close group") FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5F_unmount() */ /*------------------------------------------------------------------------- @@ -420,17 +414,17 @@ H5F_mountpoint(H5G_entry_t *find/*in,out*/) } /* Copy root info over to ENT */ - if (0==cmp) { + if(0 == cmp) { /* Get the entry for the root group in the child's file */ ent = H5G_entof(parent->mtab.child[md].file->shared->root_grp); - /* Don't lose the user path of the group when we copy the root group's entry */ - if(H5G_ent_copy(find,ent,H5G_COPY_LIMITED)<0) + /* Don't lose the paths of the group when we copy the root group's entry */ + if(H5G_ent_copy(find, ent, H5_COPY_LIMITED) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy group entry") /* Switch to child's file */ parent = ent->file; - } + } /* end if */ } while (!cmp); done: @@ -444,30 +438,27 @@ done: * Purpose: Check if a file has mounted files within it. * * Return: Success: TRUE/FALSE - * Failure: Negative + * Failure: (can't happen) * * Programmer: Quincey Koziol * Thursday, January 2, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ -htri_t +hbool_t H5F_has_mount(const H5F_t *file) { - htri_t ret_value; /* Return value */ + hbool_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5F_has_mount, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_has_mount) - assert(file); + HDassert(file); - if(file->mtab.nmounts>0) - ret_value=TRUE; + if(file->mtab.nmounts > 0) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_has_mount() */ @@ -478,30 +469,27 @@ done: * Purpose: Check if a file is mounted within another file. * * Return: Success: TRUE/FALSE - * Failure: Negative + * Failure: (can't happen) * * Programmer: Quincey Koziol * Thursday, January 2, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ -htri_t +hbool_t H5F_is_mount(const H5F_t *file) { - htri_t ret_value; /* Return value */ + hbool_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5F_is_mount, FAIL) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_is_mount) - assert(file); + HDassert(file); - if(file->mtab.parent!=NULL) - ret_value=TRUE; + if(file->mtab.parent != NULL) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_mount() */ @@ -517,26 +505,24 @@ done: * Programmer: Robb Matzke * Tuesday, October 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { H5G_entry_t *loc = NULL; - H5F_t *child = NULL; + H5F_t *child = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Fmount, FAIL) H5TRACE4("e","isii",loc_id,name,child_id,plist_id); /* Check arguments */ - if (NULL==(loc=H5G_loc(loc_id))) + if(NULL == (loc = H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if (NULL==(child=H5I_object_verify(child_id,H5I_FILE))) + if(NULL == (child = H5I_object_verify(child_id,H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_MOUNT_DEFAULT; @@ -545,12 +531,12 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") /* Do the mount */ - if (H5F_mount(loc, name, child, plist_id, H5AC_dxpl_id)<0) + if(H5F_mount(loc, name, child, plist_id, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Fmount() */ /*------------------------------------------------------------------------- @@ -570,8 +556,6 @@ done: * Programmer: Robb Matzke * Tuesday, October 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -586,16 +570,16 @@ H5Funmount(hid_t loc_id, const char *name) /* Check args */ if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Unmount */ - if (H5F_unmount(loc, name, H5AC_dxpl_id)<0) + if (H5F_unmount(loc, name, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Funmount() */ /*------------------------------------------------------------------------- @@ -609,8 +593,6 @@ done: * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -658,8 +640,6 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj * Programmer: Quincey Koziol * Tues, July 19, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 2cce29e..c1717ca 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -433,8 +433,8 @@ H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f); #endif /* H5_HAVE_PARALLEL */ /* Functions than check file mounting information */ -H5_DLL htri_t H5F_is_mount(const H5F_t *file); -H5_DLL htri_t H5F_has_mount(const H5F_t *file); +H5_DLL hbool_t H5F_is_mount(const H5F_t *file); +H5_DLL hbool_t H5F_has_mount(const H5F_t *file); /* Functions than retrieve values set from the FCPL */ H5_DLL size_t H5F_sizeof_addr(const H5F_t *f); @@ -97,33 +97,8 @@ #define H5G_INIT_HEAP 8192 #define H5G_RESERVED_ATOMS 0 -/* - * During name lookups (see H5G_namei()) we sometimes want information about - * a symbolic link or a mount point. The normal operation is to follow the - * symbolic link or mount point and return information about its target. - */ -#define H5G_TARGET_NORMAL 0x0000 -#define H5G_TARGET_SLINK 0x0001 -#define H5G_TARGET_MOUNT 0x0002 - /* Local typedefs */ -/* Struct only used by change name callback function */ -typedef struct H5G_names_t { - H5G_entry_t *loc; - H5RS_str_t *src_name; - H5G_entry_t *src_loc; - H5RS_str_t *dst_name; - H5G_entry_t *dst_loc; - H5G_names_op_t op; -} H5G_names_t; - -/* Enum for H5G_namei actions */ -typedef enum { - H5G_NAMEI_TRAVERSE, /* Just traverse groups */ - H5G_NAMEI_INSERT /* Insert entry in group */ -} H5G_namei_act_t ; - /* * This table contains a list of object types, descriptions, and the * functions that determine if some object is a particular type. The table @@ -141,8 +116,6 @@ typedef struct H5G_typeinfo_t { static H5G_typeinfo_t *H5G_type_g = NULL; /*object typing info */ static size_t H5G_ntypes_g = 0; /*entries in type table */ static size_t H5G_atypes_g = 0; /*entries allocated */ -static char *H5G_comp_g = NULL; /*component buffer */ -static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */ /* Declare a free list to manage the H5G_t struct */ H5FL_DEFINE(H5G_t); @@ -157,22 +130,14 @@ H5FL_DEFINE(haddr_t); /* Private prototypes */ static herr_t H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*, hid_t), const char *desc); -static const char * H5G_component(const char *name, size_t *size_p); static const char * H5G_basename(const char *name, size_t *size_p); static char * H5G_normalize(const char *name); -static herr_t H5G_namei(const H5G_entry_t *loc_ent, const char *name, - const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, - unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, - H5G_entry_t *ent, hid_t dxpl_id); -static herr_t H5G_traverse_slink(H5G_entry_t *grp_ent/*in,out*/, - H5G_entry_t *obj_ent/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id); static H5G_t *H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id); static htri_t H5G_isa(H5G_entry_t *ent, hid_t dxpl_id); static htri_t H5G_link_isa(H5G_entry_t *ent, hid_t dxpl_id); static herr_t H5G_open_oid(H5G_t *grp, hid_t dxpl_id); -static H5G_t *H5G_rootof(H5F_t *f); static herr_t H5G_link(H5G_entry_t *cur_loc, const char *cur_name, - H5G_entry_t *new_loc, const char *new_name, H5G_link_t type, + H5G_entry_t *link_loc, const char *link_name, H5G_link_t type, unsigned namei_flags, hid_t dxpl_id); static herr_t H5G_get_num_objs(H5G_entry_t *grp, hsize_t *num_objs, hid_t dxpl_id); static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id); @@ -186,10 +151,6 @@ static int H5G_get_comment(H5G_entry_t *loc, const char *name, static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id); static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_id); -static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, - const H5RS_str_t *prefix_r); -static H5RS_str_t *H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); -static int H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key); /*------------------------------------------------------------------------- @@ -217,8 +178,6 @@ static int H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key); * Programmer: Robb Matzke * Wednesday, September 24, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -238,7 +197,7 @@ H5Gcreate(hid_t loc_id, const char *name, size_t size_hint) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") /* Create the group */ - if (NULL == (grp = H5G_create(loc, name, size_hint, H5AC_dxpl_id))) + if(NULL == (grp = H5G_create(loc, name, size_hint, H5AC_dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") if((ret_value = H5I_register(H5I_GROUP, grp)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") @@ -268,8 +227,6 @@ done: * Programmer: Robb Matzke * Wednesday, December 31, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -290,16 +247,16 @@ H5Gopen(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); /* Open the parent group, making sure it's a group */ - if (H5G_find(loc, name, &ent/*out*/, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found"); + if(H5G_find(loc, name, &ent/*out*/, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") /* Open the group */ - if ((grp = H5G_open(&ent, H5AC_dxpl_id))==NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group"); + if((grp = H5G_open(&ent, H5AC_dxpl_id)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an atom for the group */ - if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group"); + if((ret_value = H5I_register(H5I_GROUP, grp)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") done: if(ret_value < 0) { @@ -322,8 +279,6 @@ done: * Programmer: Robb Matzke * Wednesday, December 31, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -432,11 +387,11 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, /* Check for too high of a starting index (ex post facto :-) */ /* (Skipping exactly as many entries as are in the group is currently an error) */ - if(idx>0 && idx>=udata.final_ent) + if(idx > 0 && idx >= udata.final_ent) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified"); /* Set the index we stopped at */ - *idx_p=udata.final_ent; + *idx_p = udata.final_ent; done: FUNC_LEAVE_API(ret_value) @@ -470,7 +425,7 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) + if(H5G_get_type(loc,H5AC_ind_dxpl_id) != H5G_GROUP) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") if(!num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer") @@ -503,8 +458,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t @@ -517,12 +470,12 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) H5TRACE4("Zs","ihsz",loc_id,idx,name,size); /* Check args */ - if (NULL==(loc=H5G_loc (loc_id))) + if (NULL==(loc=H5G_loc(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) + if(H5G_get_type(loc, H5AC_ind_dxpl_id) != H5G_GROUP) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - /*call private function*/ + /* Call internal function*/ ret_value = H5G_get_objname_by_idx(loc, idx, name, size, H5AC_ind_dxpl_id); done: @@ -543,8 +496,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ #ifdef H5_WANT_H5_V1_4_COMPAT @@ -578,22 +529,21 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */ H5G_obj_t ret_value; - FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN); + FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN) H5TRACE2("Go","ih",loc_id,idx); /* Check args */ - if (NULL==(loc=H5G_loc (loc_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID"); - if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group"); + if(NULL==(loc=H5G_loc (loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") + if(H5G_get_type(loc, H5AC_ind_dxpl_id) != H5G_GROUP) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group") - /*call private function*/ + /* Call internal function*/ ret_value = (H5G_obj_t)H5G_get_objtype_by_idx(loc, idx, H5AC_ind_dxpl_id); done: - FUNC_LEAVE_API(ret_value); - -} + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_objtype_by_idx() */ #endif /*H5_WANT_H5_V1_4_COMPAT*/ @@ -611,45 +561,38 @@ done: * Programmer: Robb Matzke * Monday, April 6, 1998 * - * Modifications: - * - * Raymond Lu - * Thursday, April 18, 2002 - * *------------------------------------------------------------------------- */ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - H5G_entry_t *src_loc=NULL; - H5G_entry_t *dst_loc=NULL; + H5G_entry_t *src_loc = NULL; + H5G_entry_t *dst_loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Gmove2, FAIL) H5TRACE4("e","isis",src_loc_id,src_name,dst_loc_id,dst_name); - if (src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id))) + if(src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id))) + if(dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!dst_name || !*dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") - if(src_loc_id == H5G_SAME_LOC && dst_loc_id == H5G_SAME_LOC) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC"); - } else if(src_loc_id == H5G_SAME_LOC) { + if(src_loc_id == H5G_SAME_LOC && dst_loc_id == H5G_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC") + else if(src_loc_id == H5G_SAME_LOC) src_loc = dst_loc; - } - else if(dst_loc_id == H5G_SAME_LOC) { + else if(dst_loc_id == H5G_SAME_LOC) dst_loc = src_loc; - } else if(src_loc->file != dst_loc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file."); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - if(H5G_move(src_loc, src_name, dst_loc, dst_name, H5AC_dxpl_id)<0) + if(H5G_move(src_loc, src_name, dst_loc, dst_name, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to change object name") done: @@ -680,46 +623,41 @@ done: * Programmer: Robb Matzke * Monday, April 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name) + hid_t link_loc_id, const char *link_name) { H5G_entry_t *cur_loc = NULL; - H5G_entry_t *new_loc = NULL; + H5G_entry_t *link_loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Glink2, FAIL) - H5TRACE5("e","isGlis",cur_loc_id,cur_name,type,new_loc_id,new_name); + H5TRACE5("e","isGlis",cur_loc_id,cur_name,type,link_loc_id,link_name); /* Check arguments */ - if (cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id))) + if(cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (new_loc_id != H5G_SAME_LOC && NULL==(new_loc=H5G_loc(new_loc_id))) + if(link_loc_id != H5G_SAME_LOC && NULL==(link_loc=H5G_loc(link_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(type != H5G_LINK_HARD && type != H5G_LINK_SOFT) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type") if(!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!new_name || !*new_name) + if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") - if(cur_loc_id == H5G_SAME_LOC && new_loc_id == H5G_SAME_LOC) { + if(cur_loc_id == H5G_SAME_LOC && link_loc_id == H5G_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC") - } - else if(cur_loc_id == H5G_SAME_LOC) { - cur_loc = new_loc; - } - else if(new_loc_id == H5G_SAME_LOC) { - new_loc = cur_loc; - } - else if(cur_loc->file != new_loc->file) + else if(cur_loc_id == H5G_SAME_LOC) + cur_loc = link_loc; + else if(link_loc_id == H5G_SAME_LOC) + link_loc = cur_loc; + else if(cur_loc->file != link_loc->file) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - if(H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL, H5AC_dxpl_id) <0) + if(H5G_link(cur_loc, cur_name, link_loc, link_name, type, H5G_TARGET_NORMAL, H5AC_dxpl_id) <0) HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to create link") done: @@ -742,8 +680,6 @@ done: * Programmer: Robb Matzke * Monday, April 6, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -783,8 +719,6 @@ done: * Programmer: Robb Matzke * Monday, April 13, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -826,8 +760,6 @@ done: * Programmer: Robb Matzke * Monday, April 13, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1001,7 +933,6 @@ done: int H5G_term_interface(void) { - size_t i; int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_term_interface) @@ -1010,6 +941,8 @@ H5G_term_interface(void) if ((n = H5I_nmembers(H5I_GROUP))) { H5I_clear_group(H5I_GROUP, FALSE); } else { + size_t i; + /* Empty the object type table */ for (i=0; i<H5G_ntypes_g; i++) H5MM_xfree(H5G_type_g[i].desc); @@ -1020,8 +953,7 @@ H5G_term_interface(void) H5I_destroy_group(H5I_GROUP); /* Free the global component buffer */ - H5G_comp_g = H5MM_xfree(H5G_comp_g); - H5G_comp_alloc_g = 0; + H5G_namei_term_interface(); /* Mark closed */ H5_interface_initialize_g = 0; @@ -1125,7 +1057,7 @@ done: * *------------------------------------------------------------------------- */ -static const char * +const char * H5G_component(const char *name, size_t *size_p) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ @@ -1200,8 +1132,6 @@ H5G_basename(const char *name, size_t *size_p) * Programmer: Quincey Koziol * Saturday, August 16, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static char * @@ -1255,386 +1185,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_namei - * - * Purpose: Translates a name to a symbol table entry. - * - * If the specified name can be fully resolved, then this - * function returns the symbol table entry for the named object - * through the OBJ_ENT argument. The symbol table entry for the - * group containing the named object is returned through the - * GRP_ENT argument if it is non-null. However, if the name - * refers to the root object then the GRP_ENT will be - * initialized with an undefined object header address. The - * REST argument, if present, will point to the null terminator - * of NAME. - * - * If the specified name cannot be fully resolved, then OBJ_ENT - * is initialized with the undefined object header address. The - * REST argument will point into the NAME argument to the start - * of the component that could not be located. The GRP_ENT will - * contain the entry for the symbol table that was being - * searched at the time of the failure and will have an - * undefined object header address if the search failed at the - * root object. For instance, if NAME is `/foo/bar/baz' and the - * root directory exists and contains an entry for `foo', and - * foo is a group that contains an entry for bar, but bar is not - * a group, then the results will be that REST points to `baz', - * OBJ_ENT has an undefined object header address, and GRP_ENT - * is the symbol table entry for `bar' in `/foo'. - * - * Every file has a root group whose name is `/'. Components of - * a name are separated from one another by one or more slashes - * (/). Slashes at the end of a name are ignored. If the name - * begins with a slash then the search begins at the root group - * of the file containing LOC_ENT. Otherwise it begins at - * LOC_ENT. The component `.' is a no-op, but `..' is not - * understood by this function (unless it appears as an entry in - * the symbol table). - * - * Symbolic links are followed automatically, but if TARGET - * includes the H5G_TARGET_SLINK bit and the last component of - * the name is a symbolic link then that link is not followed. - * The *NLINKS value is decremented each time a link is followed - * and link traversal fails if the value would become negative. - * If NLINKS is the null pointer then a default value is used. - * - * Mounted files are handled by calling H5F_mountpoint() after - * each step of the translation. If the input argument to that - * function is a mount point then the argument shall be replaced - * with information about the root group of the mounted file. - * But if TARGET includes the H5G_TARGET_MOUNT bit and the last - * component of the name is a mount point then H5F_mountpoint() - * is not called and information about the mount point itself is - * returned. - * - * Errors: - * - * Return: Success: Non-negative if name can be fully resolved. - * See above for values of REST, GRP_ENT, and - * OBJ_ENT. NLINKS has been decremented for - * each symbolic link that was followed. - * - * Failure: Negative if the name could not be fully - * resolved. See above for values of REST, - * GRP_ENT, and OBJ_ENT. - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 11 1997 - * - * Modifications: - * Robb Matzke, 2002-03-28 - * The component name buffer on the stack has been replaced by - * a dynamically allocated buffer on the heap in order to - * remove limitations on the length of a name component. - * There are two reasons that the buffer pointer is global: - * (1) We want to be able to reuse the buffer without - * allocating and freeing it each time this function is - * called. - * (2) We need to be able to free it from H5G_term_interface() - * when the library terminates. - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Modified to deep copies of symbol table entries - * Added `id to name' support. - * - * Quincey Koziol, 2003-01-06 - * Added "action" and "ent" parameters to allow different actions when - * working on the last component of a name. (Specifically, this allows - * inserting an entry into a group, instead of trying to look it up) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, - H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, - unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, - H5G_entry_t *ent, hid_t dxpl_id) -{ - H5G_entry_t _grp_ent; /*entry for current group */ - H5G_entry_t _obj_ent; /*entry found */ - size_t nchars; /*component name length */ - int _nlinks = H5G_NLINKS; - const char *s = NULL; - unsigned null_obj; /* Flag to indicate this function was called with obj_ent set to NULL */ - unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */ - unsigned obj_copy = 0; /* Flag to indicate that the object entry is copied */ - unsigned group_copy = 0; /* Flag to indicate that the group entry is copied */ - unsigned last_comp = 0; /* Flag to indicate that a component is the last component in the name */ - unsigned did_insert = 0; /* Flag to indicate that H5G_stab_insert was called */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_namei); - - /* Set up "out" parameters */ - if (rest) - *rest = name; - if (!grp_ent) { - grp_ent = &_grp_ent; - null_grp = 1; - } /* end if */ - else - null_grp = 0; - if (!obj_ent) { - obj_ent = &_obj_ent; - null_obj = 1; - } /* end if */ - else - null_obj = 0; - if (!nlinks) - nlinks = &_nlinks; - - /* Check args */ - if (!name || !*name) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given"); - if (!loc_ent) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group"); - - /* - * Where does the searching start? For absolute names it starts at the - * root of the file; for relative names it starts at CWG. - */ - /* Check if we need to get the root group's entry */ - if ('/' == *name) { - H5G_t *tmp_grp; /* Temporary pointer to root group of file */ - - tmp_grp=H5G_rootof(loc_ent->file); - assert(tmp_grp); - - /* Set the location entry to the root group's entry*/ - loc_ent=&(tmp_grp->ent); - } /* end if */ - - /* Deep copy of the symbol table entry (duplicates strings) */ - if (H5G_ent_copy(obj_ent, loc_ent,H5G_COPY_DEEP)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry"); - obj_copy = 1; - - H5G_ent_reset(grp_ent); - - /* traverse the name */ - while ((name = H5G_component(name, &nchars)) && *name) { - /* Update the "rest of name" pointer */ - if (rest) - *rest = name; - - /* - * Copy the component name into a null-terminated buffer so - * we can pass it down to the other symbol table functions. - */ - if (nchars+1 > H5G_comp_alloc_g) { - H5G_comp_alloc_g = MAX3(1024, 2*H5G_comp_alloc_g, nchars+1); - H5G_comp_g = H5MM_realloc(H5G_comp_g, H5G_comp_alloc_g); - if (!H5G_comp_g) { - H5G_comp_alloc_g = 0; - HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "unable to allocate component buffer"); - } - } - HDmemcpy(H5G_comp_g, name, nchars); - H5G_comp_g[nchars] = '\0'; - - /* - * The special name `.' is a no-op. - */ - if ('.' == H5G_comp_g[0] && !H5G_comp_g[1]) { - name += nchars; - continue; - } - - /* - * Advance to the next component of the name. - */ - /* If we've already copied a new entry into the group entry, - * it needs to be freed before overwriting it with another entry - */ - if(group_copy) - H5G_free_ent_name(grp_ent); - - /* Transfer "ownership" of the entry's information to the group entry */ - H5G_ent_copy(grp_ent,obj_ent,H5G_COPY_SHALLOW); - H5G_ent_reset(obj_ent); - - /* Set flag that we've copied a new entry into the group entry */ - group_copy =1; - - /* Check if this is the last component of the name */ - if(!((s=H5G_component(name+nchars, NULL)) && *s)) - last_comp=1; - - switch(action) { - case H5G_NAMEI_TRAVERSE: - if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { - /* - * Component was not found in the current symbol table, possibly - * because GRP_ENT isn't a symbol table. - */ - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); - } - break; - - case H5G_NAMEI_INSERT: - if(!last_comp) { - if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { - /* - * Component was not found in the current symbol table, possibly - * because GRP_ENT isn't a symbol table. - */ - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); - } - } /* end if */ - else { - did_insert = 1; - if (H5G_stab_insert(grp_ent, H5G_comp_g, ent, TRUE, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert name"); - HGOTO_DONE(SUCCEED); - } /* end else */ - break; - } /* end switch */ - - /* - * If we found a symbolic link then we should follow it. But if this - * is the last component of the name and the H5G_TARGET_SLINK bit of - * TARGET is set then we don't follow it. - */ - if(H5G_CACHED_SLINK==obj_ent->type && - (0==(target & H5G_TARGET_SLINK) || !last_comp)) { - if ((*nlinks)-- <= 0) - HGOTO_ERROR (H5E_SYM, H5E_SLINK, FAIL, "too many links"); - if (H5G_traverse_slink (grp_ent, obj_ent, nlinks, dxpl_id)<0) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link traversal failed"); - } - - /* - * Resolve mount points to the mounted group. Do not do this step if - * the H5G_TARGET_MOUNT bit of TARGET is set and this is the last - * component of the name. - */ - if (0==(target & H5G_TARGET_MOUNT) || !last_comp) - H5F_mountpoint(obj_ent/*in,out*/); - - /* next component */ - name += nchars; - } /* end while */ - - /* Update the "rest of name" pointer */ - if (rest) - *rest = name; /*final null */ - - /* If this was an insert, make sure that the insert function was actually - * called (this catches no-op names like "." and "/") */ - if(action == H5G_NAMEI_INSERT && !did_insert) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group already exists"); - -done: - /* If we started with a NULL obj_ent, free the entry information */ - if(null_obj || (ret_value < 0 && obj_copy)) - H5G_free_ent_name(obj_ent); - /* If we started with a NULL grp_ent and we copied something into it, free the entry information */ - if(null_grp && group_copy) - H5G_free_ent_name(grp_ent); - - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5G_traverse_slink - * - * Purpose: Traverses symbolic link. The link head appears in the group - * whose entry is GRP_ENT and the link head entry is OBJ_ENT. - * - * Return: Success: Non-negative, OBJ_ENT will contain information - * about the object to which the link points and - * GRP_ENT will contain the information about - * the group in which the link tail appears. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Friday, April 10, 1998 - * - * Modifications: - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added `id to name' support. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/, - H5G_entry_t *obj_ent/*in,out*/, - int *nlinks/*in,out*/, hid_t dxpl_id) -{ - H5O_stab_t stab_mesg; /*info about local heap */ - const char *clv = NULL; /*cached link value */ - char *linkval = NULL; /*the copied link value */ - H5G_entry_t tmp_grp_ent; /* Temporary copy of group entry */ - H5RS_str_t *tmp_user_path_r=NULL, *tmp_canon_path_r=NULL; /* Temporary pointer to object's user path & canonical path */ - const H5HL_t *heap; - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_slink); - - /* Portably initialize the temporary group entry */ - H5G_ent_reset(&tmp_grp_ent); - - /* Get the link value */ - if (NULL==H5O_read (grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); - - if (NULL == (heap = H5HL_protect(grp_ent->file, dxpl_id, stab_mesg.heap_addr))) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") - - clv = H5HL_offset_into(grp_ent->file, heap, obj_ent->cache.slink.lval_offset); - - linkval = H5MM_xstrdup (clv); - assert(linkval); - - if (H5HL_unprotect(grp_ent->file, dxpl_id, heap, stab_mesg.heap_addr) < 0) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") - - /* Hold the entry's name (& old_name) to restore later */ - tmp_user_path_r=obj_ent->user_path_r; - obj_ent->user_path_r=NULL; - tmp_canon_path_r=obj_ent->canon_path_r; - obj_ent->canon_path_r=NULL; - - /* Free the names for the group entry */ - H5G_free_ent_name(grp_ent); - - /* Clone the group entry, so we can track the names properly */ - H5G_ent_copy(&tmp_grp_ent,grp_ent,H5G_COPY_DEEP); - - /* Traverse the link */ - if (H5G_namei (&tmp_grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link"); - - /* Free the entry's names, we will use the original name for the object */ - H5G_free_ent_name(obj_ent); - - /* Restore previous name for object */ - obj_ent->user_path_r = tmp_user_path_r; - tmp_user_path_r=NULL; - obj_ent->canon_path_r = tmp_canon_path_r; - tmp_canon_path_r=NULL; - -done: - /* Error cleanup */ - if(tmp_user_path_r) - H5RS_decr(tmp_user_path_r); - if(tmp_canon_path_r) - H5RS_decr(tmp_canon_path_r); - - /* Release cloned copy of group entry */ - H5G_free_ent_name(&tmp_grp_ent); - - H5MM_xfree (linkval); - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- * Function: H5G_mkroot * * Purpose: Creates a root group in an empty file and opens it. If a @@ -1653,7 +1203,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) +H5G_mkroot(H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) { H5G_entry_t new_root; /*new root object */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1673,7 +1223,7 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) * If there is no root object then create one. The root group always starts * with a hard link count of one since it's pointed to by the boot block. */ - if (!ent) { + if(!ent) { ent = &new_root; H5G_ent_reset(ent); if (H5G_stab_create (f, dxpl_id, (size_t)H5G_SIZE_HINT, ent/*out*/)<0) @@ -1684,16 +1234,12 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) /* * Open the root object as a group. */ - if (H5O_open (ent)<0) + if(H5O_open(ent) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group") } /* end else */ /* Create the path names for the root group's entry */ - ent->user_path_r=H5RS_create("/"); - assert(ent->user_path_r); - ent->canon_path_r=H5RS_create("/"); - assert(ent->canon_path_r); - ent->user_path_hidden=0; + H5G_name_init(ent, "/"); /* * Create the group pointer. Also decrement the open object count so we @@ -1708,7 +1254,7 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent) } /* end if */ /* Shallow copy (take ownership) of the group entry object */ - if(H5G_ent_copy(&(f->shared->root_grp->ent), ent, H5G_COPY_SHALLOW)<0) + if(H5G_ent_copy(&(f->shared->root_grp->ent), ent, H5_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy group entry") f->shared->root_grp->shared->fo_count = 1; @@ -1788,7 +1334,7 @@ done: if(stab_init) { if(H5O_close(&(grp->ent))<0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header") - if(H5O_delete(file, dxpl_id,grp->ent.header)<0) + if(H5O_delete(file, dxpl_id, grp->ent.header) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ if(grp != NULL) { @@ -1906,11 +1452,11 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group") /* Shallow copy (take ownership) of the group entry object */ - if(H5G_ent_copy(&(grp->ent), ent, H5G_COPY_SHALLOW)<0) + if(H5G_ent_copy(&(grp->ent), ent, H5_COPY_SHALLOW)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy group entry") /* Check if group was already open */ - if((shared_fo=H5FO_opened(grp->ent.file, grp->ent.header))==NULL) { + if((shared_fo = H5FO_opened(grp->ent.file, grp->ent.header))==NULL) { /* Clear any errors from H5FO_opened() */ H5E_clear(); @@ -2070,8 +1616,7 @@ H5G_close(H5G_t *grp) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") } /* end if */ - if(H5G_free_ent_name(&(grp->ent))<0) - { + if(H5G_name_free(&(grp->ent))<0) { H5FL_FREE (H5G_t,grp); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name") } @@ -2097,8 +1642,6 @@ done: * Programmer: James Laird * Tuesday, September 7, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -2134,11 +1677,9 @@ done: * Programmer: Robb Matzke * Tuesday, October 13, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ -static H5G_t * +H5G_t * H5G_rootof(H5F_t *f) { FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof) @@ -2180,7 +1721,6 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent, hid_t dxpl_id) if (H5G_namei(loc, name, NULL, NULL, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_INSERT, ent, dxpl_id)<0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_insert() */ @@ -2393,16 +1933,11 @@ done: * Programmer: Robb Matzke * Monday, April 6, 1998 * - * Modifications: - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002 - * Added `id to name' support. - * *------------------------------------------------------------------------- */ static herr_t -H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, - const char *new_name, H5G_link_t type, unsigned namei_flags, hid_t dxpl_id) +H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *link_loc, + const char *link_name, H5G_link_t type, unsigned namei_flags, hid_t dxpl_id) { H5G_entry_t cur_obj; /*entry for the link tail */ unsigned cur_obj_init=0; /* Flag to indicate that the current object is initialized */ @@ -2410,7 +1945,7 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, H5O_stab_t stab_mesg; /*symbol table message */ const char *rest = NULL; /*last component of new name */ char *norm_cur_name = NULL; /* Pointer to normalized current name */ - char *norm_new_name = NULL; /* Pointer to normalized current name */ + char *norm_link_name = NULL; /* Pointer to normalized current name */ size_t nchars; /*characters in component */ size_t offset; /*offset to sym-link value */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2419,43 +1954,51 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, /* Check args */ HDassert(cur_loc); - HDassert(new_loc); + HDassert(link_loc); HDassert(cur_name && *cur_name); - HDassert(new_name && *new_name); + HDassert(link_name && *link_name); /* Get normalized copies of the current and new names */ if((norm_cur_name = H5G_normalize(cur_name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name") - if((norm_new_name = H5G_normalize(new_name)) == NULL) + if((norm_link_name = H5G_normalize(link_name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name") switch(type) { + case H5G_LINK_HARD: + if(H5G_namei(cur_loc, norm_cur_name, NULL, NULL, &cur_obj, namei_flags, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found") + cur_obj_init = 1; /* Indicate that the cur_obj struct is initialized */ + if(H5G_insert(link_loc, norm_link_name, &cur_obj, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object") + break; + case H5G_LINK_SOFT: /* * Lookup the the new_name so we can get the group which will contain * the new entry. The entry shouldn't exist yet. */ - if (H5G_namei(new_loc, norm_new_name, &rest, &grp_ent, NULL, - H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)>=0) - HGOTO_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists"); + if(H5G_namei(link_loc, norm_link_name, &rest, &grp_ent, NULL, + H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id) >= 0) + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists") H5E_clear (); /*it's okay that we didn't find it*/ - rest = H5G_component (rest, &nchars); + rest = H5G_component(rest, &nchars); /* * There should be one component left. Make sure it's null * terminated and that `rest' points to it. */ - assert(!rest[nchars]); + HDassert(!rest[nchars]); /* * Add the link-value to the local heap for the symbol table which * will contain the link. */ - if (NULL==H5O_read (&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address"); - if ((size_t)(-1)==(offset=H5HL_insert (grp_ent.file, dxpl_id, + if(NULL == H5O_read(&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address") + if((size_t)(-1) == (offset = H5HL_insert (grp_ent.file, dxpl_id, stab_mesg.heap_addr, HDstrlen(norm_cur_name)+1, norm_cur_name))) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap"); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap") H5O_reset (H5O_STAB_ID, &stab_mesg); /* @@ -2466,7 +2009,7 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, cur_obj.file = grp_ent.file; cur_obj.type = H5G_CACHED_SLINK; cur_obj.cache.slink.lval_offset = offset; - cur_obj_init=1; /* Indicate that the cur_obj struct is initialized */ + cur_obj_init = 1; /* Indicate that the cur_obj struct is initialized */ /* * Insert the link head in the symbol table. This shouldn't ever @@ -2477,16 +2020,8 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, * * Note: We don't increment the link count of the destination object */ - if (H5G_stab_insert (&grp_ent, rest, &cur_obj, FALSE, dxpl_id)<0) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object"); - break; - - case H5G_LINK_HARD: - if (H5G_namei(cur_loc, norm_cur_name, NULL, NULL, &cur_obj, namei_flags, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)<0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found"); - cur_obj_init=1; /* Indicate that the cur_obj struct is initialized */ - if (H5G_insert (new_loc, norm_new_name, &cur_obj, dxpl_id)<0) - HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object"); + if(H5G_stab_insert(&grp_ent, rest, &cur_obj, FALSE, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object") break; default: @@ -2496,17 +2031,17 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc, done: /* Free the group's ID to name buffer, if creating a soft link */ if(type == H5G_LINK_SOFT) - H5G_free_ent_name(&grp_ent); + H5G_name_free(&grp_ent); /* Free the ID to name buffer */ if(cur_obj_init) - H5G_free_ent_name(&cur_obj); + H5G_name_free(&cur_obj); /* Free the normalized path names */ if(norm_cur_name) H5MM_xfree(norm_cur_name); - if(norm_new_name) - H5MM_xfree(norm_new_name); + if(norm_link_name) + H5MM_xfree(norm_link_name); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_link() */ @@ -2654,8 +2189,8 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link, done: /* Free the ID to name buffers */ - H5G_free_ent_name(&grp_ent); - H5G_free_ent_name(&obj_ent); + H5G_name_free(&grp_ent); + H5G_name_free(&obj_ent); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_objinfo() */ @@ -2675,8 +2210,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -2847,7 +2380,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, hid_t dxpl_id) +H5G_linkval(H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, hid_t dxpl_id) { const char *s = NULL; H5G_entry_t grp_ent, obj_ent; @@ -2888,8 +2421,8 @@ H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/, done: /* Free the ID to name buffers */ - H5G_free_ent_name(&grp_ent); - H5G_free_ent_name(&obj_ent); + H5G_name_free(&grp_ent); + H5G_name_free(&obj_ent); FUNC_LEAVE_NOAPI(ret_value) } /* H5G_linkval() */ @@ -2927,14 +2460,14 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf, hid_t dxpl_ /* Add the new message */ if(buf && *buf) { comment.s = H5MM_xstrdup(buf); - if (H5O_modify(&obj_ent, H5O_NAME_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &comment, dxpl_id)<0) + if(H5O_modify(&obj_ent, H5O_NAME_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &comment, dxpl_id)<0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message") H5O_reset(H5O_NAME_ID, &comment); } /* end if */ done: /* Free the ID to name buffer */ - H5G_free_ent_name(&obj_ent); + H5G_name_free(&obj_ent); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_set_comment() */ @@ -2971,8 +2504,8 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, h /* Get the message */ comment.s = NULL; - if (NULL==H5O_read(&obj_ent, H5O_NAME_ID, 0, &comment, dxpl_id)) { - if (buf && bufsize>0) + if(NULL == H5O_read(&obj_ent, H5O_NAME_ID, 0, &comment, dxpl_id)) { + if(buf && bufsize > 0) buf[0] = '\0'; ret_value = 0; } else { @@ -2984,7 +2517,7 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, h done: /* Free the ID to name buffer */ - H5G_free_ent_name(&obj_ent); + H5G_name_free(&obj_ent); FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_comment() */ @@ -3043,13 +2576,13 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table") /* Search the open IDs and replace names for unlinked object */ - if (H5G_replace_name(obj_type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0) + if (H5G_name_replace(obj_type, &obj_ent, NULL, NULL, H5G_NAME_UNLINK )<0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") done: /* Free the ID to name buffers */ - H5G_free_ent_name(&grp_ent); - H5G_free_ent_name(&obj_ent); + H5G_name_free(&grp_ent); + H5G_name_free(&obj_ent); /* Free the normalized path name */ if(norm_name) @@ -3076,11 +2609,10 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_id) { H5G_stat_t sb; - char *linkval=NULL; - size_t lv_size=32; - H5G_entry_t obj_ent; /* Object entry for object being moved */ - H5RS_str_t *src_name_r; /* Ref-counted version of src name */ - H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ + char *linkval = NULL; + size_t lv_size = 32; + H5G_entry_t obj_ent; /* Object entry for object being moved */ + H5RS_str_t *dst_name_r = NULL; /* Ref-counted version of dest name */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5G_move) @@ -3122,23 +2654,23 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc, * This has to be done here because H5G_link and H5G_unlink have * internal object entries, and do not modify the entries list */ - if (H5G_namei(src_loc, src_name, NULL, NULL, &obj_ent, H5G_TARGET_NORMAL|H5G_TARGET_SLINK, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) - HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link"); - src_name_r=H5RS_wrap(src_name); - assert(src_name_r); - dst_name_r=H5RS_wrap(dst_name); - assert(dst_name_r); - if (H5G_replace_name(sb.type, &obj_ent, src_name_r, src_loc, dst_name_r, dst_loc, OP_MOVE )<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name "); - H5RS_decr(src_name_r); - H5RS_decr(dst_name_r); - H5G_free_ent_name(&obj_ent); + if(H5G_namei(src_loc, src_name, NULL, NULL, &obj_ent, H5G_TARGET_NORMAL|H5G_TARGET_SLINK, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") + dst_name_r = H5RS_wrap(dst_name); + HDassert(dst_name_r); + if(H5G_name_replace(sb.type, &obj_ent, dst_name_r, dst_loc, H5G_NAME_MOVE) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ") + H5G_name_free(&obj_ent); /* Remove the old name */ if(H5G_unlink(src_loc, src_name, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink old object name") done: + /* Cleanup */ + if(dst_name_r) + H5RS_decr(dst_name_r); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_move() */ @@ -3184,7 +2716,7 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id) * doesn't already exist. */ if (H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)>=0) { - H5G_free_ent_name(&grp_ent); + H5G_name_free(&grp_ent); HGOTO_ERROR(H5E_SYM, H5E_EXISTS, NULL, "name already exists"); } /* end if */ H5E_clear(); @@ -3194,7 +2726,7 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id) assert(*rest && size>0); rest = H5G_component(rest+size, NULL); if (*rest) { - H5G_free_ent_name(&grp_ent); + H5G_name_free(&grp_ent); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "insertion point not found"); } /* end if */ @@ -3202,11 +2734,11 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id) ret_value=grp_ent.file; /* Free the ID to name buffer */ - H5G_free_ent_name(&grp_ent); + H5G_name_free(&grp_ent); } /* end if */ else /* Use the location's file */ - ret_value=loc->file; + ret_value = loc->file; done: FUNC_LEAVE_NOAPI(ret_value) @@ -3245,7 +2777,7 @@ H5G_free_grp_name(H5G_t *grp) HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "cannot get entry"); /* Free the entry */ - H5G_free_ent_name(ent); + H5G_name_free(ent); done: FUNC_LEAVE_NOAPI(ret_value) @@ -3253,604 +2785,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_free_ent_name - * - * Purpose: Free the 'ID to name' buffers. - * - * Return: Success - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: August 22, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_free_ent_name(H5G_entry_t *ent) -{ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_free_ent_name, FAIL); - - /* Check args */ - assert(ent); - - if(ent->user_path_r) { - H5RS_decr(ent->user_path_r); - ent->user_path_r=NULL; - } /* end if */ - if(ent->canon_path_r) { - H5RS_decr(ent->canon_path_r); - ent->canon_path_r=NULL; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5G_replace_name - * - * Purpose: Search the list of open IDs and replace names according to a - * particular operation. The operation occured on the LOC - * entry, which had SRC_NAME previously. The new name (if there - * is one) is DST_NAME. Additional entry location information - * (currently only needed for the 'move' operation) is passed - * in SRC_LOC and DST_LOC. - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 11, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_replace_name(int type, H5G_entry_t *loc, - H5RS_str_t *src_name, H5G_entry_t *src_loc, - H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op ) -{ - H5G_names_t names; /* Structure to hold operation information for callback */ - unsigned search_group=0; /* Flag to indicate that groups are to be searched */ - unsigned search_dataset=0; /* Flag to indicate that datasets are to be searched */ - unsigned search_datatype=0; /* Flag to indicate that datatypes are to be searched */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5G_replace_name, FAIL); - - /* Set up common information for callback */ - names.src_name=src_name; - names.dst_name=dst_name; - names.loc=loc; - names.src_loc=src_loc; - names.dst_loc=dst_loc; - names.op=op; - - /* Determine which types of IDs need to be operated on */ - switch(type) { - /* Object is a group */ - case H5G_GROUP: - /* Search and replace names through group IDs */ - search_group=1; - break; - - /* Object is a dataset */ - case H5G_DATASET: - /* Search and replace names through dataset IDs */ - search_dataset=1; - break; - - /* Object is a named datatype */ - case H5G_TYPE: - /* Search and replace names through datatype IDs */ - search_datatype=1; - break; - - case H5G_UNKNOWN: /* We pass H5G_UNKNOWN as object type when we need to search all IDs */ - case H5G_LINK: /* Symbolic links might resolve to any object, so we need to search all IDs */ - /* Check if we will need to search groups */ - if(H5I_nmembers(H5I_GROUP)>0) - search_group=1; - - /* Check if we will need to search datasets */ - if(H5I_nmembers(H5I_DATASET)>0) - search_dataset=1; - - /* Check if we will need to search datatypes */ - if(H5I_nmembers(H5I_DATATYPE)>0) - search_datatype=1; - break; - - default: - HGOTO_ERROR (H5E_DATATYPE, H5E_BADTYPE, FAIL, "not valid object type"); - } /* end switch */ - - /* Search through group IDs */ - if(search_group) - H5I_search(H5I_GROUP, H5G_replace_ent, &names); - - /* Search through dataset IDs */ - if(search_dataset) - H5I_search(H5I_DATASET, H5G_replace_ent, &names); - - /* Search through datatype IDs */ - if(search_datatype) - H5I_search(H5I_DATATYPE, H5G_replace_ent, &names); - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5G_common_path - * - * Purpose: Determine if one path is a valid prefix of another path - * - * Return: TRUE for valid prefix, FALSE for not a valid prefix, FAIL - * on error - * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu - * - * Date: September 24, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static htri_t -H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r) -{ - const char *fullpath; /* Pointer to actual fullpath string */ - const char *prefix; /* Pointer to actual prefix string */ - size_t nchars1,nchars2; /* Number of characters in components */ - htri_t ret_value=FALSE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_common_path); - - /* Get component of each name */ - fullpath=H5RS_get_str(fullpath_r); - assert(fullpath); - fullpath=H5G_component(fullpath,&nchars1); - assert(fullpath); - prefix=H5RS_get_str(prefix_r); - assert(prefix); - prefix=H5G_component(prefix,&nchars2); - assert(prefix); - - /* Check if we have a real string for each component */ - while(*fullpath && *prefix) { - /* Check that the components we found are the same length */ - if(nchars1==nchars2) { - /* Check that the two components are equal */ - if(HDstrncmp(fullpath,prefix,nchars1)==0) { - /* Advance the pointers in the names */ - fullpath+=nchars1; - prefix+=nchars2; - - /* Get next component of each name */ - fullpath=H5G_component(fullpath,&nchars1); - assert(fullpath); - prefix=H5G_component(prefix,&nchars2); - assert(prefix); - } /* end if */ - else - HGOTO_DONE(FALSE); - } /* end if */ - else - HGOTO_DONE(FALSE); - } /* end while */ - - /* If we reached the end of the prefix path to check, it must be a valid prefix */ - if(*prefix=='\0') - ret_value=TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5G_build_fullpath - * - * Purpose: Build a full path from a prefix & base pair of reference counted - * strings - * - * Return: Pointer to reference counted string on success, NULL on error - * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu - * - * Date: August 19, 2005 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static H5RS_str_t * -H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r) -{ - const char *prefix; /* Pointer to raw string of prefix */ - const char *name; /* Pointer to raw string of name */ - char *full_path; /* Full user path built */ - size_t path_len; /* Length of the path */ - unsigned need_sep; /* Flag to indicate if separator is needed */ - H5RS_str_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_build_fullpath) - - /* Get the pointer to the prefix */ - prefix=H5RS_get_str(prefix_r); - - /* Get the length of the prefix */ - path_len=HDstrlen(prefix); - - /* Determine if there is a trailing separator in the name */ - if(prefix[path_len-1]=='/') - need_sep=0; - else - need_sep=1; - - /* Get the pointer to the raw src user path */ - name=H5RS_get_str(name_r); - - /* Add in the length needed for the '/' separator and the relative path */ - path_len+=HDstrlen(name)+need_sep; - - /* Allocate space for the path */ - if(NULL==(full_path = H5FL_BLK_MALLOC(str_buf,path_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Build full path */ - HDstrcpy(full_path,prefix); - if(need_sep) - HDstrcat(full_path,"/"); - HDstrcat(full_path,name); - - /* Create reference counted string for path */ - ret_value=H5RS_own(full_path); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_build_fullpath() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_replace_ent - * - * Purpose: H5I_search callback function to replace group entry names - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: June 5, 2002 - * - * Comments: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key) -{ - const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ - H5G_entry_t *ent = NULL; /* Group entry for object that the ID refers to */ - H5F_t *top_ent_file; /* Top file in entry's mounted file chain */ - H5F_t *top_loc_file; /* Top file in location's mounted file chain */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_replace_ent); - - assert(obj_ptr); - - /* Get the symbol table entry */ - switch(H5I_get_type(obj_id)) { - case H5I_GROUP: - ent = H5G_entof((H5G_t*)obj_ptr); - break; - - case H5I_DATASET: - ent = H5D_entof((H5D_t*)obj_ptr); - break; - - case H5I_DATATYPE: - /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t*)obj_ptr)) - HGOTO_DONE(SUCCEED); /* Do not exit search over IDs */ - - ent = H5T_entof((H5T_t*)obj_ptr); - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object"); - } /* end switch */ - assert(ent); - - switch(names->op) { - /*------------------------------------------------------------------------- - * OP_MOUNT - *------------------------------------------------------------------------- - */ - case OP_MOUNT: - if(ent->user_path_r) { - if(ent->file->mtab.parent && H5RS_cmp(ent->user_path_r,ent->canon_path_r)) { - /* Find the "top" file in the chain of mounted files */ - top_ent_file=ent->file->mtab.parent; - while(top_ent_file->mtab.parent!=NULL) - top_ent_file=top_ent_file->mtab.parent; - } /* end if */ - else - top_ent_file=ent->file; - - /* Check for entry being in correct file (or mounted file) */ - if(top_ent_file->shared == names->loc->file->shared) { - /* Check if the source is along the entry's path */ - /* (But not actually the entry itself) */ - if(H5G_common_path(ent->user_path_r,names->src_name) && - H5RS_cmp(ent->user_path_r,names->src_name)!=0) { - /* Hide the user path */ - ent->user_path_hidden++; - } /* end if */ - } /* end if */ - } /* end if */ - break; - - /*------------------------------------------------------------------------- - * OP_UNMOUNT - *------------------------------------------------------------------------- - */ - case OP_UNMOUNT: - if(ent->user_path_r) { - if(ent->file->mtab.parent) { - /* Find the "top" file in the chain of mounted files for the entry */ - top_ent_file=ent->file->mtab.parent; - while(top_ent_file->mtab.parent!=NULL) - top_ent_file=top_ent_file->mtab.parent; - } /* end if */ - else - top_ent_file=ent->file; - - if(names->loc->file->mtab.parent) { - /* Find the "top" file in the chain of mounted files for the location */ - top_loc_file=names->loc->file->mtab.parent; - while(top_loc_file->mtab.parent!=NULL) - top_loc_file=top_loc_file->mtab.parent; - } /* end if */ - else - top_loc_file=names->loc->file; - - /* If the ID's entry is not in the file we operated on, skip it */ - if(top_ent_file->shared == top_loc_file->shared) { - if(ent->user_path_hidden) { - if(H5G_common_path(ent->user_path_r,names->src_name)) { - /* Un-hide the user path */ - ent->user_path_hidden--; - } /* end if */ - } /* end if */ - else { - if(H5G_common_path(ent->user_path_r,names->src_name)) { - /* Free user path */ - H5RS_decr(ent->user_path_r); - ent->user_path_r=NULL; - } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ - break; - - /*------------------------------------------------------------------------- - * OP_UNLINK - *------------------------------------------------------------------------- - */ - case OP_UNLINK: - /* If the ID's entry is not in the file we operated on, skip it */ - if(ent->file->shared == names->loc->file->shared && - names->loc->canon_path_r && ent->canon_path_r && ent->user_path_r) { - /* Check if we are referring to the same object */ - if(H5F_addr_eq(ent->header, names->loc->header)) { - /* Check if the object was opened with the same canonical path as the one being moved */ - if(H5RS_cmp(ent->canon_path_r,names->loc->canon_path_r)==0) { - /* Free user path */ - H5RS_decr(ent->user_path_r); - ent->user_path_r=NULL; - } /* end if */ - } /* end if */ - else { - /* Check if the location being unlinked is in the canonical path for the current object */ - if(H5G_common_path(ent->canon_path_r,names->loc->canon_path_r)) { - /* Free user path */ - H5RS_decr(ent->user_path_r); - ent->user_path_r=NULL; - } /* end if */ - } /* end else */ - } /* end if */ - break; - - /*------------------------------------------------------------------------- - * OP_MOVE - *------------------------------------------------------------------------- - */ - case OP_MOVE: /* H5Gmove case, check for relative names case */ - /* If the ID's entry is not in the file we operated on, skip it */ - if(ent->file->shared == names->loc->file->shared) { - if(ent->user_path_r && names->loc->user_path_r && - names->src_loc->user_path_r && names->dst_loc->user_path_r) { - H5RS_str_t *src_path_r; /* Full user path of source name */ - H5RS_str_t *dst_path_r; /* Full user path of destination name */ - H5RS_str_t *canon_src_path_r; /* Copy of canonical part of source path */ - H5RS_str_t *canon_dst_path_r; /* Copy of canonical part of destination path */ - - /* Sanity check */ - HDassert(names->src_name); - HDassert(names->dst_name); - - /* Make certain that the source and destination names are full (not relative) paths */ - if(*(H5RS_get_str(names->src_name))!='/') { - /* Create reference counted string for full src path */ - if((src_path_r = H5G_build_fullpath(names->src_loc->user_path_r, names->src_name)) == NULL) - HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build source path name") - } /* end if */ - else - src_path_r=H5RS_dup(names->src_name); - if(*(H5RS_get_str(names->dst_name))!='/') { - /* Create reference counted string for full dst path */ - if((dst_path_r = H5G_build_fullpath(names->dst_loc->user_path_r, names->dst_name)) == NULL) - HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build destination path name") - } /* end if */ - else - dst_path_r=H5RS_dup(names->dst_name); - - /* Get the canonical parts of the source and destination names */ - - /* Check if the object being moved was accessed through a mounted file */ - if(H5RS_cmp(names->loc->user_path_r,names->loc->canon_path_r)!=0) { - size_t non_canon_name_len; /* Length of non-canonical part of name */ - - /* Get current string lengths */ - non_canon_name_len=H5RS_len(names->loc->user_path_r)-H5RS_len(names->loc->canon_path_r); - - canon_src_path_r=H5RS_create(H5RS_get_str(src_path_r)+non_canon_name_len); - canon_dst_path_r=H5RS_create(H5RS_get_str(dst_path_r)+non_canon_name_len); - } /* end if */ - else { - canon_src_path_r=H5RS_dup(src_path_r); - canon_dst_path_r=H5RS_dup(dst_path_r); - } /* end else */ - - /* Check if the link being changed in the file is along the canonical path for this object */ - if(H5G_common_path(ent->canon_path_r,canon_src_path_r)) { - size_t user_dst_len; /* Length of destination user path */ - size_t canon_dst_len; /* Length of destination canonical path */ - const char *old_user_path; /* Pointer to previous user path */ - char *new_user_path; /* Pointer to new user path */ - char *new_canon_path; /* Pointer to new canonical path */ - const char *tail_path; /* Pointer to "tail" of path */ - size_t tail_len; /* Pointer to "tail" of path */ - char *src_canon_prefix; /* Pointer to source canonical path prefix of component which is moving */ - size_t src_canon_prefix_len;/* Length of the source canonical path prefix */ - char *dst_canon_prefix; /* Pointer to destination canonical path prefix of component which is moving */ - size_t dst_canon_prefix_len;/* Length of the destination canonical path prefix */ - char *user_prefix; /* Pointer to user path prefix of component which is moving */ - size_t user_prefix_len; /* Length of the user path prefix */ - char *src_comp; /* The source name of the component which is actually changing */ - char *dst_comp; /* The destination name of the component which is actually changing */ - const char *canon_src_path; /* pointer to canonical part of source path */ - const char *canon_dst_path; /* pointer to canonical part of destination path */ - - /* Get the pointers to the raw strings */ - canon_src_path=H5RS_get_str(canon_src_path_r); - canon_dst_path=H5RS_get_str(canon_dst_path_r); - - /* Get the source & destination components */ - src_comp=HDstrrchr(canon_src_path,'/'); - assert(src_comp); - dst_comp=HDstrrchr(canon_dst_path,'/'); - assert(dst_comp); - - /* Find the canonical prefixes for the entry */ - src_canon_prefix_len=HDstrlen(canon_src_path)-HDstrlen(src_comp); - if(NULL==(src_canon_prefix = H5MM_malloc(src_canon_prefix_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - HDstrncpy(src_canon_prefix,canon_src_path,src_canon_prefix_len); - src_canon_prefix[src_canon_prefix_len]='\0'; - - dst_canon_prefix_len=HDstrlen(canon_dst_path)-HDstrlen(dst_comp); - if(NULL==(dst_canon_prefix = H5MM_malloc(dst_canon_prefix_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - HDstrncpy(dst_canon_prefix,canon_dst_path,dst_canon_prefix_len); - dst_canon_prefix[dst_canon_prefix_len]='\0'; - - /* Hold this for later use */ - old_user_path=H5RS_get_str(ent->user_path_r); - - /* Find the user prefix for the entry */ - user_prefix_len=HDstrlen(old_user_path)-H5RS_len(ent->canon_path_r); - if(NULL==(user_prefix = H5MM_malloc(user_prefix_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - HDstrncpy(user_prefix,old_user_path,user_prefix_len); - user_prefix[user_prefix_len]='\0'; - - /* Set the tail path info */ - tail_path=old_user_path+user_prefix_len+src_canon_prefix_len+HDstrlen(src_comp); - tail_len=HDstrlen(tail_path); - - /* Get the length of the destination paths */ - user_dst_len=user_prefix_len+dst_canon_prefix_len+HDstrlen(dst_comp)+tail_len; - canon_dst_len=dst_canon_prefix_len+HDstrlen(dst_comp)+tail_len; - - /* Allocate space for the new user path */ - if(NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_dst_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - - /* Allocate space for the new canonical path */ - if(NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_dst_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - - /* Create the new names */ - HDstrcpy(new_user_path,user_prefix); - HDstrcat(new_user_path,dst_canon_prefix); - HDstrcat(new_user_path,dst_comp); - HDstrcat(new_user_path,tail_path); - HDstrcpy(new_canon_path,dst_canon_prefix); - HDstrcat(new_canon_path,dst_comp); - HDstrcat(new_canon_path,tail_path); - - /* Release the old user & canonical paths */ - H5RS_decr(ent->user_path_r); - H5RS_decr(ent->canon_path_r); - - /* Take ownership of the new user & canonical paths */ - ent->user_path_r=H5RS_own(new_user_path); - ent->canon_path_r=H5RS_own(new_canon_path); - - /* Free the extra paths allocated */ - H5MM_xfree(src_canon_prefix); - H5MM_xfree(dst_canon_prefix); - H5MM_xfree(user_prefix); - } /* end if */ - - - /* Free the extra paths allocated */ - H5RS_decr(src_path_r); - H5RS_decr(dst_path_r); - H5RS_decr(canon_src_path_r); - H5RS_decr(canon_dst_path_r); - } /* end if */ - else { - /* Release the old user path */ - if(ent->user_path_r) { - H5RS_decr(ent->user_path_r); - ent->user_path_r = NULL; - } /* end if */ - } /* end else */ - } /* end if */ - break; - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid call"); - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value); -} - - -/*------------------------------------------------------------------------- * Function: H5G_get_shared_count * * Purpose: Queries the group object's "shared count" @@ -3860,8 +2794,6 @@ done: * Programmer: Quincey Koziol * Tuesday, July 5, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -3886,8 +2818,6 @@ H5G_get_shared_count(H5G_t *grp) * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -3916,8 +2846,6 @@ H5G_mount(H5G_t *grp) * Programmer: Quincey Koziol * Tuesday, July 19, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Gent.c b/src/H5Gent.c index a8f9037..b96537d 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -188,9 +188,9 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_decode); /* check arguments */ - assert(f); - assert(pp); - assert(ent); + HDassert(f); + HDassert(pp); + HDassert(ent); ent->file = f; @@ -222,8 +222,8 @@ H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent) *pp = p_ret + H5G_SIZEOF_ENTRY(f); - FUNC_LEAVE_NOAPI(SUCCEED); -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5G_ent_decode() */ /*------------------------------------------------------------------------- @@ -348,104 +348,92 @@ H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent) /*------------------------------------------------------------------------- - * Function: H5G_ent_copy - * - * Purpose: Do a deep copy of symbol table entries - * - * Return: Success: 0, Failure: -1 + * Function: H5G_ent_copy * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Purpose: Do a deep copy of symbol table entries * - * Date: August 2002 + * Return: Success: Non-negative + * Failure: Negative * - * Comments: + * Programmer: Pedro Vicente + * pvn@ncsa.uiuc.edu + * ???day, August ??, 2002 * - * Modifications: - * Quincey Koziol, Sept. 25, 2002: - * - Changed source & destination parameters to match the rest - * of the functions in the library. - * - Added 'depth' parameter to determine how much of the group - * entry structure we want to copy. The new depths are: - * H5G_COPY_NULL - Copy all the fields from the + * Notes: 'depth' parameter determines how much of the group entry + * structure we want to copy. The values are: + * H5_COPY_NULL - Copy all the fields from the * source to the destination, but set the destination's - * user path and canonical path to NULL. - * H5G_COPY_LIMITED - Copy all the fields from the - * source to the destination, except for the user path - * field, keeping it the same as its + * paths to NULL. + * H5_COPY_LIMITED - Copy all the fields from the + * source to the destination, except for the paths + * keeping them the same as their * previous value in the destination. - * H5G_COPY_SHALLOW - Copy all the fields from the source - * to the destination, including the user path and - * canonical path. (Destination "takes ownership" of - * user and canonical paths) - * H5G_COPY_DEEP - Copy all the fields from the source to - * the destination, deep copying the user and canonical - * paths. + * H5_COPY_SHALLOW - Copy all the fields from the source + * to the destination, including the paths. + * (Destination "takes ownership" of paths) + * H5_COPY_DEEP - Copy all the fields from the source to + * the destination, deep copying the paths. * *------------------------------------------------------------------------- */ herr_t -H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5G_ent_copy_depth_t depth) +H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5_copy_depth_t depth) { - H5RS_str_t *tmp_user_path_r=NULL; /* Temporary string pointer for entry's user path */ + H5RS_str_t *old_full_path_r = NULL; /* String pointer for dst entry's full path */ + H5RS_str_t *old_user_path_r = NULL; /* String pointer for dst entry's user path */ - FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_copy); + FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_copy) /* Check arguments */ - assert(src); - assert(dst); - - /* If the depth is "very shallow", keep the old entry's user path */ - if(depth==H5G_COPY_LIMITED) { - tmp_user_path_r=dst->user_path_r; - if(dst->canon_path_r) - H5RS_decr(dst->canon_path_r); + HDassert(src); + HDassert(dst); + HDassert(depth >= H5_COPY_NULL || depth <= H5_COPY_DEEP); + + /* If the depth is "limited", keep the old entry's paths */ + if(depth == H5_COPY_LIMITED) { + old_full_path_r = dst->full_path_r; + old_user_path_r = dst->user_path_r; } /* end if */ /* Copy the top level information */ - HDmemcpy(dst,src,sizeof(H5G_entry_t)); + HDmemcpy(dst, src, sizeof(H5G_entry_t)); /* Deep copy the names */ - if(depth==H5G_COPY_DEEP) { - dst->user_path_r=H5RS_dup(src->user_path_r); - dst->canon_path_r=H5RS_dup(src->canon_path_r); - } else if(depth==H5G_COPY_LIMITED) { - dst->user_path_r=tmp_user_path_r; - dst->canon_path_r=H5RS_dup(src->canon_path_r); - } else if(depth==H5G_COPY_NULL) { - dst->user_path_r=NULL; - dst->canon_path_r=NULL; - } else if(depth==H5G_COPY_SHALLOW) { -#ifndef NDEBUG + if(depth == H5_COPY_DEEP) { + dst->full_path_r = H5RS_dup(src->full_path_r); + dst->user_path_r = H5RS_dup(src->user_path_r); + } else if(depth == H5_COPY_LIMITED) { + dst->full_path_r = old_full_path_r; + dst->user_path_r = old_user_path_r; + } else if(depth == H5_COPY_NULL) { + dst->full_path_r = NULL; + dst->user_path_r = NULL; + } else if(depth == H5_COPY_SHALLOW) { /* Discarding 'const' qualifier OK - QAK */ H5G_ent_reset((H5G_entry_t *)src); -#endif /* NDEBUG */ } /* end if */ - FUNC_LEAVE_NOAPI(SUCCEED); -} + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5G_ent_copy() */ /*------------------------------------------------------------------------- - * Function: H5G_ent_reset - * - * Purpose: Reset a symbol table entry to an empty state + * Function: H5G_ent_reset * - * Return: Success: 0, Failure: -1 + * Purpose: Reset a symbol table entry to an empty state * - * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu + * Return: Success: Non-negative + * Failure: Negative * - * Date: August 2005 - * - * Comments: - * - * Modifications: + * Programmer: Quincey Koziol + * ?day, August ??, 2005 * *------------------------------------------------------------------------- */ herr_t H5G_ent_reset(H5G_entry_t *ent) { - FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_reset); + FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_reset) /* Check arguments */ HDassert(ent); @@ -454,144 +442,21 @@ H5G_ent_reset(H5G_entry_t *ent) HDmemset(ent, 0, sizeof(H5G_entry_t)); ent->header = HADDR_UNDEF; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_ent_reset() */ /*------------------------------------------------------------------------- - * Function: H5G_ent_set_name - * - * Purpose: Set the name of a symbol entry OBJ, located at LOC - * - * Return: Success: 0, Failure: -1 - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: August 22, 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_ent_set_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name) -{ - size_t name_len; /* Length of name to append */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(H5G_ent_set_name, FAIL) - - assert(loc); - assert(obj); - assert(name); - - /* Reset the object's previous names, if they exist */ - if(obj->user_path_r) { - H5RS_decr(obj->user_path_r); - obj->user_path_r=NULL; - } /* end if */ - if(obj->canon_path_r) { - H5RS_decr(obj->canon_path_r); - obj->canon_path_r=NULL; - } /* end if */ - obj->user_path_hidden=0; - - /* Get the length of the new name */ - name_len = HDstrlen(name); - - /* Modify the object's user path, if a user path exists in the location */ - if(loc->user_path_r) { - const char *loc_user_path; /* Pointer to raw string for user path */ - size_t user_path_len; /* Length of location's user path name */ - char *new_user_path; /* Pointer to new user path */ - - /* Get the length of the strings involved */ - user_path_len = H5RS_len(loc->user_path_r); - - /* Modify the object's user path */ - - /* Get the raw string for the user path */ - loc_user_path=H5RS_get_str(loc->user_path_r); - assert(loc_user_path); - - /* The location's user path already ends in a '/' separator */ - if ('/'==loc_user_path[user_path_len-1]) { - if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+name_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDstrcpy(new_user_path, loc_user_path); - } /* end if */ - /* The location's user path needs a separator */ - else { - if (NULL==(new_user_path = H5FL_BLK_MALLOC(str_buf,user_path_len+1+name_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDstrcpy(new_user_path, loc_user_path); - HDstrcat(new_user_path, "/"); - } /* end else */ - - /* Append the component's name */ - HDstrcat(new_user_path, name); - - /* Give ownership of the user path to the entry */ - obj->user_path_r=H5RS_own(new_user_path); - assert(obj->user_path_r); - } /* end if */ - - /* Modify the object's canonical path, if a canonical path exists in the location */ - if(loc->canon_path_r) { - const char *loc_canon_path; /* Pointer to raw string for canonical path */ - size_t canon_path_len; /* Length of location's canonical path name */ - char *new_canon_path; /* Pointer to new canonical path */ - - /* Get the length of the strings involved */ - canon_path_len = H5RS_len(loc->canon_path_r); - - /* Modify the object's canonical path */ - - /* Get the raw string for the canonical path */ - loc_canon_path=H5RS_get_str(loc->canon_path_r); - assert(loc_canon_path); - - /* The location's canonical path already ends in a '/' separator */ - if ('/'==loc_canon_path[canon_path_len-1]) { - if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+name_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDstrcpy(new_canon_path, loc_canon_path); - } /* end if */ - /* The location's canonical path needs a separator */ - else { - if (NULL==(new_canon_path = H5FL_BLK_MALLOC(str_buf,canon_path_len+1+name_len+1))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDstrcpy(new_canon_path, loc_canon_path); - HDstrcat(new_canon_path, "/"); - } /* end else */ - - /* Append the component's name */ - HDstrcat(new_canon_path, name); - - /* Give ownership of the canonical path to the entry */ - obj->canon_path_r=H5RS_own(new_canon_path); - assert(obj->canon_path_r); - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_ent_set_name() */ - - -/*------------------------------------------------------------------------- * Function: H5G_ent_debug * * Purpose: Prints debugging information about a symbol table entry. * - * Errors: - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 29 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The HEAP argument is passed by value. *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Gname.c b/src/H5Gname.c index c4f5c95..7ca5045 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -15,7 +15,7 @@ /*------------------------------------------------------------------------- * * Created: H5Gname.c - * Sep 12 2005 + * Dec 19 2005 * Quincey Koziol <koziol@ncsa.uiuc.edu> * * Purpose: Functions for handling group hierarchy paths. @@ -40,12 +40,13 @@ /* Struct used by change name callback function */ typedef struct H5G_names_t { H5G_names_op_t op; /* Operation performed on file */ - H5G_loc_t *loc; /* [src] Location affected */ + H5G_entry_t *loc; /* [src] Location affected */ H5F_t *top_loc_file; /* Top file in src location's mounted file hier. */ - H5G_loc_t *dst_loc; /* Destination location */ + H5G_entry_t *dst_loc; /* Destination location */ H5RS_str_t *dst_name; /* Name of object relative to destination location */ } H5G_names_t; + /* Private macros */ /* Local variables */ @@ -272,19 +273,19 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n *------------------------------------------------------------------------- */ herr_t -H5G_name_init(H5G_name_t *name, const char *path) +H5G_name_init(H5G_entry_t *ent, const char *path) { FUNC_ENTER_NOAPI_NOFUNC(H5G_name_init) /* Check arguments */ - HDassert(name); + HDassert(ent); /* Set the initial paths for a name object */ - name->full_path_r = H5RS_create(path); - HDassert(name->full_path_r); - name->user_path_r = H5RS_create(path); - HDassert(name->user_path_r); - name->obj_hidden = 0; + ent->full_path_r = H5RS_create(path); + HDassert(ent->full_path_r); + ent->user_path_r = H5RS_create(path); + HDassert(ent->user_path_r); + ent->obj_hidden = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_init() */ @@ -304,7 +305,7 @@ H5G_name_init(H5G_name_t *name, const char *path) *------------------------------------------------------------------------- */ herr_t -H5G_name_set(H5G_name_t *loc, H5G_name_t *obj, const char *name) +H5G_name_set(H5G_entry_t *loc, H5G_entry_t *obj, const char *name) { herr_t ret_value = SUCCEED; @@ -337,59 +338,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_name_copy - * - * Purpose: Do a copy of group hier. names - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Monday, September 12, 2005 - * - * Notes: 'depth' parameter determines how much of the group entry - * structure we want to copy. The depths are: - * H5_COPY_SHALLOW - Copy all the fields from the source - * to the destination, including the user path and - * canonical path. (Destination "takes ownership" of - * user and canonical paths) - * H5_COPY_DEEP - Copy all the fields from the source to - * the destination, deep copying the user and canonical - * paths. - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) -{ - FUNC_ENTER_NOAPI_NOFUNC(H5G_name_copy) - - /* Check arguments */ - HDassert(src); - HDassert(dst); -#if defined(H5_USING_PURIFY) || !defined(NDEBUG) - HDassert(dst->full_path_r == NULL); - HDassert(dst->user_path_r == NULL); -#endif /* H5_USING_PURIFY */ - HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); - - /* Copy the top level information */ - HDmemcpy(dst, src, sizeof(H5G_name_t)); - - /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { - dst->full_path_r = H5RS_dup(src->full_path_r); - dst->user_path_r = H5RS_dup(src->user_path_r); - } else { - /* Discarding 'const' qualifier OK - QAK */ - H5G_name_reset((H5G_name_t *)src); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_name_copy() */ - - -/*------------------------------------------------------------------------- * Function: H5G_get_name * * Purpose: Gets a name of an object from its ID. @@ -407,62 +355,33 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth) ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size) { - H5G_loc_t loc; /* Object location */ - ssize_t ret_value = FAIL; + H5G_entry_t *ent; /*symbol table entry */ + size_t len = 0; + ssize_t ret_value; FUNC_ENTER_NOAPI_NOFUNC(H5G_get_name) - /* get object location */ - if(H5G_loc(id, &loc) >= 0) { - size_t len = 0; - - if(loc.path->user_path_r != NULL && loc.path->obj_hidden == 0) { - len = H5RS_len(loc.path->user_path_r); + /* get symbol table entry */ + if(NULL != (ent = H5G_loc(id))) { + if (ent->user_path_r != NULL && ent->obj_hidden == 0) { + len = H5RS_len(ent->user_path_r); if(name) { - HDstrncpy(name, H5RS_get_str(loc.path->user_path_r), MIN(len + 1, size)); + HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len + 1, size)); if(len >= size) - name[size-1] = '\0'; + name[size-1]='\0'; } /* end if */ } /* end if */ - - /* Set return value */ - ret_value = (ssize_t)len; } /* end if */ + /* Set return value */ + ret_value=(ssize_t)len; + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_get_name() */ /*------------------------------------------------------------------------- - * Function: H5G_name_reset - * - * Purpose: Reset a group hierarchy name to an empty state - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Monday, September 12, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_name_reset(H5G_name_t *name) -{ - FUNC_ENTER_NOAPI_NOFUNC(H5G_name_reset) - - /* Check arguments */ - HDassert(name); - - /* Clear the group hier. name to an empty state */ - HDmemset(name, 0, sizeof(H5G_name_t)); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_name_reset() */ - - -/*------------------------------------------------------------------------- * Function: H5G_name_free * * Purpose: Free the 'ID to name' buffers. @@ -476,22 +395,22 @@ H5G_name_reset(H5G_name_t *name) *------------------------------------------------------------------------- */ herr_t -H5G_name_free(H5G_name_t *name) +H5G_name_free(H5G_entry_t *ent) { FUNC_ENTER_NOAPI_NOFUNC(H5G_name_free) /* Check args */ - HDassert(name); + HDassert(ent); - if(name->full_path_r) { - H5RS_decr(name->full_path_r); - name->full_path_r = NULL; + if(ent->full_path_r) { + H5RS_decr(ent->full_path_r); + ent->full_path_r = NULL; } /* end if */ - if(name->user_path_r) { - H5RS_decr(name->user_path_r); - name->user_path_r = NULL; + if(ent->user_path_r) { + H5RS_decr(ent->user_path_r); + ent->user_path_r = NULL; } /* end if */ - name->obj_hidden = 0; + ent->obj_hidden = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G_name_free() */ @@ -617,8 +536,7 @@ static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) { const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */ - H5O_loc_t *oloc; /* Object location for object that the ID refers to */ - H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ + H5G_entry_t *ent = NULL; /* Group entry for object that the ID refers to */ H5F_t *top_obj_file; /* Top file in object's mounted file hier. */ hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */ herr_t ret_value = SUCCEED; /* Return value */ @@ -630,13 +548,11 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Get the symbol table entry */ switch(H5I_get_type(obj_id)) { case H5I_GROUP: - oloc = H5G_oloc((H5G_t *)obj_ptr); - obj_path = H5G_nameof((H5G_t *)obj_ptr); + ent = H5G_entof((H5G_t*)obj_ptr); break; case H5I_DATASET: - oloc = H5D_oloc((H5D_t *)obj_ptr); - obj_path = H5D_nameof((H5D_t *)obj_ptr); + ent = H5D_entof((H5D_t*)obj_ptr); break; case H5I_DATATYPE: @@ -644,41 +560,39 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) if(!H5T_is_named((H5T_t *)obj_ptr)) HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ - oloc = H5T_oloc((H5T_t *)obj_ptr); - obj_path = H5T_nameof((H5T_t *)obj_ptr); + ent = H5T_entof((H5T_t*)obj_ptr); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object") } /* end switch */ - HDassert(oloc); - HDassert(obj_path); + HDassert(ent); /* Check if the object has a full path still */ - if(!obj_path->full_path_r) + if(!ent->full_path_r) HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ /* Find the top file in object's mount hier. */ - if(oloc->file->mtab.parent) { + if(ent->file->mtab.parent) { /* Check if object is in child file (for mount & unmount operations) */ - if(names->dst_loc && oloc->file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_loc && ent->file->shared == names->dst_loc->file->shared) obj_in_child = TRUE; /* Find the "top" file in the chain of mounted files */ - top_obj_file = oloc->file->mtab.parent; + top_obj_file = ent->file->mtab.parent; while(top_obj_file->mtab.parent != NULL) { /* Check if object is in child mount hier. (for mount & unmount operations) */ - if(names->dst_loc && top_obj_file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_loc && top_obj_file->shared == names->dst_loc->file->shared) obj_in_child = TRUE; top_obj_file = top_obj_file->mtab.parent; } /* end while */ } /* end if */ else - top_obj_file = oloc->file; + top_obj_file = ent->file; /* Check if object is in top of child mount hier. (for mount & unmount operations) */ - if(names->dst_loc && top_obj_file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_loc && top_obj_file->shared == names->dst_loc->file->shared) obj_in_child = TRUE; /* Check if the object is in same file mount hier. */ @@ -699,8 +613,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) size_t new_full_len; /* Length of new full path */ /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->loc->path->full_path_r); + full_path = H5RS_get_str(ent->full_path_r); + src_path = H5RS_get_str(names->loc->full_path_r); /* Build new full path */ @@ -714,19 +628,19 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDstrcat(new_full_path, full_path); /* Release previous full path */ - H5RS_decr(obj_path->full_path_r); + H5RS_decr(ent->full_path_r); /* Take ownership of the new full path */ - obj_path->full_path_r = H5RS_own(new_full_path); + ent->full_path_r = H5RS_own(new_full_path); } /* end if */ /* Object must be in parent mount file hier. */ else { /* Check if the source is along the entry's path */ /* (But not actually the entry itself) */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(ent->full_path_r, names->loc->full_path_r) && + H5RS_cmp(ent->full_path_r, names->loc->full_path_r)) { /* Hide the user path */ - (obj_path->obj_hidden)++; + (ent->obj_hidden)++; } /* end if */ } /* end else */ break; @@ -743,8 +657,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) char *new_full_path; /* New full path of object */ /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->loc->path->full_path_r); + full_path = H5RS_get_str(ent->full_path_r); + src_path = H5RS_get_str(names->loc->full_path_r); /* Construct full path suffix */ full_suffix = full_path + HDstrlen(src_path); @@ -757,24 +671,24 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDstrcpy(new_full_path, full_suffix); /* Release previous full path */ - H5RS_decr(obj_path->full_path_r); + H5RS_decr(ent->full_path_r); /* Take ownership of the new full path */ - obj_path->full_path_r = H5RS_own(new_full_path); + ent->full_path_r = H5RS_own(new_full_path); /* Check if the object's user path should be invalidated */ - if(obj_path->user_path_r && HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) { + if(ent->user_path_r && HDstrlen(new_full_path) < (size_t)H5RS_len(ent->user_path_r)) { /* Free user path */ - H5RS_decr(obj_path->user_path_r); - obj_path->user_path_r = NULL; + H5RS_decr(ent->user_path_r); + ent->user_path_r = NULL; } /* end if */ } /* end if */ else { /* Check if file being unmounted was hiding the object */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(ent->full_path_r, names->loc->full_path_r) && + H5RS_cmp(ent->full_path_r, names->loc->full_path_r)) { /* Un-hide the user path */ - (obj_path->obj_hidden)--; + (ent->obj_hidden)--; } /* end if */ } /* end else */ break; @@ -785,9 +699,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_UNLINK: /* Check if the location being unlinked is in the path for the current object */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(ent->full_path_r, names->loc->full_path_r)) { /* Free paths for object */ - H5G_name_free(obj_path); + H5G_name_free(ent); } /* end if */ break; @@ -797,7 +711,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_MOVE: /* H5Gmove case, check for relative names case */ /* Check if the src object moved is in the current object's path */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(ent->full_path_r, names->loc->full_path_r)) { const char *full_path; /* Full path of current object */ const char *full_suffix; /* Suffix of full path, after src_path */ char *new_full_path; /* New full path of object */ @@ -808,21 +722,21 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *dst_path; /* Full path of destination object */ /* Sanity check */ - HDassert(*(H5RS_get_str(names->loc->path->full_path_r)) == '/'); + HDassert(*(H5RS_get_str(names->loc->full_path_r)) == '/'); HDassert(names->dst_name); /* Make certain that the source and destination names are full (not relative) paths */ - src_path_r = H5RS_dup(names->loc->path->full_path_r); + src_path_r = H5RS_dup(names->loc->full_path_r); if(*(H5RS_get_str(names->dst_name)) != '/') { /* Create reference counted string for full dst path */ - if((dst_path_r = H5G_build_fullpath_refstr_refstr(names->dst_loc->path->full_path_r, names->dst_name)) == NULL) + if((dst_path_r = H5G_build_fullpath_refstr_refstr(names->dst_loc->full_path_r, names->dst_name)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build destination path name") } /* end if */ else dst_path_r = H5RS_dup(names->dst_name); /* Get pointers to paths of interest */ - full_path = H5RS_get_str(obj_path->full_path_r); + full_path = H5RS_get_str(ent->full_path_r); src_path = H5RS_get_str(src_path_r); dst_path = H5RS_get_str(dst_path_r); @@ -830,8 +744,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) full_suffix = full_path + HDstrlen(src_path); /* Update the user path, if one exists */ - if(obj_path->user_path_r) - if(H5G_name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0) + if(ent->user_path_r) + if(H5G_name_move_path(&(ent->user_path_r), full_suffix, src_path, dst_path) < 0) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name") /* Build new full path */ @@ -846,10 +760,10 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) HDstrcat(new_full_path, full_suffix); /* Release previous full path */ - H5RS_decr(obj_path->full_path_r); + H5RS_decr(ent->full_path_r); /* Take ownership of the new full path */ - obj_path->full_path_r = H5RS_own(new_full_path); + ent->full_path_r = H5RS_own(new_full_path); /* Release source & destination full paths */ H5RS_decr(src_path_r); @@ -884,15 +798,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_name_replace(H5G_obj_t type, H5G_loc_t *loc, - H5RS_str_t *dst_name, H5G_loc_t *dst_loc, H5G_names_op_t op) +H5G_name_replace(int type, H5G_entry_t *loc, + H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op ) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_name_replace, FAIL) /* Check if the object we are manipulating has a path */ - if(loc->path->full_path_r) { + if(loc->full_path_r) { unsigned search_group = 0; /* Flag to indicate that groups are to be searched */ unsigned search_dataset = 0; /* Flag to indicate that datasets are to be searched */ unsigned search_datatype = 0; /* Flag to indicate that datatypes are to be searched */ @@ -942,14 +856,14 @@ H5G_name_replace(H5G_obj_t type, H5G_loc_t *loc, H5F_t *top_loc_file; /* Top file in src location's mounted file hier. */ /* Find top file in src location's mount hierarchy */ - if(loc->oloc->file->mtab.parent) { + if(loc->file->mtab.parent) { /* Find the "top" file in the chain of mounted files for the location */ - top_loc_file = loc->oloc->file->mtab.parent; + top_loc_file = loc->file->mtab.parent; while(top_loc_file->mtab.parent != NULL) top_loc_file = top_loc_file->mtab.parent; } /* end if */ else - top_loc_file = loc->oloc->file; + top_loc_file = loc->file; /* Set up common information for callback */ names.loc = loc; diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 60c39b4..5d12d94 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -49,6 +49,19 @@ typedef struct H5G_node_key_t { size_t offset; /*offset into heap for name */ } H5G_node_key_t; +/* + * A symbol table node is a collection of symbol table entries. It can + * be thought of as the lowest level of the B-link tree that points to + * a collection of symbol table entries that belong to a specific symbol + * table or group. + */ +typedef struct H5G_node_t { + H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ + /* first field in structure */ + unsigned nsyms; /*number of symbols */ + H5G_entry_t *entry; /*array of symbol table entries */ +} H5G_node_t; + /* Private macros */ #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) @@ -677,8 +690,6 @@ H5G_compute_size(const H5F_t *f, const H5G_node_t UNUSED *sym, size_t *size_ptr) * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -883,9 +894,6 @@ done: * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t @@ -899,26 +907,26 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key int cmp = 1; const char *s; const char *base; /* Base of heap */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5G_node_found); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_found) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(udata); /* * Load the symbol table node for exclusive access. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node") /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); @@ -926,23 +934,23 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key * Binary search. */ rt = sn->nsyms; - while (lt < rt && cmp) { + while(lt < rt && cmp) { idx = (lt + rt) / 2; - s=base+sn->entry[idx].name_off; + s = base + sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); if (cmp < 0) rt = idx; else lt = idx + 1; - } + } /* end while */ - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") + heap = NULL; base = NULL; - if (cmp) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found"); + if(cmp) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") /* * The caller is querying the symbol entry, copy it into the UDATA @@ -950,8 +958,8 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key * * (do a NULL copy, since the entry's name will be constructed later) */ - if (H5G_ent_copy(udata->ent, &sn->entry[idx], H5G_COPY_NULL)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy entry"); + if(H5G_ent_copy(udata->ent, &sn->entry[idx], H5_COPY_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy entry") /* Leave object in same file as lookup occurs in */ /* If a file is opened through different H5Fopen() calls, the symbol @@ -961,11 +969,11 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key udata->ent->file = f; done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_found() */ /*------------------------------------------------------------------------- @@ -1000,16 +1008,14 @@ done: * matzke@llnl.gov * Jun 24 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static H5B_ins_t -H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, - hbool_t UNUSED *lt_key_changed, void *_md_key, - void *_udata, void *_rt_key, hbool_t *rt_key_changed, - haddr_t *new_node_p) +H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, + void UNUSED *_lt_key, hbool_t UNUSED *lt_key_changed, + void *_md_key, void *_udata, + void *_rt_key, hbool_t *rt_key_changed, + haddr_t *new_node_p) { H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; @@ -1025,27 +1031,27 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, H5G_node_t *insert_into = NULL; /*node that gets new entry*/ H5B_ins_t ret_value = H5B_INS_ERROR; - FUNC_ENTER_NOAPI_NOINIT(H5G_node_insert); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_insert) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(md_key); - assert(rt_key); - assert(udata); - assert(new_node_p); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(md_key); + HDassert(rt_key); + HDassert(udata); + HDassert(new_node_p); /* * Load the symbol node. */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); @@ -1053,30 +1059,30 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, * Where does the new symbol get inserted? We use a binary search. */ rt = sn->nsyms; - while (lt < rt) { + while(lt < rt) { idx = (lt + rt) / 2; - s=base+sn->entry[idx].name_off; + s = base + sn->entry[idx].name_off; - if (0 == (cmp = HDstrcmp(udata->common.name, s))) /*already present */ { + if(0 == (cmp = HDstrcmp(udata->common.name, s))) /*already present */ { HCOMMON_ERROR(H5E_SYM, H5E_CANTINSERT, "symbol is already present in symbol table"); - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; - HGOTO_DONE(H5B_INS_ERROR); - } + HGOTO_DONE(H5B_INS_ERROR) + } /* end if */ if (cmp < 0) rt = idx; else lt = idx + 1; - } + } /* end while */ idx += cmp > 0 ? 1 : 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; /* * Add the new name to the heap. @@ -1085,8 +1091,10 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, udata->common.name); udata->ent->name_off = offset; if (0==offset || (size_t)(-1)==offset) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap"); - if (sn->nsyms >= 2*H5F_SYM_LEAF_K(f)) { + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap") + + /* Determine where to place entry in node */ + if(sn->nsyms >= 2 * H5F_SYM_LEAF_K(f)) { /* * The node is full. Split it into a left and right * node and return the address of the new right node (the @@ -1095,12 +1103,11 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, ret_value = H5B_INS_RIGHT; /* The right node */ - if (H5G_node_create(f, dxpl_id, H5B_INS_FIRST, NULL, NULL, NULL, - new_node_p/*out*/)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node"); + if(H5G_node_create(f, dxpl_id, H5B_INS_FIRST, NULL, NULL, NULL, new_node_p/*out*/) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node") - if (NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node"); + if(NULL == (snrt = H5AC_protect(f, dxpl_id, H5AC_SNODE, *new_node_p, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node") HDmemcpy(snrt->entry, sn->entry + H5F_SYM_LEAF_K(f), H5F_SYM_LEAF_K(f) * sizeof(H5G_entry_t)); @@ -1117,37 +1124,36 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, md_key->offset = sn->entry[sn->nsyms - 1].name_off; /* Where to insert the new entry? */ - if (idx <= (int)H5F_SYM_LEAF_K(f)) { + if(idx <= (int)H5F_SYM_LEAF_K(f)) { insert_into = sn; - if (idx == (int)H5F_SYM_LEAF_K(f)) + if(idx == (int)H5F_SYM_LEAF_K(f)) md_key->offset = offset; } else { idx -= H5F_SYM_LEAF_K(f); insert_into = snrt; - if (idx == (int)H5F_SYM_LEAF_K (f)) { + if(idx == (int)H5F_SYM_LEAF_K (f)) { rt_key->offset = offset; *rt_key_changed = TRUE; - } - } + } /* end if */ + } /* end else */ } else { /* Where to insert the new entry? */ ret_value = H5B_INS_NOOP; sn->cache_info.is_dirty = TRUE; insert_into = sn; - if (idx == (int)sn->nsyms) { + if(idx == (int)sn->nsyms) { rt_key->offset = offset; *rt_key_changed = TRUE; - } - } + } /* end if */ + } /* end else */ /* Move entries down to make room for new entry */ - HDmemmove(insert_into->entry + idx + 1, - insert_into->entry + idx, + HDmemmove(insert_into->entry + idx + 1, insert_into->entry + idx, (insert_into->nsyms - idx) * sizeof(H5G_entry_t)); /* Copy new entry into table */ - /* (use H5G_COPY_NULL because we don't track the object names in the table) */ - H5G_ent_copy(&(insert_into->entry[idx]), udata->ent, H5G_COPY_NULL); + if(H5G_ent_copy(&(insert_into->entry[idx]), udata->ent, H5_COPY_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, H5B_INS_ERROR, "unable to copy entry") /* Flag entry as dirty */ insert_into->entry[idx].dirty = TRUE; @@ -1156,13 +1162,13 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key, insert_into->nsyms += 1; done: - if (snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); + if(snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_insert() */ /*------------------------------------------------------------------------- @@ -1191,16 +1197,6 @@ done: * Programmer: Robb Matzke * Thursday, September 24, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002 - * Added `id to name' support. - * - * Quincey Koziol, 2003-03-22 - * Added support for deleting all the entries at once. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -1214,74 +1210,73 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, H5G_bt_ud2_t *udata = (H5G_bt_ud2_t *)_udata; H5G_node_t *sn = NULL; const H5HL_t *heap = NULL; - unsigned lt=0, rt, idx=0; - int cmp=1; + unsigned lt = 0, rt, idx = 0; + int cmp = 1; const char *s = NULL; const char *base; /* Base of heap */ H5B_ins_t ret_value = H5B_INS_ERROR; - FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove) /* Check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(lt_key); - assert(rt_key); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(lt_key); + HDassert(rt_key); + HDassert(udata); /* Load the symbol table */ - if (NULL==(sn=H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node"); + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_WRITE))) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node") /* "Normal" removal of a single entry from the symbol table node */ - if(udata->common.name!=NULL) { - size_t len=0; + if(udata->common.name != NULL) { + size_t len = 0; hbool_t found; /* Indicate that the string was found */ /* Get base address of heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") base = H5HL_offset_into(f, heap, 0); /* Find the name with a binary search */ rt = sn->nsyms; - while (lt<rt && cmp) { - idx = (lt+rt)/2; - s=base+sn->entry[idx].name_off; + while(lt < rt && cmp) { + idx = (lt + rt) / 2; + s = base + sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); - if (cmp<0) { + if(cmp < 0) rt = idx; - } else { - lt = idx+1; - } - } + else + lt = idx + 1; + } /* end while */ - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; base=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; base = NULL; - if (cmp) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found"); + if(cmp) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found") - if (H5G_CACHED_SLINK==sn->entry[idx].type) { + if(H5G_CACHED_SLINK == sn->entry[idx].type) { /* Remove the symbolic link value */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") s = H5HL_offset_into(f, heap, sn->entry[idx].cache.slink.lval_offset); - if (s) { - len=HDstrlen(s)+1; - found=1; + if(s) { + len = HDstrlen(s) + 1; + found = 1; } /* end if */ else - found=0; + found = 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; s=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; s = NULL; - if (found) + if(found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].cache.slink.lval_offset, len); H5E_clear(); /* no big deal */ @@ -1289,55 +1284,55 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); - if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) + if(H5O_link(sn->entry+idx, -1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ - } + } /* end else */ /* Remove the name from the local heap */ - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") s = H5HL_offset_into(f, heap, sn->entry[idx].name_off); - if (s) { - len=HDstrlen(s)+1; - found=1; + if(s) { + len = HDstrlen(s) + 1; + found = 1; } /* end if */ else - found=0; + found = 0; - if (H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name"); - heap=NULL; s=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") + heap = NULL; s = NULL; - if (found) + if(found) H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].name_off, len); H5E_clear(); /* no big deal */ /* Remove the entry from the symbol table node */ - if(1==sn->nsyms) { + if(1 == sn->nsyms) { /* * We are about to remove the only symbol in this node. Copy the left * key to the right key and mark the right key as dirty. Free this * node and indicate that the pointer to this node in the B-tree * should be removed also. */ - assert(0==idx); + HDassert(0 == idx); *rt_key = *lt_key; *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; - if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); - } + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") + } /* end if */ sn = NULL; ret_value = H5B_INS_REMOVE; - } else if (0==idx) { + } else if(0 == idx) { /* * We are about to remove the left-most entry from the symbol table * node but there are other entries to the right. No key values @@ -1345,11 +1340,11 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - HDmemmove(sn->entry+idx, sn->entry+idx+1, - (sn->nsyms-idx)*sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, + (sn->nsyms-idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } else if (idx+1==sn->nsyms) { + } else if (idx + 1 == sn->nsyms) { /* * We are about to remove the right-most entry from the symbol table * node but there are other entries to the left. The right key @@ -1357,7 +1352,7 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - rt_key->offset = sn->entry[sn->nsyms-1].name_off; + rt_key->offset = sn->entry[sn->nsyms - 1].name_off; *rt_key_changed = TRUE; ret_value = H5B_INS_NOOP; @@ -1368,20 +1363,20 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, */ sn->nsyms -= 1; sn->cache_info.is_dirty = TRUE; - HDmemmove(sn->entry+idx, sn->entry+idx+1, - (sn->nsyms-idx)*sizeof(H5G_entry_t)); + HDmemmove(sn->entry + idx, sn->entry + idx + 1, + (sn->nsyms - idx) * sizeof(H5G_entry_t)); ret_value = H5B_INS_NOOP; - } + } /* end else */ } /* end if */ /* Remove all entries from node, during B-tree deletion */ else { /* Reduce the link count for all entries in this node */ - for(idx=0; idx<sn->nsyms; idx++) { - if (H5G_CACHED_SLINK!=sn->entry[idx].type) { + for(idx = 0; idx < sn->nsyms; idx++) { + if(H5G_CACHED_SLINK != sn->entry[idx].type) { /* Decrement the reference count, if requested */ if(udata->adj_link) { HDassert(H5F_addr_defined(sn->entry[idx].header)); - if (H5O_link(sn->entry+idx, -1, dxpl_id)<0) + if (H5O_link(sn->entry+idx, -1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ } /* end if */ @@ -1397,21 +1392,21 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, *rt_key_changed = TRUE; sn->nsyms = 0; sn->cache_info.is_dirty = TRUE; - if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f))<0 + if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)H5G_node_size(f)) < 0 || H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, TRUE)<0) { sn = NULL; - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); - } + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node") + } /* end if */ sn = NULL; ret_value = H5B_INS_REMOVE; } /* end else */ done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE)<0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node"); + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_remove() */ /*------------------------------------------------------------------------- @@ -1425,12 +1420,6 @@ done: * matzke@llnl.gov * Jun 24 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Quincey Koziol, 2002-04-22 - * Changed to callback from H5B_iterate *------------------------------------------------------------------------- */ int @@ -1538,8 +1527,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1585,8 +1572,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1655,7 +1640,6 @@ done: * Programmer: Raymond Lu * Nov 20, 2002 * - * *------------------------------------------------------------------------- */ int @@ -1663,35 +1647,38 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, const void UNUSED *_rt_key, void *_udata) { H5G_bt_it_ud3_t *udata = (H5G_bt_it_ud3_t*)_udata; - hsize_t loc_idx; H5G_node_t *sn = NULL; int ret_value = H5B_ITER_CONT; - FUNC_ENTER_NOAPI(H5G_node_type, H5B_ITER_ERROR); + FUNC_ENTER_NOAPI(H5G_node_type, H5B_ITER_ERROR) /* Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(udata); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(udata); /* Find the node, locate the object symbol table entry and retrieve the type */ - if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) + if(NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node"); if(udata->idx >= udata->num_objs && udata->idx < (udata->num_objs + sn->nsyms)) { + hsize_t loc_idx; + + /* Compute index of entry */ loc_idx = udata->idx - udata->num_objs; + udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id); ret_value = H5B_ITER_STOP; } else { udata->num_objs += sn->nsyms; - } + } /* end else */ done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header"); FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5G_node_type() */ /*------------------------------------------------------------------------- @@ -1829,9 +1816,6 @@ H5G_node_shared_free (void *_shared) * matzke@llnl.gov * Aug 4 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR and HEAP arguments are passed by value. *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index d68e413..e7318ab 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -37,19 +37,6 @@ #define H5G_SIZE_HINT 256 /* default root grp size hint */ /* - * A symbol table node is a collection of symbol table entries. It can - * be thought of as the lowest level of the B-link tree that points to - * a collection of symbol table entries that belong to a specific symbol - * table or group. - */ -typedef struct H5G_node_t { - H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */ - /* first field in structure */ - unsigned nsyms; /*number of symbols */ - H5G_entry_t *entry; /*array of symbol table entries */ -} H5G_node_t; - -/* * Shared information for all open group objects */ struct H5G_shared_t { @@ -172,6 +159,21 @@ typedef struct H5G_bt_it_ud4_t { /* upward */ } H5G_bt_it_ud4_t; +/* Enum for H5G_namei actions */ +typedef enum { + H5G_NAMEI_TRAVERSE, /* Just traverse groups */ + H5G_NAMEI_INSERT /* Insert entry in group */ +} H5G_namei_act_t ; + +/* + * During name lookups (see H5G_namei()) we sometimes want information about + * a symbolic link or a mount point. The normal operation is to follow the + * symbolic link or mount point and return information about its target. + */ +#define H5G_TARGET_NORMAL 0x0000 +#define H5G_TARGET_SLINK 0x0001 +#define H5G_TARGET_MOUNT 0x0002 + /* * This is the class identifier to give to the B-tree functions. */ @@ -181,6 +183,17 @@ H5_DLLVAR H5B_class_t H5B_SNODE[1]; H5_DLLVAR const H5AC_class_t H5AC_SNODE[1]; /* + * Utility functions + */ +H5_DLL H5G_t *H5G_rootof(H5F_t *f); +H5_DLL const char * H5G_component(const char *name, size_t *size_p); +H5_DLL herr_t H5G_namei_term_interface(void); +H5_DLL herr_t H5G_namei(const H5G_entry_t *loc_ent, const char *name, + const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, + unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, + H5G_entry_t *ent, hid_t dxpl_id); + +/* * Functions that understand symbol tables but not names. The * functions that understand names are exported to the rest of * the library and appear in H5Gprivate.h. @@ -201,7 +214,6 @@ H5_DLL herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, unsigned n); H5_DLL herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, unsigned n); -H5_DLL herr_t H5G_ent_set_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name); /* Functions that understand symbol table nodes */ H5_DLL int H5G_node_iterate (H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, @@ -212,4 +224,11 @@ H5_DLL int H5G_node_name(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t a const void *_rt_key, void *_udata); H5_DLL int H5G_node_type(H5F_t *f, hid_t dxpl_id, const void *_lt_key, haddr_t addr, const void *_rt_key, void *_udata); + +/* + * These functions operate on group hierarchy names. + */ +H5_DLL herr_t H5G_name_init(H5G_entry_t *name, const char *path); +H5_DLL herr_t H5G_name_set(H5G_entry_t *loc, H5G_entry_t *obj, const char *name); + #endif diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 242d65b..b480ded 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -73,6 +73,14 @@ typedef enum H5G_type_t { H5G_NCACHED = 3 /*THIS MUST BE LAST */ } H5G_type_t; +/* Type of operation being performed for call to H5G_name_replace() */ +typedef enum { + H5G_NAME_MOVE = 0, /* H5*move call */ + H5G_NAME_UNLINK, /* H5Gunlink call */ + H5G_NAME_MOUNT, /* H5Fmount call */ + H5G_NAME_UNMOUNT /* H5Funmount call */ +} H5G_names_op_t; + /* * A symbol table entry caches these parameters from object header * messages... The values are entered into the symbol table when an object @@ -104,29 +112,14 @@ typedef struct H5G_entry_t { size_t name_off; /*offset of name within name heap */ haddr_t header; /*file address of object header */ H5F_t *file; /*file to which this obj hdr belongs */ + H5RS_str_t *full_path_r; /* Path to object, as seen from root of current file mounting hierarchy */ H5RS_str_t *user_path_r; /* Path to object, as opened by user */ - H5RS_str_t *canon_path_r; /* Path to object, as found in file */ - unsigned user_path_hidden; /* Whether the user's path is valid */ + unsigned obj_hidden; /* Whether the object is visible in group hier. */ } H5G_entry_t; typedef struct H5G_t H5G_t; typedef struct H5G_shared_t H5G_shared_t; -/* Type of operation being performed for call to H5G_replace_name() */ -typedef enum { - OP_MOVE = 0, /* H5*move call */ - OP_UNLINK, /* H5Gunlink call */ - OP_MOUNT, /* H5Fmount call */ - OP_UNMOUNT /* H5Funmount call */ -} H5G_names_op_t; - -/* Depth of group entry copy */ -typedef enum { - H5G_COPY_NULL, /* Null destination names */ - H5G_COPY_LIMITED, /* Limited copy from source to destination, omitting name & old name fields */ - H5G_COPY_SHALLOW, /* Copy from source to destination, including name & old name fields */ - H5G_COPY_DEEP /* Deep copy from source to destination, including duplicating name & old name fields */ -} H5G_ent_copy_depth_t; /* * Library prototypes... These are the ones that other packages routinely @@ -148,9 +141,6 @@ H5_DLL herr_t H5G_insert(H5G_entry_t *loc, const char *name, H5_DLL herr_t H5G_find(H5G_entry_t *loc, const char *name, H5G_entry_t *ent/*out*/, hid_t dxpl_id); H5_DLL H5F_t *H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id); -H5_DLL herr_t H5G_replace_name(int type, H5G_entry_t *loc, - H5RS_str_t *src_name, H5G_entry_t *src_loc, - H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op); H5_DLL herr_t H5G_free_grp_name(H5G_t *grp); H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); H5_DLL herr_t H5G_mount(H5G_t *grp); @@ -159,10 +149,10 @@ H5_DLL herr_t H5G_unmount(H5G_t *grp); /* * These functions operate on symbol table nodes. */ -H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, - int indent, int fwidth, haddr_t heap); H5_DLL herr_t H5G_node_init(H5F_t *f); H5_DLL herr_t H5G_node_close(const H5F_t *f); +H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, + int indent, int fwidth, haddr_t heap); /* * These functions operate on symbol table entries. They're used primarily @@ -174,9 +164,18 @@ H5_DLL herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent/*out*/); H5_DLL const H5G_cache_t *H5G_ent_cache(const H5G_entry_t *ent, H5G_type_t *cache_type); H5_DLL herr_t H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, - H5G_ent_copy_depth_t depth); + H5_copy_depth_t depth); H5_DLL herr_t H5G_ent_reset(H5G_entry_t *ent); -H5_DLL herr_t H5G_free_ent_name(H5G_entry_t *ent); H5_DLL herr_t H5G_ent_debug(H5F_t *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * stream, int indent, int fwidth, haddr_t heap); + +/* + * These functions operate on group hierarchy names. + */ +H5_DLL herr_t H5G_name_free(H5G_entry_t *ent); +H5_DLL herr_t H5G_name_replace(int type, H5G_entry_t *loc, + H5RS_str_t *dst_name, H5G_entry_t *dst_loc, H5G_names_op_t op); +H5_DLL ssize_t H5G_get_name(hid_t id, char *name/*out*/, size_t size); + #endif + diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 8c83859..c2e54f0 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -43,24 +43,20 @@ * item in the heap is the empty string, and must appear at * heap offset zero. * - * Errors: - * * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 1 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5G_stab_create(H5F_t *f, hid_t dxpl_id, size_t init, H5G_entry_t *self/*out*/) { - size_t name; /*offset of "" name */ + size_t name_offset; /* Offset of "" name */ H5O_stab_t stab; /*symbol table message */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_create, FAIL) @@ -72,17 +68,17 @@ H5G_stab_create(H5F_t *f, hid_t dxpl_id, size_t init, H5G_entry_t *self/*out*/) init = MAX(init, H5HL_SIZEOF_FREE(f) + 2); /* Create symbol table private heap */ - if (H5HL_create(f, dxpl_id, init, &(stab.heap_addr)/*out*/)<0) + if(H5HL_create(f, dxpl_id, init, &(stab.heap_addr)/*out*/)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap") - name = H5HL_insert(f, dxpl_id, stab.heap_addr, 1, ""); - if ((size_t)(-1)==name) + name_offset = H5HL_insert(f, dxpl_id, stab.heap_addr, 1, ""); + if((size_t)(-1) == name_offset) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap") /* * B-tree's won't work if the first name isn't at the beginning * of the heap. */ - assert(0 == name); + HDassert(0 == name_offset); /* Create the B-tree */ if (H5B_create(f, dxpl_id, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0) @@ -164,7 +160,7 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name, HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") /* Set the name for the symbol entry OBJ_ENT */ - if (H5G_ent_set_name( grp_ent, obj_ent, name ) < 0) + if (H5G_name_set( grp_ent, obj_ent, name ) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot insert name") done: @@ -191,25 +187,21 @@ herr_t H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, hbool_t inc_link, hid_t dxpl_id) { - H5O_stab_t stab; /*symbol table message */ + H5O_stab_t stab; /* Symbol table message */ H5G_bt_ud1_t udata; /*data to pass through B-tree */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_stab_insert, FAIL) /* check arguments */ - assert(grp_ent && grp_ent->file); - assert(name && *name); - assert(obj_ent && obj_ent->file); - if (grp_ent->file->shared != obj_ent->file->shared) + HDassert(grp_ent && grp_ent->file); + HDassert(name && *name); + HDassert(obj_ent && obj_ent->file); + if(grp_ent->file->shared != obj_ent->file->shared) HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "interfile hard links are not allowed") - /* Set the name for the symbol entry OBJ_ENT */ - if (H5G_ent_set_name( grp_ent, obj_ent, name ) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot insert name") - /* initialize data to pass through B-tree */ - if (NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) + if(NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") udata.common.name = name; @@ -217,17 +209,21 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent, udata.ent = obj_ent; /* insert */ - if (H5B_insert(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) + if(H5B_insert(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry") + /* Set the name for the symbol entry OBJ_ENT */ + if(H5G_name_set(grp_ent, obj_ent, name) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot insert name") + /* Increment link count on object, if appropriate */ if(inc_link) if (H5O_link(obj_ent, 1, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to increment hard link count") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_stab_insert() */ /*------------------------------------------------------------------------- @@ -240,8 +236,6 @@ done: * Programmer: Robb Matzke * Thursday, September 17, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -253,23 +247,25 @@ H5G_stab_remove(H5G_entry_t *grp_ent, const char *name, hid_t dxpl_id) FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL) - assert(grp_ent && grp_ent->file); - assert(name && *name); + HDassert(grp_ent && grp_ent->file); + HDassert(name && *name); /* initialize data to pass through B-tree */ - if (NULL==H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") + if(NULL == H5O_read(grp_ent, H5O_STAB_ID, 0, &stab, dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table") + + /* Initialize data to pass through B-tree */ udata.common.name = name; udata.common.heap_addr = stab.heap_addr; udata.adj_link = TRUE; - /* remove */ - if (H5B_remove(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata)<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") + /* Remove */ + if(H5B_remove(grp_ent->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata)<0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5G_stab_remove() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 83f561e..20d7d86 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -13,7 +13,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> - * Monday, October 17, 2005 + * Monday, December 19, 2005 * * Purpose: Group testing functions. */ @@ -32,207 +32,6 @@ /*-------------------------------------------------------------------------- NAME - H5G_is_empty_test - PURPOSE - Determine whether a group contains no objects - USAGE - htri_t H5G_is_empty_test(gid) - hid_t gid; IN: group to check - RETURNS - Non-negative TRUE/FALSE on success, negative on failure - DESCRIPTION - Checks to see if the group has no link messages and no symbol table message - dimensionality and shape. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5G_is_empty_test(hid_t gid) -{ - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - htri_t ret_value = TRUE; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_is_empty_test, FAIL) - - /* Get group structure */ - if(NULL == (grp = H5I_object_verify(gid, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* Check if the group has any link messages */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_LINK_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) - HGOTO_DONE(FALSE) - - /* Check if the group has a symbol table message */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_STAB_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) - HGOTO_DONE(FALSE) - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_is_empty_test() */ - - -/*-------------------------------------------------------------------------- - NAME - H5G_has_links_test - PURPOSE - Determine whether a group contains link messages - USAGE - htri_t H5G_has_links_test(gid) - hid_t gid; IN: group to check - unsigned *nmsgs; OUT: # of link messages in header - RETURNS - Non-negative TRUE/FALSE on success, negative on failure - DESCRIPTION - Checks to see if the group has link messages and how many. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5G_has_links_test(hid_t gid, unsigned *nmsgs) -{ - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - htri_t ret_value = TRUE; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_has_links_test, FAIL) - - /* Get group structure */ - if(NULL == (grp = H5I_object_verify(gid, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* Check if the group has any link messages */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_LINK_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) - HGOTO_DONE(FALSE) - - /* Check if the group has a symbol table message */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_STAB_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") - - /* Check if we should retrieve the number of link messages */ - if(nmsgs) { - int msg_count; /* Number of messages of a type */ - - /* Check how many link messages there are */ - if((msg_count = H5O_count(&(grp->oloc), H5O_LINK_ID, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to count link messages") - *nmsgs = (unsigned)msg_count; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_has_links_test() */ - - -/*-------------------------------------------------------------------------- - NAME - H5G_has_stab_test - PURPOSE - Determine whether a group contains a symbol table message - USAGE - htri_t H5G_has_stab_test(gid) - hid_t gid; IN: group to check - RETURNS - Non-negative TRUE/FALSE on success, negative on failure - DESCRIPTION - Checks to see if the group has a symbol table message. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5G_has_stab_test(hid_t gid) -{ - H5G_t *grp = NULL; /* Pointer to group */ - htri_t msg_exists = 0; /* Indicate that a header message is present */ - htri_t ret_value = TRUE; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_has_stab_test, FAIL) - - /* Get group structure */ - if(NULL == (grp = H5I_object_verify(gid, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* Check if the group has a symbol table message */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_STAB_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists == 0) - HGOTO_DONE(FALSE) - - /* Check if the group has any link messages */ - if((msg_exists = H5O_exists(&(grp->oloc), H5O_LINK_ID, 0, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(msg_exists > 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "both symbol table and link messages found") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_has_stab_test() */ - - -/*-------------------------------------------------------------------------- - NAME - H5G_lheap_size_test - PURPOSE - Determine the size of a local heap for a group - USAGE - herr_t H5G_lheap_size_test(gid, lheap_size) - hid_t gid; IN: group to check - size_t *lheap_size; OUT: Size of local heap - RETURNS - Non-negative on success, negative on failure - DESCRIPTION - Checks the size of the local heap for a group - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5G_lheap_size_test(hid_t gid, size_t *lheap_size) -{ - H5G_t *grp = NULL; /* Pointer to group */ - H5O_stab_t stab; /* Symbol table message */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_lheap_size_test, FAIL) - - /* Get group structure */ - if(NULL == (grp = H5I_object_verify(gid, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* Make certain the group has a symbol table message */ - if(NULL == H5O_read(&(grp->oloc), H5O_STAB_ID, 0, &stab, H5AC_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbol table message") - - /* Check the size of the local heap for the group */ - if(H5HL_get_size(grp->oloc.file, H5AC_dxpl_id, stab.heap_addr, lheap_size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't query local heap size") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5G_lheap_size_test() */ - - -/*-------------------------------------------------------------------------- - NAME H5G_user_path_test PURPOSE Retrieve the user path for an ID @@ -257,7 +56,7 @@ herr_t H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden) { void *obj_ptr; /* Pointer to object for ID */ - H5G_name_t *obj_path; /* Pointer to group hier. path for obj */ + H5G_entry_t *obj_ent; /* Pointer to symbol table entry for obj */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_user_path_test, FAIL) @@ -273,11 +72,11 @@ H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigne /* Get the symbol table entry */ switch(H5I_get_type(obj_id)) { case H5I_GROUP: - obj_path = H5G_nameof((H5G_t *)obj_ptr); + obj_ent = H5G_entof((H5G_t *)obj_ptr); break; case H5I_DATASET: - obj_path = H5D_nameof((H5D_t *)obj_ptr); + obj_ent = H5D_entof((H5D_t *)obj_ptr); break; case H5I_DATATYPE: @@ -285,27 +84,27 @@ H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigne if(!H5T_is_named((H5T_t *)obj_ptr)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype") - obj_path = H5T_nameof((H5T_t *)obj_ptr); + obj_ent = H5T_entof((H5T_t *)obj_ptr); break; default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object type") } /* end switch */ - HDassert(obj_path); + HDassert(obj_ent); /* Retrieve a copy of the user path and put it into the buffer */ - if(obj_path->user_path_r) { - size_t len = H5RS_len(obj_path->user_path_r); + if(obj_ent->user_path_r) { + size_t len = H5RS_len(obj_ent->user_path_r); /* Set the user path, if given */ if(user_path) - HDstrcpy(user_path, H5RS_get_str(obj_path->user_path_r)); + HDstrcpy(user_path, H5RS_get_str(obj_ent->user_path_r)); /* Set the length of the path */ *user_path_len = len; /* Set the user path hidden flag */ - *obj_hidden = obj_path->obj_hidden; + *obj_hidden = obj_ent->obj_hidden; } /* end if */ else { *user_path_len = 0; diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 8a53064..c706ed3 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -15,7 +15,7 @@ /*------------------------------------------------------------------------- * * Created: H5Gtraverse.c - * Sep 13 2005 + * Dec 19 2005 * Quincey Koziol <koziol@ncsa.uiuc.edu> * * Purpose: Functions for traversing group hierarchy @@ -25,22 +25,19 @@ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ - /* Packages needed by this file... */ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ +#ifdef QAK +#include "H5Iprivate.h" /* IDs */ +#endif /* QAK */ #include "H5MMprivate.h" /* Memory management */ /* Private typedefs */ -/* User data for path traversal routine */ -typedef struct { - H5G_loc_t *obj_loc; /* Object location */ -} H5G_trav_ud1_t; - /* Private macros */ /* Local variables */ @@ -48,18 +45,12 @@ static char *H5G_comp_g = NULL; /*component buffer */ static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */ /* PRIVATE PROTOTYPES */ -static herr_t H5G_traverse_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, - const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/); -static herr_t H5G_traverse_slink(H5G_loc_t *grp_loc/*in,out*/, H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id); -static herr_t H5G_traverse_mount(H5G_loc_t *loc/*in,out*/); -static herr_t H5G_traverse_real(const H5G_loc_t *loc, const char *name, - unsigned target, int *nlinks, H5G_traverse_t op, void *op_data, - hid_t dxpl_id); +static herr_t H5G_traverse_slink(H5G_entry_t *grp_ent/*in,out*/, + H5G_entry_t *obj_ent/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id); /*------------------------------------------------------------------------- - * Function: H5G_traverse_term_interface + * Function: H5G_namei_term_interface * * Purpose: Terminates part of the H5G interface - free the global * component buffer. @@ -74,68 +65,27 @@ static herr_t H5G_traverse_real(const H5G_loc_t *loc, const char *name, *------------------------------------------------------------------------- */ herr_t -H5G_traverse_term_interface(void) +H5G_namei_term_interface(void) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_traverse_term_interface) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_namei_term_interface) /* Free the global component buffer */ H5G_comp_g = H5MM_xfree(H5G_comp_g); H5G_comp_alloc_g = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5G_traverse_term_interface() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_traverse_link_cb - * - * Purpose: Callback for link traversal. This routine sets the - * correct information for the object location. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, September 13, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_traverse_link_cb(H5G_loc_t UNUSED *grp_loc, const char UNUSED *name, const H5O_link_t UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/) -{ - H5G_trav_ud1_t *udata = (H5G_trav_ud1_t *)_udata; /* User data passed in */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_link_cb) - - /* Check for dangling soft link */ - if(obj_loc == NULL) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") - - /* Copy new location information for resolved object */ - H5O_loc_copy(udata->obj_loc->oloc, obj_loc->oloc, H5_COPY_DEEP); - -done: - /* Release the group location for the object */ - /* (Group traversal callbacks are responsible for either taking ownership - * of the group location for the object, or freeing it. - QAK) - */ - if(obj_loc) - H5G_loc_free(obj_loc); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_traverse_link_cb() */ +} /* end H5G_namei_term_interface() */ /*------------------------------------------------------------------------- * Function: H5G_traverse_slink * * Purpose: Traverses symbolic link. The link head appears in the group - * whose entry is GRP_LOC and the link tail entry is OBJ_LOC. + * whose entry is GRP_ENT and the link head entry is OBJ_ENT. * - * Return: Success: Non-negative, OBJ_LOC will contain information + * Return: Success: Non-negative, OBJ_ENT will contain information * about the object to which the link points and - * GRP_LOC will contain the information about + * GRP_ENT will contain the information about * the group in which the link tail appears. * * Failure: Negative @@ -143,181 +93,222 @@ done: * Programmer: Robb Matzke * Friday, April 10, 1998 * + * Modifications: + * + * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 + * Added `id to name' support. + * *------------------------------------------------------------------------- */ static herr_t -H5G_traverse_slink(H5G_loc_t *grp_loc/*in,out*/, H5O_link_t *lnk, - H5G_loc_t *obj_loc/*in,out*/, int *nlinks/*in,out*/, hid_t dxpl_id) +H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/, + H5G_entry_t *obj_ent/*in,out*/, + int *nlinks/*in,out*/, hid_t dxpl_id) { - H5G_trav_ud1_t udata; /* User data to pass to link traversal callback */ - H5G_name_t tmp_obj_path; /* Temporary copy of object's path */ - hbool_t tmp_obj_path_set = FALSE; /* Flag to indicate that tmp object path is initialized */ - H5O_loc_t tmp_grp_oloc; /* Temporary copy of group entry */ - H5G_name_t tmp_grp_path; /* Temporary copy of group's path */ - H5G_loc_t tmp_grp_loc; /* Temporary copy of group's location */ - hbool_t tmp_grp_path_set = FALSE; /* Flag to indicate that tmp group path is initialized */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_slink) - - /* Sanity check */ - HDassert(grp_loc); - HDassert(lnk); - HDassert(lnk->type == H5G_LINK_SOFT); - HDassert(nlinks); - - /* Set up temporary location */ - tmp_grp_loc.oloc = &tmp_grp_oloc; - tmp_grp_loc.path = &tmp_grp_path; - - /* Portably initialize the temporary objects */ - H5G_loc_reset(&tmp_grp_loc); - H5G_name_reset(&tmp_obj_path); - - /* Clone the group location, so we can track the names properly */ - /* ("tracking the names properly" means to ignore the effects of the - * link traversal on the object's & group's paths - QAK) - */ - H5G_loc_copy(&tmp_grp_loc, grp_loc, H5_COPY_DEEP); - tmp_grp_path_set = TRUE; + H5O_stab_t stab_mesg; /*info about local heap */ + const char *clv = NULL; /*cached link value */ + char *linkval = NULL; /*the copied link value */ + H5G_entry_t tmp_grp_ent; /* Temporary copy of group entry */ + H5RS_str_t *tmp_full_path_r = NULL, *tmp_user_path_r = NULL; /* Temporary pointer to object's user path & canonical path */ + const H5HL_t *heap; + herr_t ret_value=SUCCEED; /* Return value */ - /* Hold the object's group hier. path to restore later */ - /* (Part of "tracking the names properly") */ - H5G_name_copy(&tmp_obj_path, obj_loc->path, H5_COPY_SHALLOW); - tmp_obj_path_set = TRUE; + FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_slink); - /* Set up user data for traversal callback */ - udata.obj_loc = obj_loc; + /* Portably initialize the temporary group entry */ + H5G_ent_reset(&tmp_grp_ent); - /* Traverse the link */ - if(H5G_traverse_real(&tmp_grp_loc, lnk->u.soft.name, H5G_TARGET_NORMAL, nlinks, H5G_traverse_link_cb, &udata, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link") + /* Get the link value */ + if (NULL==H5O_read (grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id)) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address"); -done: - /* Restore object's group hier. path */ - if(tmp_obj_path_set) { - H5G_name_free(obj_loc->path); - H5G_name_copy(obj_loc->path, &tmp_obj_path, H5_COPY_SHALLOW); - } /* end if */ + if (NULL == (heap = H5HL_protect(grp_ent->file, dxpl_id, stab_mesg.heap_addr))) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value") - /* Release cloned copy of group path */ - if(tmp_grp_path_set) - H5G_name_free(&tmp_grp_path); + clv = H5HL_offset_into(grp_ent->file, heap, obj_ent->cache.slink.lval_offset); - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_traverse_slink() */ + linkval = H5MM_xstrdup (clv); + assert(linkval); - -/*------------------------------------------------------------------------- - * Function: H5G_traverse_mount - * - * Purpose: If LNK is a mount point then copy the entry for the root - * group of the mounted file into LNK. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_traverse_mount(H5G_loc_t *obj_loc/*in,out*/) -{ - H5F_t *parent = obj_loc->oloc->file; /* File of object */ - unsigned lt, rt, md = 0; /* Binary search indices */ - int cmp; - H5O_loc_t *oloc = NULL; /* Object location for mount points */ - herr_t ret_value = SUCCEED; /* Return value */ + if (H5HL_unprotect(grp_ent->file, dxpl_id, heap, stab_mesg.heap_addr) < 0) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value") - FUNC_ENTER_NOAPI(H5G_traverse_mount, FAIL) + /* Hold the entry's name (& old_name) to restore later */ + tmp_full_path_r = obj_ent->full_path_r; + obj_ent->full_path_r = NULL; + tmp_user_path_r = obj_ent->user_path_r; + obj_ent->user_path_r = NULL; - /* Sanity check */ - HDassert(obj_loc); + /* Free the names for the group entry */ + H5G_name_free(grp_ent); - /* - * The loop is necessary because we might have file1 mounted at the root - * of file2, which is mounted somewhere in file3. - */ - do { - /* - * Use a binary search to find the potential mount point in the mount - * table for the parent - */ - lt = 0; - rt = parent->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - oloc = H5G_oloc(parent->mtab.child[md].group); - cmp = H5F_addr_cmp(obj_loc->oloc->addr, oloc->addr); - if(cmp < 0) - rt = md; - else - lt = md + 1; - } /* end while */ - - /* Copy root info over to ENT */ - if(0 == cmp) { - /* Get the location for the root group in the child's file */ - oloc = H5G_oloc(parent->mtab.child[md].file->shared->root_grp); - - /* Copy the entry for the root group */ - if(H5O_loc_copy(obj_loc->oloc, oloc, H5_COPY_DEEP) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy object location") - - /* Switch to child's file */ - parent = oloc->file; - } /* end if */ - } while(!cmp); + /* Clone the group entry, so we can track the names properly */ + H5G_ent_copy(&tmp_grp_ent,grp_ent,H5_COPY_DEEP); + + /* Traverse the link */ + if (H5G_namei (&tmp_grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks, H5G_NAMEI_TRAVERSE, NULL, dxpl_id)) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link"); + + /* Free the entry's names, we will use the original name for the object */ + H5G_name_free(obj_ent); + + /* Restore previous name for object */ + obj_ent->full_path_r = tmp_full_path_r; + tmp_full_path_r = NULL; + obj_ent->user_path_r = tmp_user_path_r; + tmp_user_path_r = NULL; done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_traverse_mount() */ + /* Error cleanup */ + if(tmp_full_path_r) + H5RS_decr(tmp_full_path_r); + if(tmp_user_path_r) + H5RS_decr(tmp_user_path_r); + + /* Release cloned copy of group entry */ + H5G_name_free(&tmp_grp_ent); + + H5MM_xfree (linkval); + FUNC_LEAVE_NOAPI(ret_value); +} /*------------------------------------------------------------------------- - * Function: H5G_traverse_real + * Function: H5G_namei + * + * Purpose: Translates a name to a symbol table entry. + * + * If the specified name can be fully resolved, then this + * function returns the symbol table entry for the named object + * through the OBJ_ENT argument. The symbol table entry for the + * group containing the named object is returned through the + * GRP_ENT argument if it is non-null. However, if the name + * refers to the root object then the GRP_ENT will be + * initialized with an undefined object header address. The + * REST argument, if present, will point to the null terminator + * of NAME. + * + * If the specified name cannot be fully resolved, then OBJ_ENT + * is initialized with the undefined object header address. The + * REST argument will point into the NAME argument to the start + * of the component that could not be located. The GRP_ENT will + * contain the entry for the symbol table that was being + * searched at the time of the failure and will have an + * undefined object header address if the search failed at the + * root object. For instance, if NAME is `/foo/bar/baz' and the + * root directory exists and contains an entry for `foo', and + * foo is a group that contains an entry for bar, but bar is not + * a group, then the results will be that REST points to `baz', + * OBJ_ENT has an undefined object header address, and GRP_ENT + * is the symbol table entry for `bar' in `/foo'. + * + * Every file has a root group whose name is `/'. Components of + * a name are separated from one another by one or more slashes + * (/). Slashes at the end of a name are ignored. If the name + * begins with a slash then the search begins at the root group + * of the file containing LOC_ENT. Otherwise it begins at + * LOC_ENT. The component `.' is a no-op, but `..' is not + * understood by this function (unless it appears as an entry in + * the symbol table). + * + * Symbolic links are followed automatically, but if TARGET + * includes the H5G_TARGET_SLINK bit and the last component of + * the name is a symbolic link then that link is not followed. + * The *NLINKS value is decremented each time a link is followed + * and link traversal fails if the value would become negative. + * If NLINKS is the null pointer then a default value is used. * - * Purpose: Internal version of path traversal routine + * Mounted files are handled by calling H5F_mountpoint() after + * each step of the translation. If the input argument to that + * function is a mount point then the argument shall be replaced + * with information about the root group of the mounted file. + * But if TARGET includes the H5G_TARGET_MOUNT bit and the last + * component of the name is a mount point then H5F_mountpoint() + * is not called and information about the mount point itself is + * returned. + * + * Errors: * * Return: Success: Non-negative if name can be fully resolved. + * See above for values of REST, GRP_ENT, and + * OBJ_ENT. NLINKS has been decremented for + * each symbolic link that was followed. * * Failure: Negative if the name could not be fully - * resolved. + * resolved. See above for values of REST, + * GRP_ENT, and OBJ_ENT. * * Programmer: Robb Matzke * matzke@llnl.gov * Aug 11 1997 * + * Modifications: + * Robb Matzke, 2002-03-28 + * The component name buffer on the stack has been replaced by + * a dynamically allocated buffer on the heap in order to + * remove limitations on the length of a name component. + * There are two reasons that the buffer pointer is global: + * (1) We want to be able to reuse the buffer without + * allocating and freeing it each time this function is + * called. + * (2) We need to be able to free it from H5G_term_interface() + * when the library terminates. + * + * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 + * Modified to deep copies of symbol table entries + * Added `id to name' support. + * + * Quincey Koziol, 2003-01-06 + * Added "action" and "ent" parameters to allow different actions when + * working on the last component of a name. (Specifically, this allows + * inserting an entry into a group, instead of trying to look it up) + * *------------------------------------------------------------------------- */ -static herr_t -H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, - int *nlinks, H5G_traverse_t op, void *op_data, hid_t dxpl_id) +herr_t +H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/, + H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/, + unsigned target, int *nlinks/*out*/, H5G_namei_act_t action, + H5G_entry_t *ent, hid_t dxpl_id) { - H5G_loc_t loc; /* Location of start object */ - H5O_loc_t grp_oloc; /* Object loc. for current group */ - H5G_name_t grp_path; /* Path for current group */ - H5G_loc_t grp_loc; /* Location of group */ - H5O_loc_t obj_oloc; /* Object found */ - H5G_name_t obj_path; /* Path for object found */ - H5G_loc_t obj_loc; /* Location of object */ - size_t nchars; /* component name length */ - H5O_link_t lnk; /* Link information for object */ - hbool_t link_valid = FALSE; /* Flag to indicate that the link information is valid */ - hbool_t obj_loc_valid = FALSE; /* Flag to indicate that the object location is valid */ - hbool_t group_copy = FALSE; /* Flag to indicate that the group entry is copied */ - hbool_t last_comp = FALSE; /* Flag to indicate that a component is the last component in the name */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_real) - - /* Check parameters */ - HDassert(_loc); - HDassert(name); - HDassert(nlinks); - HDassert(op); + H5G_entry_t _grp_ent; /*entry for current group */ + H5G_entry_t _obj_ent; /*entry found */ + size_t nchars; /*component name length */ + int _nlinks = H5G_NLINKS; + const char *s = NULL; + unsigned null_obj; /* Flag to indicate this function was called with obj_ent set to NULL */ + unsigned null_grp; /* Flag to indicate this function was called with grp_ent set to NULL */ + unsigned obj_copy = 0; /* Flag to indicate that the object entry is copied */ + unsigned group_copy = 0; /* Flag to indicate that the group entry is copied */ + unsigned last_comp = 0; /* Flag to indicate that a component is the last component in the name */ + unsigned did_insert = 0; /* Flag to indicate that H5G_stab_insert was called */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5G_namei); + + /* Set up "out" parameters */ + if (rest) + *rest = name; + if (!grp_ent) { + grp_ent = &_grp_ent; + null_grp = 1; + } /* end if */ + else + null_grp = 0; + if (!obj_ent) { + obj_ent = &_obj_ent; + null_obj = 1; + } /* end if */ + else + null_obj = 0; + if (!nlinks) + nlinks = &_nlinks; + + /* Check args */ + if (!name || !*name) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given"); + if (!loc_ent) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group"); /* * Where does the searching start? For absolute names it starts at the @@ -325,41 +316,22 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, */ /* Check if we need to get the root group's entry */ if('/' == *name) { - H5G_t *root_grp; /* Temporary pointer to root group of file */ + H5G_t *tmp_grp; /* Temporary pointer to root group of file */ /* Look up root group for starting location */ - root_grp = H5G_rootof(_loc->oloc->file); - HDassert(root_grp); + tmp_grp = H5G_rootof(loc_ent->file); + HDassert(tmp_grp); - /* Set the location entry to the root group's info */ - loc.oloc=&(root_grp->oloc); - loc.path=&(root_grp->path); + /* Set the location entry to the root group's entry*/ + loc_ent = &(tmp_grp->ent); } /* end if */ - else { - loc.oloc = _loc->oloc; - loc.path = _loc->path; - } /* end else */ - - /* Set up group & object locations */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - -#if defined(H5_USING_PURIFY) || !defined(NDEBUG) - /* Clear group location */ - if(H5G_loc_reset(&grp_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") -#endif /* H5_USING_PURIFY */ - - /* Deep copy of the starting location to group location */ - if(H5G_loc_copy(&grp_loc, &loc, H5_COPY_DEEP) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to copy location") - group_copy = TRUE; - - /* Clear object location */ - if(H5G_loc_reset(&obj_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to reset location") + + /* Deep copy of the symbol table entry (duplicates strings) */ + if(H5G_ent_copy(obj_ent, loc_ent, H5_COPY_DEEP) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") + obj_copy = 1; + + H5G_ent_reset(grp_ent); /* Check for needing a larger buffer for the individual path name components */ if(HDstrlen(name) + 1 > H5G_comp_alloc_g) { @@ -371,10 +343,11 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, } /* end if */ } /* end if */ - /* Traverse the path */ - while((name = H5G_component(name, &nchars)) && *name) { - const char *s; /* Temporary string pointer */ - herr_t lookup_status; /* Status from object lookup */ + /* traverse the name */ + while ((name = H5G_component(name, &nchars)) && *name) { + /* Update the "rest of name" pointer */ + if(rest) + *rest = name; /* * Copy the component name into a null-terminated buffer so @@ -386,203 +359,103 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target, /* * The special name `.' is a no-op. */ - if('.' == H5G_comp_g[0] && !H5G_comp_g[1]) { + if ('.' == H5G_comp_g[0] && !H5G_comp_g[1]) { name += nchars; continue; } /* end if */ - /* Check if this is the last component of the name */ - if(!((s = H5G_component(name + nchars, NULL)) && *s)) - last_comp = TRUE; - - /* If there's valid information in the link, reset it */ - if(link_valid) { - H5O_reset(H5O_LINK_ID, &lnk); - link_valid = FALSE; - } /* end if */ + /* + * Advance to the next component of the name. + */ + /* If we've already copied a new entry into the group entry, + * it needs to be freed before overwriting it with another entry + */ + if(group_copy) + H5G_name_free(grp_ent); - /* Get information for object in current group */ - /* (Defer issuing error for bad lookup until later) */ - lookup_status = H5G_obj_lookup(grp_loc.oloc, H5G_comp_g, &lnk/*out*/, dxpl_id); - - /* If the lookup was OK, try traversing soft links and mount points, if allowed */ - if(lookup_status >= 0) { - /* Indicate that the link info is valid */ - link_valid = TRUE; - - /* Build object's group hier. location */ - if(H5G_name_set(grp_loc.path, obj_loc.path, H5G_comp_g) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cannot set name") - - /* Set the object location, if it's a hard link set the address also */ - obj_loc.oloc->file = grp_loc.oloc->file; - if(lnk.type == H5G_LINK_HARD) { - obj_loc.oloc->addr = lnk.u.hard.addr; - } /* end if */ - obj_loc_valid = TRUE; - - /* - * If we found a symbolic link then we should follow it. But if this - * is the last component of the name and the H5G_TARGET_SLINK bit of - * TARGET is set then we don't follow it. - */ - if(H5G_LINK_SOFT == lnk.type && - (0 == (target & H5G_TARGET_SLINK) || !last_comp)) { - if((*nlinks)-- <= 0) - HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "too many links") - if(H5G_traverse_slink(&grp_loc/*in,out*/, &lnk/*in*/, &obj_loc, nlinks, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_SLINK, FAIL, "symbolic link traversal failed") - } /* end if */ - - /* - * Resolve mount points to the mounted group. Do not do this step if - * the H5G_TARGET_MOUNT bit of TARGET is set and this is the last - * component of the name. - * - * (If this link is a hard link, try to perform mount point traversal) - * - * (Note that the soft link traversal above can change the status of - * the object (into a hard link), so don't use an 'else' statement - * here. -QAK) - */ - if(H5F_addr_defined(obj_loc.oloc->addr) && - (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) { - if(H5G_traverse_mount(&obj_loc/*in,out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "mount point traversal failed") - } /* end if */ - } /* end if */ + /* Transfer "ownership" of the entry's information to the group entry */ + H5G_ent_copy(grp_ent, obj_ent, H5_COPY_SHALLOW); + H5G_ent_reset(obj_ent); - /* Check for last component in name provided */ - if(last_comp) { - H5O_link_t *tmp_lnk; /* Pointer to link info for callback */ - H5G_loc_t *tmp_loc; /* Pointer to object location for callback */ - - /* Set callback parameters appropriately, based on link being found */ - if(lookup_status < 0) { - tmp_lnk = NULL; - tmp_loc = NULL; - } /* end if */ - else { - tmp_lnk = &lnk; - tmp_loc = &obj_loc; - } /* end else */ - - /* Operator routine will take care of object location, succeed or fail */ - obj_loc_valid = FALSE; - - /* Call 'operator' routine */ - if((op)(&grp_loc, H5G_comp_g, tmp_lnk, tmp_loc, op_data) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CALLBACK, FAIL, "traversal operator failed") - HGOTO_DONE(SUCCEED) - } /* end if */ + /* Set flag that we've copied a new entry into the group entry */ + group_copy = 1; - /* Handle lookup failures now */ - if(lookup_status < 0) { - /* If an intermediate group doesn't exist & flag is set, create the group */ - if(target & H5G_CRT_INTMD_GROUP) { - H5O_ginfo_t ginfo; /* Group info message for parent group */ - - /* Get the group info for parent group */ - if(NULL == H5O_read(grp_loc.oloc, H5O_GINFO_ID, 0, &ginfo, dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") - - /* Create the intermediate group */ -/* XXX: Should we allow user to control the group creation params here? -QAK */ - if(H5G_obj_create(grp_oloc.file, dxpl_id, &ginfo, obj_loc.oloc/*out*/) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group entry") - - /* Insert new group into current group's symbol table */ - if(H5G_loc_insert(&grp_loc, H5G_comp_g, &obj_loc, TRUE, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert intermediate group") - - /* Close new group */ - if(H5O_close(obj_loc.oloc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close") - } /* end if */ - else - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") - } /* end if */ + /* Check if this is the last component of the name */ + if(!((s=H5G_component(name+nchars, NULL)) && *s)) + last_comp=1; + + switch(action) { + case H5G_NAMEI_TRAVERSE: + if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { + /* + * Component was not found in the current symbol table, possibly + * because GRP_ENT isn't a symbol table. + */ + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); + } + break; + + case H5G_NAMEI_INSERT: + if(!last_comp) { + if (H5G_stab_find(grp_ent, H5G_comp_g, obj_ent/*out*/, dxpl_id )<0) { + /* + * Component was not found in the current symbol table, possibly + * because GRP_ENT isn't a symbol table. + */ + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found"); + } + } /* end if */ + else { + did_insert = 1; + if(H5G_stab_insert(grp_ent, H5G_comp_g, ent, TRUE, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert name") + HGOTO_DONE(SUCCEED); + } /* end else */ + break; + } /* end switch */ /* - * Advance to the next component of the path. + * If we found a symbolic link then we should follow it. But if this + * is the last component of the name and the H5G_TARGET_SLINK bit of + * TARGET is set then we don't follow it. */ + if(H5G_CACHED_SLINK==obj_ent->type && + (0==(target & H5G_TARGET_SLINK) || !last_comp)) { + if ((*nlinks)-- <= 0) + HGOTO_ERROR (H5E_SYM, H5E_SLINK, FAIL, "too many links"); + if (H5G_traverse_slink (grp_ent, obj_ent, nlinks, dxpl_id)<0) + HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link traversal failed"); + } - /* Transfer "ownership" of the object's information to the group object */ - H5G_loc_free(&grp_loc); - H5G_loc_copy(&grp_loc, &obj_loc, H5_COPY_SHALLOW); - H5G_loc_reset(&obj_loc); - obj_loc_valid = FALSE; + /* + * Resolve mount points to the mounted group. Do not do this step if + * the H5G_TARGET_MOUNT bit of TARGET is set and this is the last + * component of the name. + */ + if (0==(target & H5G_TARGET_MOUNT) || !last_comp) + H5F_mountpoint(obj_ent/*in,out*/); - /* Advance to next component in string */ + /* next component */ name += nchars; } /* end while */ - /* If we've fallen through to here, the name must be something like just '.' - * and we should issue the callback on that. -QAK - */ - /* Reset "group copied" flag */ - /* (callback will take ownership of group location, succeed or fail) */ - HDassert(group_copy); - group_copy = FALSE; - - /* Call 'operator' routine */ - if((op)(&grp_loc, ".", NULL, &grp_loc, op_data) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTNEXT, FAIL, "traversal operator failed") - HGOTO_DONE(SUCCEED) - -done: - /* If the object location is still valid (usually in an error situation), reset it */ - if(obj_loc_valid) - H5G_loc_free(&obj_loc); - /* If there's valid information in the link, reset it */ - if(link_valid) - H5O_reset(H5O_LINK_ID, &lnk); - /* If we copied something into the group location, free it */ - if(group_copy) - H5G_loc_free(&grp_loc); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_traverse_real() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_traverse - * - * Purpose: Traverse a path from a location & perform an operation when - * the last component of the name is reached. - * - * Return: Success: Non-negative if path can be fully traversed. - * Failure: Negative if the path could not be fully - * traversed. - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Sep 13 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, - void *op_data, hid_t dxpl_id) -{ - int nlinks = H5G_NLINKS; /* Link countdown value */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_traverse, FAIL) - - /* Check args */ - if(!name || !*name) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no name given") - if(!loc) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no starting location") - if(!op) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no operation provided") + /* Update the "rest of name" pointer */ + if (rest) + *rest = name; /*final null */ - /* Go perform "real" traversal */ - if(H5G_traverse_real(loc, name, target, &nlinks, op, op_data, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "path traversal failed") + /* If this was an insert, make sure that the insert function was actually + * called (this catches no-op names like "." and "/") */ + if(action == H5G_NAMEI_INSERT && !did_insert) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group already exists"); done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_traverse() */ + /* If we started with a NULL obj_ent, free the entry information */ + if(null_obj || (ret_value < 0 && obj_copy)) + H5G_name_free(obj_ent); + /* If we started with a NULL grp_ent and we copied something into it, free the entry information */ + if(null_grp && group_copy) + H5G_name_free(grp_ent); + + FUNC_LEAVE_NOAPI(ret_value); +} @@ -1303,39 +1303,23 @@ done: * If a zero is returned for the name's length, then there is no name * associated with the ID. * - * Modifications: - * *------------------------------------------------------------------------- */ ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { - H5G_entry_t *ent; /*symbol table entry */ - size_t len=0; ssize_t ret_value; - FUNC_ENTER_API (H5Iget_name, FAIL); + FUNC_ENTER_API(H5Iget_name, FAIL) H5TRACE3("Zs","ixz",id,name,size); - /* get symbol table entry */ - if(NULL!=(ent = H5G_loc(id))) { - if (ent->user_path_r != NULL && ent->user_path_hidden==0) { - len = H5RS_len(ent->user_path_r); - - if(name) { - HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len+1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ - } /* end if */ - } /* end if */ - - /* Set return value */ - ret_value=(ssize_t)len; + /* Call internal group routine to retrieve object's name */ + if((ret_value = H5G_get_name(id, name, size)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Iget_name() */ /*------------------------------------------------------------------------- @@ -462,7 +462,7 @@ H5O_close(H5G_entry_t *obj_ent) } /* end if */ /* Free the ID to name buffers */ - H5G_free_ent_name(obj_ent); + H5G_name_free(obj_ent); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 013ebb5..2a4a7d8 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -88,17 +88,6 @@ H5FL_EXTERN(H5S_extent_t); This function decodes the "raw" disk form of a attribute message into a struct in memory native format. The struct is allocated within this function using malloc() and is returned to the caller. - * - * Modifications: - * Robb Matzke, 17 Jul 1998 - * Added padding for alignment. - * - * Robb Matzke, 20 Jul 1998 - * Added a version number at the beginning. - * - * Raymond Lu, 8 April 2004 - * Changed Dataspace operation on H5S_simple_t to H5S_extent_t. - * --------------------------------------------------------------------------*/ static void * H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) @@ -107,16 +96,16 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5S_extent_t *extent; /*extent dimensionality information */ size_t name_len; /*attribute name length */ int version; /*message version number*/ - unsigned flags=0; /* Attribute flags */ + unsigned flags = 0; /* Attribute flags */ H5A_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_decode); /* check args */ - assert(f); - assert(p); + HDassert(f); + HDassert(p); - if (NULL==(attr = H5FL_CALLOC(H5A_t))) + if(NULL == (attr = H5FL_CALLOC(H5A_t))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); /* Version number */ @@ -184,8 +173,8 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5FL_FREE(H5S_extent_t,extent); /* Default to entire dataspace being selected */ - if(H5S_select_all(attr->ds,0)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); + if(H5S_select_all(attr->ds, 0) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") if(version < H5O_ATTR_VERSION_NEW) p += H5O_ALIGN(attr->ds_size); @@ -206,9 +195,18 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) attr->initialized=1; /* Set return value */ - ret_value=attr; + ret_value = attr; done: + if(!ret_value) + if(attr) { + /* Free dynamicly allocated items */ + if(H5A_free(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info") + + H5FL_FREE(H5A_t, attr); + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value); } diff --git a/src/H5Odtype.c b/src/H5Odtype.c index a649970..f6ec861 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1105,7 +1105,7 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg, /* If the address is defined, this had better be a named datatype */ HDassert (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state); - H5G_ent_copy(&(sh->ent), &(dt->ent), H5G_COPY_NULL); + H5G_ent_copy(&(sh->ent), &(dt->ent), H5_COPY_NULL); } else HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is not sharable") @@ -1138,7 +1138,7 @@ H5O_dtype_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/, HDassert(sh); /* NULL copy here, names not appropriate */ - H5G_ent_copy(&(dt->ent), &(sh->ent), H5G_COPY_NULL); + H5G_ent_copy(&(dt->ent), &(sh->ent), H5_COPY_NULL); /* Note that the datatype is a named datatype */ dt->shared->state = H5T_STATE_NAMED; diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index f04b45c..073277c 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -143,7 +143,7 @@ typedef struct H5S_iostats_t { #define H5S_GET_SELECT_TYPE(S) ((S)->select.type->type) #define H5S_SELECT_GET_SEQ_LIST(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN) ((*(S)->select.type->get_seq_list)(S,FLAGS,ITER,MAXSEQ,MAXBYTES,NSEQ,NBYTES,OFF,LEN)) #define H5S_SELECT_VALID(S) ((*(S)->select.type->is_valid)(S)) -#define H5S_SELECT_RELEASE(S) ((*(S)->select.type->release)(S)) +#define H5S_SELECT_RELEASE(S) ((S)->select.type ? (*(S)->select.type->release)(S) : SUCCEED) #define H5S_SELECT_SERIAL_SIZE(S) ((*(S)->select.type->serial_size)(S)) #define H5S_SELECT_SERIALIZE(S,BUF) ((*(S)->select.type->serialize)(S,BUF)) #define H5S_SELECT_BOUNDS(S,START,END) ((*(S)->select.type->bounds)(S,START,END)) @@ -2891,9 +2891,9 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* Deep copy of the symbol table entry, if there was one */ if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) { - if (!H5F_addr_defined(old_dt->ent.header)) + if(!H5F_addr_defined(old_dt->ent.header)) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "named dataype with invalid address") - if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5G_COPY_DEEP)<0) + if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5_COPY_DEEP)<0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry") } /* end if */ else { @@ -3078,7 +3078,7 @@ H5T_free(H5T_t *dt) } /* end switch */ /* Free the ID to name info */ - H5G_free_ent_name(&(dt->ent)); + H5G_name_free(&(dt->ent)); /* Close the parent */ if(dt->shared->parent && H5T_close(dt->shared->parent) < 0) @@ -3148,7 +3148,7 @@ H5T_close(H5T_t *dt) } /* end if */ /* Free the ID to name info since we're not calling H5T_free*/ - H5G_free_ent_name(&(dt->ent)); + H5G_name_free(&(dt->ent)); } /* end else */ /* Free the datatype struct */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index b9d6a28..07eb0d4 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -26,6 +26,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5FOprivate.h" /* File objects */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Tpkg.h" /* Datatypes */ @@ -68,8 +69,6 @@ H5T_init_commit_interface(void) * Programmer: Robb Matzke * Monday, June 1, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -77,26 +76,26 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id) { H5G_entry_t *loc = NULL; H5T_t *type = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Tcommit, FAIL) H5TRACE3("e","isi",loc_id,name,type_id); /* Check arguments */ if (NULL==(loc=H5G_loc (loc_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Commit the type */ - if (H5T_commit(loc, name, type, H5AC_dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + if(H5T_commit(loc, name, type, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Tcommit() */ /*------------------------------------------------------------------------- @@ -110,66 +109,64 @@ done: * Programmer: Robb Matzke * Monday, June 1, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) +H5T_commit(H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) { H5F_t *file = NULL; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5T_commit) - HDassert (loc); - HDassert (name && *name); - HDassert (type); + HDassert(loc); + HDassert(name && *name); + HDassert(type); /* * Check arguments. We cannot commit an immutable type because H5Tclose() * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing * a named type should always succeed. */ - if (H5T_STATE_NAMED==type->shared->state || H5T_STATE_OPEN==type->shared->state) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") - if (H5T_STATE_IMMUTABLE==type->shared->state) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") + if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == type->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") /* Find the insertion file */ - if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) + if(NULL == (file = H5G_insertion_file(loc, name, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to find insertion point") /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(type)<=0) + if(H5T_is_sensible(type) <= 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible") /* Mark datatype as being on disk now. This step changes the size of datatype as * stored on disk. */ - if(H5T_vlen_mark(type, file, H5T_VLEN_DISK)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); + if(H5T_vlen_mark(type, file, H5T_VLEN_DISK) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* * Create the object header and open it for write access. Insert the data * type message and then give the object header a name. */ if (H5O_create (file, dxpl_id, 64, &(type->ent))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header") if (H5O_modify (&(type->ent), H5O_DTYPE_ID, 0, H5O_FLAG_CONSTANT, H5O_UPDATE_TIME, type, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message") /* * Give the datatype a name. That is, create and add a new object to the * group this datatype is being initially created in. */ - if (H5G_insert (loc, name, &(type->ent), dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to name datatype") + if(H5G_insert(loc, name, &(type->ent), dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to name datatype") type->shared->state = H5T_STATE_OPEN; type->shared->fo_count=1; /* Add datatype to the list of open objects in the file */ if(H5FO_top_incr(type->ent.file, type->ent.header)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't incr object ref. count") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't incr object ref. count") if(H5FO_insert(type->ent.file, type->ent.header, type->shared)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "can't insert datatype into list of open objects") @@ -179,18 +176,18 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype in memory") done: - if (ret_value<0) { - if ((type->shared->state==H5T_STATE_TRANSIENT || type->shared->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) { + if(ret_value < 0) { + if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) { if(H5O_close(&(type->ent))<0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header") if(H5O_delete(file, dxpl_id,type->ent.header)<0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header") type->ent.header = HADDR_UNDEF; - } - } + } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} +} /* H5T_commit() */ /*------------------------------------------------------------------------- @@ -205,8 +202,6 @@ done: * Programmer: Robb Matzke * Thursday, June 4, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -219,15 +214,15 @@ H5Tcommitted(hid_t type_id) H5TRACE1("t","i",type_id); /* Check arguments */ - if (NULL==(type=H5I_object_verify(type_id,H5I_DATATYPE))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(NULL == (type = H5I_object_verify(type_id,H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ - ret_value= H5T_committed(type); + ret_value = H5T_committed(type); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Tcommitted() */ /*------------------------------------------------------------------------- @@ -240,8 +235,6 @@ done: * Programmer: Quincey Koziol * Wednesday, September 24, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -250,9 +243,9 @@ H5T_committed(const H5T_t *type) /* Use no-init for efficiency */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_committed) - assert (type); + HDassert(type); - FUNC_LEAVE_NOAPI(H5T_STATE_OPEN==type->shared->state || H5T_STATE_NAMED==type->shared->state) + FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state) } /* end H5T_committed() */ @@ -269,8 +262,6 @@ H5T_committed(const H5T_t *type) * Programmer: Quincey Koziol * Friday, September 26, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -281,11 +272,11 @@ H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id) /* Use no-init for efficiency */ FUNC_ENTER_NOAPI(H5T_link,FAIL) - assert (type); + HDassert(type); /* Adjust the link count on the named datatype */ - if((ret_value=H5O_link(&(type->ent),adjust,dxpl_id))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_LINK, FAIL, "unable to adjust named datatype link count") + if((ret_value = H5O_link(&(type->ent), adjust, dxpl_id)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_LINK, FAIL, "unable to adjust named datatype link count") done: FUNC_LEAVE_NOAPI(ret_value) @@ -295,17 +286,15 @@ done: /*------------------------------------------------------------------------- * Function: H5Topen * - * Purpose: Opens a named data type. + * Purpose: Opens a named datatype. * - * Return: Success: Object ID of the named data type. + * Return: Success: Object ID of the named datatype. * * Failure: Negative * * Programmer: Robb Matzke * Monday, June 1, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -316,23 +305,23 @@ H5Topen(hid_t loc_id, const char *name) H5G_entry_t ent; hbool_t ent_found = FALSE; /* Entry at 'name' found */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ - hid_t ret_value =FAIL; + hid_t ret_value = FAIL; - FUNC_ENTER_API(H5Topen, FAIL); + FUNC_ENTER_API(H5Topen, FAIL) H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc (loc_id))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); - if (!name || !*name) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* - * Find the named data type object header and read the data type message + * Find the named datatype object header and read the datatype message * from it. */ - if (H5G_find (loc, name, &ent/*out*/, dxpl_id)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found"); + if(H5G_find(loc, name, &ent/*out*/, dxpl_id)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") ent_found = TRUE; /* Check that the object found is the correct type */ @@ -340,54 +329,51 @@ H5Topen(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype") /* Open it */ - if ((type=H5T_open (&ent, dxpl_id)) ==NULL) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type"); + if((type = H5T_open(&ent, dxpl_id)) == NULL) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") /* Register the type and return the ID */ - if ((ret_value=H5I_register (H5I_DATATYPE, type))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type"); + if((ret_value = H5I_register(H5I_DATATYPE, type)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype") done: - if(ret_value<0) { - if(type!=NULL) + if(ret_value < 0) { + if(type != NULL) H5T_close(type); else { if(ent_found && ent.header) - H5G_free_ent_name(&ent); + H5G_name_free(&ent); } /* end else */ } /* end if */ - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Topen() */ /*------------------------------------------------------------------------- * Function: H5T_open * - * Purpose: Open a named data type. + * Purpose: Open a named datatype. * - * Return: Success: Ptr to a new data type. + * Return: Success: Ptr to a new datatype. * * Failure: NULL * * Programmer: Robb Matzke * Monday, June 1, 1998 * - * Modifications: - * Changed to use H5T_open_oid - QAK - 3/17/99 - * *------------------------------------------------------------------------- */ -H5T_t* -H5T_open (H5G_entry_t *ent, hid_t dxpl_id) +H5T_t * +H5T_open(H5G_entry_t *ent, hid_t dxpl_id) { - H5T_shared_t *shared_fo=NULL; - H5T_t *dt=NULL; + H5T_shared_t *shared_fo = NULL; + H5T_t *dt = NULL; H5T_t *ret_value; - FUNC_ENTER_NOAPI(H5T_open, NULL); + FUNC_ENTER_NOAPI(H5T_open, NULL) - assert (ent); + HDassert(ent); /* Check if datatype was already open */ if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) { @@ -395,8 +381,8 @@ H5T_open (H5G_entry_t *ent, hid_t dxpl_id) H5E_clear(); /* Open the datatype object */ - if ((dt=H5T_open_oid(ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found"); + if((dt = H5T_open_oid(ent, dxpl_id)) ==NULL) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") /* Add the datatype to the list of opened objects in the file */ if(H5FO_insert(dt->ent.file, dt->ent.header, dt->shared)<0) @@ -410,18 +396,17 @@ H5T_open (H5G_entry_t *ent, hid_t dxpl_id) if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") - dt->shared->fo_count=1; - } - else - { + dt->shared->fo_count = 1; + } /* end if */ + else { if(NULL == (dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") /* Shallow copy (take ownership) of the group entry object */ - if(H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW)<0) + if(H5G_ent_copy(&(dt->ent),ent,H5_COPY_SHALLOW)<0) HGOTO_ERROR (H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy group entry") - dt->shared=shared_fo; + dt->shared = shared_fo; shared_fo->fo_count++; @@ -435,47 +420,47 @@ H5T_open (H5G_entry_t *ent, hid_t dxpl_id) /* Increment object count for the object in the top file */ if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count") - } + } /* end else */ ret_value = dt; done: - if(ret_value==NULL) { + if(ret_value == NULL) { if(dt) { - if(shared_fo==NULL) /* Need to free shared fo */ + if(shared_fo == NULL) /* Need to free shared fo */ H5FL_FREE(H5T_shared_t, dt->shared); H5FL_FREE(H5T_t, dt); - } + } /* end if */ + if(shared_fo) shared_fo->fo_count--; - } - FUNC_LEAVE_NOAPI(ret_value); -} + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_open() */ /*------------------------------------------------------------------------- * Function: H5T_open_oid * - * Purpose: Open a named data type. + * Purpose: Open a named datatype. * - * Return: Success: Ptr to a new data type. + * Return: Success: Ptr to a new datatype. * * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, March 17, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ H5T_t * H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id) { - H5T_t *dt=NULL; + H5T_t *dt = NULL; H5T_t *ret_value; - FUNC_ENTER_NOAPI(H5T_open_oid, NULL); + FUNC_ENTER_NOAPI(H5T_open_oid, NULL) assert (ent); @@ -488,17 +473,17 @@ H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id) dt->shared->state = H5T_STATE_OPEN; /* Shallow copy (take ownership) of the group entry object */ - H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW); + H5G_ent_copy(&(dt->ent),ent,H5_COPY_SHALLOW); /* Set return value */ - ret_value=dt; + ret_value = dt; done: - if(ret_value==NULL) { - if(dt==NULL) + if(ret_value == NULL) { + if(dt == NULL) H5O_close(ent); } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_open_oid() */ diff --git a/src/H5private.h b/src/H5private.h index 18363a1..0984cb3 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -502,6 +502,14 @@ H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/); H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds); +/* Depth of object copy */ +typedef enum { + H5_COPY_NULL, /* Null destination names */ + H5_COPY_LIMITED, /* Limited copy from source to destination, omitting path fields */ + H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */ + H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */ +} H5_copy_depth_t; + /* * Redefine all the POSIX functions. We should never see a POSIX * function (or any other non-HDF5 function) in the source! diff --git a/src/Makefile.in b/src/Makefile.in index 3da5c1b..df6517f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -36,7 +36,9 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5C.c H5D.c H5Dcontig.c \ H5Fdbg.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c \ H5FDcore.c H5FDfamily.c H5FDgass.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDsrb.c H5FDstdio.c \ - H5FDstream.c H5FL.c H5FO.c H5FS.c H5G.c H5Gent.c H5Gnode.c H5Gstab.c \ + H5FDstream.c H5FL.c H5FO.c H5FS.c H5G.c H5Gent.c H5Gname.c \ + H5Gnode.c H5Gstab.c \ + H5Gtest.c H5Gtraverse.c \ H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c H5O.c \ H5Oattr.c H5Obogus.c H5Ocache.c \ H5Ocont.c H5Odtype.c H5Oefl.c H5Ofill.c H5Olayout.c H5Omtime.c \ diff --git a/test/getname.c b/test/getname.c index 5ee2139..d5404cc 100644 --- a/test/getname.c +++ b/test/getname.c @@ -19,8 +19,13 @@ * Purpose: Tests the "ID to name" functionality */ -#include "hdf5.h" +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ + +/* Define this macro to indicate that the testing APIs should be available */ +#define H5G_TESTING + #include "h5test.h" +#include "H5Gpkg.h" /* Groups */ /* Compound datatype */ @@ -42,17 +47,41 @@ const char *FILENAME[] = { #define NX 4 #define NY 5 -static int check_name( char *name, const char* check ) +#define NAME_BUF_SIZE 64 +#define SMALL_NAME_BUF_SIZE 2 + +static int +check_name(hid_t id, const char *chk_name, const char *chk_user_path) { + char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ + char user_path[NAME_BUF_SIZE]; /* Buffer to hold user path */ + size_t user_path_len; /* Length of user path */ + unsigned user_path_hidden; /* Whether the user path is hidden */ - int ret = HDstrcmp( name, check ); - HDstrcpy( name, "" ); - return ret; + /* Get name */ + *name = '\0'; + if(H5Iget_name(id, name, NAME_BUF_SIZE) < 0) goto error; -} + /* Get user path */ + *user_path = '\0'; + if(H5G_user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) goto error; -#define NAME_BUF_SIZE 40 -#define SMALL_NAME_BUF_SIZE 2 + /* Check on name from H5Iget_name() */ + if(HDstrcmp(name, chk_name)) goto error; + + /* Check on user path */ + if(HDstrcmp(user_path, chk_user_path)) goto error; + + /* Check that if user path is hidden, the name from H5Iget_name() and the user path should be different */ + if(user_path_hidden && !HDstrcmp(chk_name, chk_user_path)) goto error; + + /* Everything matches */ + return 0; + +error: + /* Something doesn't match or something bad happened */ + return -1; +} int main( void ) { @@ -68,16 +97,7 @@ int main( void ) hid_t type_id, type2_id; hsize_t dims[1] = { 5 }; - /*buffer to hold name and its size */ - char name[NAME_BUF_SIZE]; - size_t size=NAME_BUF_SIZE; - - /*small buffer to hold name and its size */ - char name2[SMALL_NAME_BUF_SIZE]; - size_t size2=SMALL_NAME_BUF_SIZE; - - /*dynamic buffer to hold name and its size */ - char *name3 = NULL; + /* Name length */ size_t name_len; /* Reset the library and get the file access property list */ @@ -91,7 +111,7 @@ int main( void ) h5_fixname(FILENAME[3], fapl, filename3, sizeof filename3); /* Create a new file_id using default properties. */ - if ((file_id = H5Fcreate( filename0, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; + if ((file_id = H5Fcreate( filename0, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; /*------------------------------------------------------------------------- @@ -102,13 +122,10 @@ int main( void ) TESTING("H5Iget_name with H5Gcreate, one group"); /* Create group "g0" in the root group using absolute name */ - if ((group_id = H5Gcreate( file_id, "/g0", 0 ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g0", 0 ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g0" )!=0) goto out; + if(check_name(group_id, "/g0", "/g0") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -125,24 +142,16 @@ int main( void ) TESTING("H5Iget_name with H5Gcreate, more than one group"); /* Create group "g1" in the root group using absolute name */ - if ((group_id = H5Gcreate( file_id, "/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g1", 0 ))<0) TEST_ERROR; /* Create group "g2" in group "g1" using absolute name */ - if ((group2_id = H5Gcreate( file_id, "/g1/g2", 0 ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if ((group2_id = H5Gcreate( file_id, "/g1/g2", 0 ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1" )!=0) - goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/g2" )!=0) - goto out; + if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -159,24 +168,16 @@ int main( void ) TESTING("H5Iget_name with H5Gopen"); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "/g1" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "/g1" ))<0) TEST_ERROR; /* Reopen the group */ - if ((group2_id = H5Gopen( file_id, "/g1/g2" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if ((group2_id = H5Gopen( file_id, "/g1/g2" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1" )!=0) - goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/g2" )!=0) - goto out; + if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -194,36 +195,26 @@ int main( void ) TESTING("H5Iget_name with H5Dcreate"); - /* Create the data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create the dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file_id , "d1", H5T_NATIVE_INT, space_id, - H5P_DEFAULT ))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/d1" )!=0) - goto out; + if(check_name(dataset_id, "/d1", "/d1") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "g1" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "g1" ))<0) TEST_ERROR; /* Create a new dataset inside "g1" */ - if ((dataset_id = H5Dcreate( group_id , "d1", H5T_NATIVE_INT, space_id, - H5P_DEFAULT ))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if ((dataset_id = H5Dcreate( group_id , "d1", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/d1" )!=0) - goto out; + if(check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -242,31 +233,23 @@ int main( void ) TESTING("H5Iget_name with H5Dopen"); /* Reopen the dataset */ - if ((dataset_id = H5Dopen( file_id, "d1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if ((dataset_id = H5Dopen( file_id, "d1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/d1" )!=0) - goto out; + if(check_name(dataset_id, "/d1", "/d1") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "g1" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "g1" ))<0) TEST_ERROR; /* Reopen the dataset */ - if ((dataset_id = H5Dopen( group_id, "d1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if ((dataset_id = H5Dopen( group_id, "d1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/d1" )!=0) - goto out; + if(check_name(dataset_id, "/g1/d1", "/g1/d1") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -284,14 +267,14 @@ int main( void ) TESTING("H5Iget_name with a long path"); /* Create group "g2/bar/baz" */ - if ((group_id = H5Gcreate( file_id, "g2", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g2/bar", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "g2/bar/baz", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g2", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g2/bar", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g2/bar/baz", 0 ))<0) TEST_ERROR; /* Create a dataset */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; if ((dataset_id = H5Dcreate( group3_id , "d1", H5T_NATIVE_INT, space_id, - H5P_DEFAULT ))<0) goto out; + H5P_DEFAULT ))<0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -301,14 +284,10 @@ int main( void ) H5Gclose( group3_id ); /* Reopen the dataset */ - if ((dataset_id = H5Dopen( file_id, "/g2/bar/baz/d1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )< 0) goto out; + if ((dataset_id = H5Dopen( file_id, "/g2/bar/baz/d1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g2/bar/baz/d1" )!=0) - goto out; + if(check_name(dataset_id, "/g2/bar/baz/d1", "/g2/bar/baz/d1") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -324,22 +303,18 @@ int main( void ) TESTING("H5Iget_name with H5Tcommit"); /* Create a datatype */ - if ((type_id = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) goto out; + if ((type_id = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) TEST_ERROR; /* Insert fields */ - if (H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0) goto out; - if (H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0) goto out; - if (H5Tinsert (type_id, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT)<0) goto out; + if (H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0) TEST_ERROR; + if (H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0) TEST_ERROR; + if (H5Tinsert (type_id, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT)<0) TEST_ERROR; /* Save datatype for later */ - if (H5Tcommit (file_id, "t1", type_id)<0) goto out; - - /* Get name */ - if (H5Iget_name( type_id, name, size )<0) goto out; + if (H5Tcommit (file_id, "t1", type_id)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/t1" )!=0) - goto out; + if(check_name(type_id, "/t1", "/t1") < 0) TEST_ERROR; /* Close datatype */ H5Tclose(type_id); @@ -354,15 +329,10 @@ int main( void ) TESTING("H5Iget_name with H5Topen"); /* Open the named datatype */ - if((type_id=H5Topen(file_id, "t1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( type_id, name, size )<0) goto out; + if((type_id=H5Topen(file_id, "t1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/t1" )!=0) - goto out; - + if(check_name(type_id, "/t1", "/t1") < 0) TEST_ERROR; /* Close datatype */ H5Tclose(type_id); @@ -379,16 +349,13 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and H5Gopen"); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "/g1" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "/g1" ))<0) TEST_ERROR; /* Rename group */ - if (H5Gmove( file_id, "/g1", "/g1a" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g1", "/g1a" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1a" )!=0) goto out; + if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -406,17 +373,13 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and H5Dopen"); /* Reopen the dataset */ - if ((dataset_id = H5Dopen( file_id, "/d1"))<0) goto out; + if ((dataset_id = H5Dopen( file_id, "/d1"))<0) TEST_ERROR; /* Rename dataset */ - if (H5Gmove( file_id, "/d1", "/d1a" )<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/d1", "/d1a" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/d1a" )!=0) - goto out; + if(check_name(dataset_id, "/d1a", "/d1a") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -434,18 +397,13 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and H5Topen"); /* Open the named datatype */ - if((type_id=H5Topen(file_id, "/t1"))<0) goto out; + if((type_id=H5Topen(file_id, "/t1"))<0) TEST_ERROR; /* Rename datatype */ - if (H5Gmove( file_id, "/t1", "/t1a" )<0) goto out; - - /* Get name */ - if (H5Iget_name( type_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/t1", "/t1a" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/t1a" )!=0) - goto out; - + if(check_name(type_id, "/t1a", "/t1a") < 0) TEST_ERROR; /* Close datatype */ H5Tclose(type_id); @@ -460,55 +418,37 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and relative names"); /* Create group "/g3" */ - if ((group_id = H5Gcreate( file_id, "/g3", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g3", 0 ))<0) TEST_ERROR; /* Create group "/g3/foo" using absolute name */ - if ((group2_id = H5Gcreate( file_id, "/g3/foo1", 0 ))<0) goto out; + if ((group2_id = H5Gcreate( file_id, "/g3/foo1", 0 ))<0) TEST_ERROR; /* Open group "/g3/foo" again */ - if ((group3_id = H5Gopen( file_id, "/g3/foo1"))<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g3/foo1"))<0) TEST_ERROR; /* Rename group */ - if (H5Gmove( group_id, "foo1", "foo2" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Gmove( group_id, "foo1", "foo2" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/foo2" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if(check_name(group2_id, "/g3/foo2", "/g3/foo2") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/foo2" )!=0) goto out; + if(check_name(group3_id, "/g3/foo2", "/g3/foo2") < 0) TEST_ERROR; /* Rename group again */ - if (H5Gmove( file_id, "g3/foo2", "g3/foo1" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Gmove( file_id, "g3/foo2", "g3/foo1" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group_id, "/g3", "/g3") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/foo1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if(check_name(group2_id, "/g3/foo1", "/g3/foo1") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/foo1" )!=0) goto out; + if(check_name(group3_id, "/g3/foo1", "/g3/foo1") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -528,53 +468,37 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and a long path"); /* Create group "g4/A/B" */ - if ((group_id = H5Gcreate( file_id, "g4", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g4/A", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "g4/A/B", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g4", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g4/A", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g4/A/B", 0 ))<0) TEST_ERROR; /* Create group "g5/C" */ - if ((group4_id = H5Gcreate( file_id, "g5", 0 ))<0) goto out; - if ((group5_id = H5Gcreate( file_id, "g5/C", 0 ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if ((group4_id = H5Gcreate( file_id, "g5", 0 ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file_id, "g5/C", 0 ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g4/A/B" )!=0) - goto out; + if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR; /* Move group "B" to "D"*/ - if (H5Gmove( file_id, "/g4/A/B", "/g5/C/D" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g4/A/B", "/g5/C/D" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g5/C/D" )!=0) goto out; + if(check_name(group3_id, "/g5/C/D", "/g5/C/D") < 0) TEST_ERROR; /* Move group "/g5/C/D" back to "/g4/A/B" using relative name */ - if (H5Gmove2( group5_id, "D", group2_id, "B" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove2( group5_id, "D", group2_id, "B" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g4/A/B" )!=0) goto out; + if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR; /* Move group "/g4/A/B" to "/g4/F/B" using relative name */ - if (H5Gmove2( group_id, "A", group_id, "F")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove2( group_id, "A", group_id, "F")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g4/F/B" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group3_id, "/g4/F/B", "/g4/F/B") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g4/F" )!=0) goto out; + if(check_name(group2_id, "/g4/F", "/g4/F") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -594,32 +518,22 @@ int main( void ) TESTING("H5Iget_name with H5Gmove and a long path #2"); /* Create group "g6/A/B" and "g7" */ - if ((group_id = H5Gcreate( file_id, "g6", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g6/A", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "g6/A/B", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file_id, "g7", 0 ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if ((group_id = H5Gcreate( file_id, "g6", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g6/A", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g6/A/B", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "g7", 0 ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g6/A/B" )!=0) - goto out; + if(check_name(group3_id, "/g6/A/B", "/g6/A/B") < 0) TEST_ERROR; /* Move group "A" to "C"*/ - if (H5Gmove( file_id, "/g6/A", "/g7/C" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g6/A", "/g7/C" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g7/C" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if(check_name(group2_id, "/g7/C", "/g7/C") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g7/C/B" )!=0) goto out; + if(check_name(group3_id, "/g7/C/B", "/g7/C/B") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -637,16 +551,13 @@ int main( void ) TESTING("H5Iget_name with H5Gunlink"); /* Create a new group. */ - if ((group_id = H5Gcreate( file_id, "/g8", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g8", 0 ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file_id, "/g8")<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g8")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -661,47 +572,35 @@ int main( void ) TESTING("H5Iget_name with H5Gunlink and a long path"); /* Create group "g9/a/b" */ - if ((group_id = H5Gcreate( file_id, "g9", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g9/a", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "g9/a/b", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g9", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g9/a", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g9/a/b", 0 ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file_id, "/g9/a")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g9/a")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group2_id ); H5Gclose( group3_id ); /* Recreate groups */ - if ((group2_id = H5Gcreate( group_id, "a", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) goto out; + if ((group2_id = H5Gcreate( group_id, "a", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) TEST_ERROR; /* Delete, using relative path */ - if (H5Gunlink( group_id, "a")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gunlink( group_id, "a")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group2_id ); @@ -711,33 +610,27 @@ int main( void ) H5Gclose( group_id ); /* Create group "g10/a/b" */ - if ((group_id = H5Gcreate( file_id, "g10", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g10/a", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "g10/a/b", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g10", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g10/a", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "g10/a/b", 0 ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file_id, "/g10/a/b")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g10/a/b")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group3_id ); /* Recreate group */ - if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) goto out; + if ((group3_id = H5Gcreate( group_id, "a/b", 0 ))<0) TEST_ERROR; /* Delete, using relative path */ - if (H5Gunlink( group_id, "a/b")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gunlink( group_id, "a/b")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group3_id ); @@ -757,28 +650,22 @@ int main( void ) /* Create group "g11/g" */ - if ((group_id = H5Gcreate( file_id, "g11", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "g11/g", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g11", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "g11/g", 0 ))<0) TEST_ERROR; /* Create two datasets "g11/d" and "g11/g/d"*/ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; - if ((dataset_id = H5Dcreate( group_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; - if ((dataset2_id = H5Dcreate( group2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; + if ((dataset_id = H5Dcreate( group_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; + if ((dataset2_id = H5Dcreate( group2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file_id, "/g11/d")<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g11/d")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( dataset2_id, name, size )<0) goto out; + if(check_name(dataset_id, "", "") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g11/g/d" )!=0) goto out; + if(check_name(dataset2_id, "/g11/g/d", "/g11/g/d") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -798,7 +685,7 @@ int main( void ) TESTING("H5Iget_name with H5Fmount; with IDs on the list"); /* Create a group "g12" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g12", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g12", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -806,28 +693,25 @@ int main( void ) /* Create second file and dataset "d" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - /* Create a data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create a dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Create the dataset */ - if ((dataset_id = H5Dcreate( file1_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((dataset_id = H5Dcreate( file1_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); /* Mount second file under "g12" in the first file */ - if (H5Fmount(file_id, "/g12", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g12", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Access dataset D in the first file under "/G/D" name */ - if ((dataset_id = H5Dopen( file_id, "/g12/d"))<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )< 0) goto out; + if ((dataset_id = H5Dopen( file_id, "/g12/d"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g12/d" )!=0) goto out; + if(check_name(dataset_id, "/g12/d", "/g12/d") < 0) TEST_ERROR; - if (H5Funmount(file_id, "/g12")<0) goto out; + if (H5Funmount(file_id, "/g12")<0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -846,9 +730,9 @@ int main( void ) TESTING("H5Iget_name with H5Fmount; long name"); /* Create a group "g13/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g13", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g13/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g13/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g13", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g13/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g13/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -858,9 +742,9 @@ int main( void ) /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g14", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g14/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g14/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g14", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g14/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g14/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -868,78 +752,69 @@ int main( void ) H5Gclose( group3_id ); /* Mount second file under "/g13/g1" in the first file */ - if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; - if (H5Funmount(file_id, "/g13/g1")<0) goto out; + if (H5Funmount(file_id, "/g13/g1")<0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); + + /* Access group in the file to mount */ + if ((group3_id = H5Gopen( file1_id, "/g14/g3/g4"))<0) TEST_ERROR; + /* Mount second file under "/g13/g1" in the first file (again) */ - if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Get a group ID for the parent of the newly mounted group */ - if ((group2_id = H5Gopen( file_id, "/g13"))<0) goto out; + if ((group2_id = H5Gopen( file_id, "/g13"))<0) TEST_ERROR; /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; - - if (H5Funmount(group2_id, "g1")<0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; + if(check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(group2_id, "g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g14/g3/g4", "/g14/g3/g4") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); H5Gclose( group2_id ); + H5Gclose( group3_id ); /* Mount second file under "/g13/g1" in the first file (again) */ - if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g13/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Get a group ID for the newly mounted group */ - if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) goto out; + if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) TEST_ERROR; /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; - - if (H5Funmount(group2_id, ".")<0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; + if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(group2_id, ".")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -947,56 +822,41 @@ int main( void ) /* Mount second file under "/g13/g1" in the first file, using relative path */ - if ((group3_id = H5Gopen( file_id, "/g13"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if ((group3_id = H5Gopen( file_id, "/g13"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13" )!=0) goto out; + if(check_name(group3_id, "/g13", "/g13") < 0) TEST_ERROR; - if (H5Fmount(group3_id, "g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(group3_id, "g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Get a group ID for the newly mounted group */ - if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1" )!=0) goto out; + if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR; /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); /* Access group in the first file, with relative path */ - if ((group_id = H5Gopen( group2_id, "g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( group2_id, "g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); - if (H5Funmount(group2_id, ".")<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(group2_id, ".")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group2_id ); @@ -1004,56 +864,42 @@ int main( void ) /* Mount second file under "/g13/g1" in the first file, using relative path */ - if ((group3_id = H5Gopen( file_id, "/g13/g1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if ((group3_id = H5Gopen( file_id, "/g13/g1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1" )!=0) goto out; + if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR; - if (H5Fmount(group3_id, ".", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(group3_id, ".", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Get a group ID for the newly mounted group */ - if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if ((group2_id = H5Gopen( file_id, "/g13/g1"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1" )!=0) goto out; + if(check_name(group2_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR; /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g13/g1/g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); /* Access group in the first file, with relative path */ - if ((group_id = H5Gopen( group2_id, "g14/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( group2_id, "g14/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g13/g1/g14/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g13/g1/g14/g3/g4", "/g13/g1/g14/g3/g4") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); - if (H5Funmount(group2_id, ".")<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(group2_id, ".")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR; /* Close */ H5Gclose( group2_id ); @@ -1073,10 +919,10 @@ int main( void ) TESTING("H5Iget_name with H5Funmount"); /* Create a group "g15/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g15", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g15/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g15/g1/g2", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file_id, "/g15/g1/g2/g3", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g15", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g15/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g15/g1/g2", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "/g15/g1/g2/g3", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1087,9 +933,9 @@ int main( void ) /* Create second file and group "g" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g16", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g16/g4", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g16/g4/g5", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g16", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g16/g4", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g16/g4/g5", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1097,43 +943,27 @@ int main( void ) H5Gclose( group3_id ); /* Access group in the first file */ - if ((group_id = H5Gopen( file_id, "/g15/g1/g2/g3"))<0) goto out; + if ((group_id = H5Gopen( file_id, "/g15/g1/g2/g3"))<0) TEST_ERROR; /* Mount second file under "/g13/g1" in the first file */ - if (H5Fmount(file_id, "/g15/g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g15/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Access group in the second file */ - if ((group2_id = H5Gopen( file_id, "/g15/g1/g16/g4/g5"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group2_id = H5Gopen( file_id, "/g15/g1/g16/g4/g5"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) - goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if(check_name(group_id, "", "/g15/g1/g2/g3") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g15/g1/g16/g4/g5" )!=0) - goto out; - - if (H5Funmount(file_id, "/g15/g1")<0) goto out; + if(check_name(group2_id, "/g15/g1/g16/g4/g5", "/g15/g1/g16/g4/g5") < 0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g15/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g15/g1/g2/g3" )!=0) - goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if(check_name(group_id, "/g15/g1/g2/g3", "/g15/g1/g2/g3") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) - goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1152,25 +982,25 @@ int main( void ) TESTING("H5Iget_name with a defined type dataset"); /* Create a datatype */ - if ((type_id = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) goto out; + if ((type_id = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)))<0) TEST_ERROR; /* Insert fields */ - if (H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0) goto out; - if (H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0) goto out; - if (H5Tinsert (type_id, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT)<0) goto out; + if (H5Tinsert (type_id, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT)<0) TEST_ERROR; + if (H5Tinsert (type_id, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT)<0) TEST_ERROR; + if (H5Tinsert (type_id, "c", HOFFSET(s1_t,c), H5T_NATIVE_FLOAT)<0) TEST_ERROR; /* Create group "g17" */ - if ((group_id = H5Gcreate( file_id, "g17", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "g17", 0 ))<0) TEST_ERROR; /* Save datatype for later */ - if (H5Tcommit (group_id, "t", type_id)<0) goto out; + if (H5Tcommit (group_id, "t", type_id)<0) TEST_ERROR; - /* Create a data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create a dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Create a new dataset */ if ((dataset_id = H5Dcreate( group_id , "d", type_id, space_id, - H5P_DEFAULT ))<0) goto out; + H5P_DEFAULT ))<0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -1179,30 +1009,22 @@ int main( void ) H5Gclose( group_id ); /* Open the named datatype */ - if((type_id=H5Topen(file_id, "/g17/t"))<0) goto out; - - /* Get name */ - if (H5Iget_name( type_id, name, size )<0) goto out; + if((type_id=H5Topen(file_id, "/g17/t"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g17/t" )!=0) - goto out; + if(check_name(type_id, "/g17/t", "/g17/t") < 0) TEST_ERROR; /* Close datatype */ H5Tclose(type_id); /* Reopen the dataset */ - if ((dataset_id = H5Dopen( file_id, "/g17/d"))<0) goto out; + if ((dataset_id = H5Dopen( file_id, "/g17/d"))<0) TEST_ERROR; /* Get datatype*/ - if((type_id=H5Dget_type(dataset_id))<0) goto out; - - /* Get name */ - if (H5Iget_name( type_id, name, size )< 0) goto out; + if((type_id=H5Dget_type(dataset_id))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) - goto out; + if(check_name(type_id, "", "") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -1219,21 +1041,18 @@ int main( void ) TESTING("H5Iget_name with datasets that have two names"); /* Open dataset named "d"*/ -if ((dataset_id = H5Dopen( file_id, "/g17/d"))<0) goto out; +if ((dataset_id = H5Dopen( file_id, "/g17/d"))<0) TEST_ERROR; /* Create link to dataset named "link" */ -if (H5Glink2(dataset_id,".",H5G_LINK_HARD,file_id,"/g17/link")<0) goto out; -if ((dataset2_id = H5Dopen( file_id, "/g17/link"))<0) goto out; +if (H5Glink2(dataset_id,".",H5G_LINK_HARD,file_id,"/g17/link")<0) TEST_ERROR; +if ((dataset2_id = H5Dopen( file_id, "/g17/link"))<0) TEST_ERROR; /* Make sure that the two IDs use two different names */ -if(H5Iget_name(dataset_id, name, size)<0) goto out; -if(check_name(name, "/g17/d")!=0) goto out; - -if(H5Iget_name(dataset2_id, name, size)<0) goto out; -if(check_name(name, "/g17/link")!=0) goto out; + if(check_name(dataset_id, "/g17/d", "/g17/d") < 0) TEST_ERROR; + if(check_name(dataset2_id, "/g17/link", "/g17/link") < 0) TEST_ERROR; -if(H5Dclose(dataset_id)<0) goto out; -if(H5Dclose(dataset2_id)<0) goto out; +if(H5Dclose(dataset_id)<0) TEST_ERROR; +if(H5Dclose(dataset2_id)<0) TEST_ERROR; PASSED(); @@ -1245,34 +1064,28 @@ PASSED(); TESTING("H5Iget_name with different files"); /* Create a new file using default properties. */ - if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; + if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; /* Create a new file using default properties. */ - if ((file3_id = H5Fcreate( filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; + if ((file3_id = H5Fcreate( filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; - /* Create the data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create the dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((dataset_id = H5Dcreate( file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset2_id = H5Dcreate( file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((dataset2_id = H5Dcreate( file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file2_id, "/d")<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (H5Gunlink( file2_id, "/d")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( dataset2_id, name, size )<0) goto out; + if(check_name(dataset_id, "", "") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/d" )!=0) goto out; + if(check_name(dataset2_id, "/d", "/d") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -1292,34 +1105,28 @@ PASSED(); TESTING("H5Iget_name with different files #2"); /* Create a new file using default properties. */ - if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; + if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; /* Create a new file using default properties. */ - if ((file3_id = H5Fcreate( filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; + if ((file3_id = H5Fcreate( filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; - /* Create the data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create the dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((dataset_id = H5Dcreate( file2_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset2_id = H5Dcreate( file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; + if ((dataset2_id = H5Dcreate( file3_id , "d", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file3_id, "/d")<0) goto out; - - /* Get name */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; + if (H5Gunlink( file3_id, "/d")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/d" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( dataset2_id, name, size )<0) goto out; + if(check_name(dataset_id, "/d", "/d") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(dataset2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Dclose( dataset_id ); @@ -1338,17 +1145,22 @@ PASSED(); TESTING("H5Iget_name with a small buffer for name"); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "/g17" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "/g17" ))<0) TEST_ERROR; + +{ + /*small buffer to hold name and its size */ + char name2[SMALL_NAME_BUF_SIZE]; /* Get name */ - name_len=H5Iget_name( group_id, name2, size2 ); + name_len=H5Iget_name( group_id, name2, SMALL_NAME_BUF_SIZE ); - if ( name_len > size2 ) - /* Get name with a larger buffer */ - name_len=H5Iget_name( group_id, name, size ); + /* Check that name is longer */ + if(name_len <= SMALL_NAME_BUF_SIZE) TEST_ERROR; + if(HDstrcmp(name2, "/")) TEST_ERROR; +} /* Verify */ - if (check_name( name, "/g17" )!=0) goto out; + if(check_name(group_id, "/g17", "/g17") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1364,30 +1176,34 @@ PASSED(); TESTING("H5Iget_name with a dynamic buffer for name"); /* Reopen the group */ - if ((group_id = H5Gopen( file_id, "/g17" ))<0) goto out; + if ((group_id = H5Gopen( file_id, "/g17" ))<0) TEST_ERROR; /* Get name */ - name_len=H5Iget_name( group_id, NULL, size ); + name_len = H5Iget_name(group_id, NULL, NAME_BUF_SIZE); + +{ + /* dynamic buffer to hold name */ + char *name3; /* Include the extra null character */ - name3 = malloc(name_len+1); + name3 = HDmalloc(name_len + 1); + if(!name3) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name3, name_len+1 )<0) goto out; + /* Get name with dynamic buffer */ + if(H5Iget_name(group_id, name3, name_len + 1) < 0) TEST_ERROR; /* Verify */ - if (check_name( name3, "/g17" )!=0) - goto out; + if(HDstrcmp(name3, "/g17")) TEST_ERROR; + *name3 = '\0'; - /* Get name */ - if (H5Iget_name( group_id, name3, 3 )<0) goto out; + /* Get name with smaller buffer */ + if(H5Iget_name(group_id, name3, 3) < 0) TEST_ERROR; /* Verify */ - if (check_name( name3, "/g" )!=0) - goto out; + if(HDstrcmp(name3, "/g")) TEST_ERROR; - if ( name3 ) - free(name3); + HDfree(name3); +} /* Close */ H5Gclose( group_id ); @@ -1403,21 +1219,28 @@ PASSED(); TESTING("H5Iget_name with invalid IDs"); - /* Create a data space */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; + /* Create a dataspace */ + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; /* Define a datatype */ - if ((type_id = H5Tcopy(H5T_NATIVE_INT))<0) goto out; + if ((type_id = H5Tcopy(H5T_NATIVE_INT))<0) TEST_ERROR; /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file_id , "d2", type_id, space_id, - H5P_DEFAULT ))<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "d2", type_id, space_id, H5P_DEFAULT ))<0) TEST_ERROR; - /* Get name for non commited datatype, it should fail */ - if (H5Iget_name( type_id, name, size ) >0) goto out; +{ + char name[NAME_BUF_SIZE]; /* Buffer to hold name and its size */ - /* Get name for data space, it should fail */ - if (H5Iget_name( space_id, name, size ) >0) goto out; + /* Get name for non commited datatype, it should fail */ + H5E_BEGIN_TRY { + if(H5Iget_name( type_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR; + } H5E_END_TRY; + + /* Get name for dataspace, it should fail */ + H5E_BEGIN_TRY { + if(H5Iget_name( space_id, name, NAME_BUF_SIZE) > 0) TEST_ERROR; + } H5E_END_TRY; +} /* Close */ H5Dclose( dataset_id ); @@ -1435,85 +1258,62 @@ PASSED(); TESTING("H5Iget_name with added names with mounting"); /* Create a group "g18/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g18", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g18/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g18", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g18/g2", 0 ))<0) TEST_ERROR; /* Also create a dataset and a datatype */ - if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; - if ((type_id = H5Tcopy(H5T_NATIVE_INT))<0) goto out; + if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) TEST_ERROR; + if ((type_id = H5Tcopy(H5T_NATIVE_INT))<0) TEST_ERROR; if ((dataset_id = H5Dcreate( file_id, "g18/d2", type_id, space_id, - H5P_DEFAULT ))<0) goto out; + H5P_DEFAULT ))<0) TEST_ERROR; - if (H5Tcommit(file_id, "g18/t2", type_id) <0) goto out; + if (H5Tcommit(file_id, "g18/t2", type_id) <0) TEST_ERROR; /* Create second file and group "/g3/g4/g5" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group3_id = H5Gcreate( file1_id, "/g3", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file1_id, "/g3/g4", 0 ))<0) goto out; - if ((group5_id = H5Gcreate( file1_id, "/g3/g4/g5", 0 ))<0) goto out; + if ((group3_id = H5Gcreate( file1_id, "/g3", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file1_id, "/g3/g4", 0 ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file1_id, "/g3/g4/g5", 0 ))<0) TEST_ERROR; /* Mount first file at "g3/g4" in the second file */ - if (H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file1_id, "/g3/g4", file_id, H5P_DEFAULT)<0) TEST_ERROR; /* Get name for the group ID in the first file, should be "/g18/g2" still */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - if (check_name( name, "/g18/g2" )!=0) goto out; + if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR; /* Get name for the dataset ID in the first file, should be "/g18/g2/d2" still */ - if (H5Iget_name( dataset_id, name, size )<0) goto out; - if (check_name( name, "/g18/d2" )!=0) goto out; + if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR; /* Get name for the datatype ID in the first file, should be "/g18/g2/t2" still */ - if (H5Iget_name( type_id, name, size )<0) goto out; - if (check_name( name, "/g18/t2" )!=0) goto out; + if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR; /* Open the mounted group, dataset, and datatype through their new names */ - if ((group6_id = H5Gopen( file1_id, "/g3/g4/g18/g2" ))<0) goto out; - if ((dataset2_id = H5Dopen( file1_id, "/g3/g4/g18/d2" ))<0) goto out; - if ((type2_id = H5Topen( file1_id, "/g3/g4/g18/t2" ))<0) goto out; + if ((group6_id = H5Gopen( file1_id, "/g3/g4/g18/g2" ))<0) TEST_ERROR; + if ((dataset2_id = H5Dopen( file1_id, "/g3/g4/g18/d2" ))<0) TEST_ERROR; + if ((type2_id = H5Topen( file1_id, "/g3/g4/g18/t2" ))<0) TEST_ERROR; /* Verify names */ - if (H5Iget_name( group6_id, name, size )<0) goto out; - if (check_name( name, "/g3/g4/g18/g2" )!=0) goto out; - - if (H5Iget_name( dataset2_id, name, size )<0) goto out; - if (check_name( name, "/g3/g4/g18/d2" )!=0) goto out; - - if (H5Iget_name( type2_id, name, size )<0) goto out; - if (check_name( name, "/g3/g4/g18/t2" )!=0) goto out; + if(check_name(group6_id, "/g3/g4/g18/g2", "/g3/g4/g18/g2") < 0) TEST_ERROR; + if(check_name(dataset2_id, "/g3/g4/g18/d2", "/g3/g4/g18/d2") < 0) TEST_ERROR; + if(check_name(type2_id, "/g3/g4/g18/t2", "/g3/g4/g18/t2") < 0) TEST_ERROR; /* Verify that old IDs still refer to objects by their old names */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - if (check_name( name, "/g18/g2" )!=0) goto out; - - if (H5Iget_name( dataset_id, name, size )<0) goto out; - if (check_name( name, "/g18/d2" )!=0) goto out; - - if (H5Iget_name( type_id, name, size )<0) goto out; - if (check_name( name, "/g18/t2" )!=0) goto out; + if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR; + if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR; + if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR; /* Unmount */ - if (H5Funmount(file1_id, "/g3/g4")<0) goto out; + if (H5Funmount(file1_id, "/g3/g4")<0) TEST_ERROR; /* Get name for the IDs of the first file, should be unchanged */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - if (check_name( name, "/g18/g2" )!=0) goto out; - - if (H5Iget_name( dataset_id, name, size )<0) goto out; - if (check_name( name, "/g18/d2" )!=0) goto out; - - if (H5Iget_name( type_id, name, size )<0) goto out; - if (check_name( name, "/g18/t2" )!=0) goto out; + if(check_name(group2_id, "/g18/g2", "/g18/g2") < 0) TEST_ERROR; + if(check_name(dataset_id, "/g18/d2", "/g18/d2") < 0) TEST_ERROR; + if(check_name(type_id, "/g18/t2", "/g18/t2") < 0) TEST_ERROR; /* Get name for the IDs of the second file, should be "" */ - if (H5Iget_name( group6_id, name, size )<0) goto out; - if (check_name( name, "" )!=0) goto out; - - if (H5Iget_name( dataset2_id, name, size )<0) goto out; - if (check_name( name, "" )!=0) goto out; - - if (H5Iget_name( type2_id, name, size )<0) goto out; - if (check_name( name, "" )!=0) goto out; + if(check_name(group6_id, "", "") < 0) TEST_ERROR; + if(check_name(dataset2_id, "", "") < 0) TEST_ERROR; + if(check_name(type2_id, "", "") < 0) TEST_ERROR; H5Tclose( type_id ); H5Tclose( type2_id ); @@ -1539,25 +1339,17 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) goto out; - - /* Get name for the ID */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/g2" )!=0) - goto out; + if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; /* Close file */ H5Fclose( file1_id ); - /* Get name for the ID */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - /* Verify */ - if (check_name( name, "/g1/g2" )!=0) - goto out; + if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1575,40 +1367,31 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; /* Create a new file and group "/g3/g4" in it */ - if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) goto out; + if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) TEST_ERROR; /* Mount first file at "/g3/g4" in the second file */ - if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) goto out; + if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Open the mounted group */ - if ((group5_id = H5Gopen( file2_id, "/g3/g4/g1/g2" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if ((group5_id = H5Gopen( file2_id, "/g3/g4/g1/g2" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1/g2" )!=0) goto out; + if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR; /* Delete */ - if (H5Gunlink( file1_id, "/g3/g4/g1/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if (H5Gunlink( file1_id, "/g3/g4/g1/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if(check_name(group5_id, "", "") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1632,136 +1415,83 @@ PASSED(); /* Create a file and group "/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g1", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g1/g2", 0 ))<0) TEST_ERROR; /* Create a new file and group "/g3/g4" in it */ - if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) goto out; + if ((file2_id = H5Fcreate( filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g3", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file2_id, "/g3/g4", 0 ))<0) TEST_ERROR; /* Mount first file at "g3/g4" in the second file */ - if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; + if(H5Fmount(file2_id, "/g3/g4", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4" )!=0) goto out; + if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR; /* Open the mounted group */ - if ((group5_id = H5Gopen( file2_id, "/g3/g4/g1/g2" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if ((group5_id = H5Gopen( file2_id, "/g3/g4/g1/g2" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1/g2" )!=0) goto out; + if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR; /* Open another mounted group, in the middle of the path */ - if ((group6_id = H5Gopen( file2_id, "/g3/g4/g1" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if ((group6_id = H5Gopen( file2_id, "/g3/g4/g1" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1" )!=0) goto out; + if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR; /* Rename group */ - if (H5Gmove( file2_id, "/g3/g4/g1/g2", "/g3/g4/g1/g5" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if (H5Gmove( file2_id, "/g3/g4/g1/g2", "/g3/g4/g1/g5" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1/g5" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g1/g5" )!=0) goto out; + if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR; + if(check_name(group2_id, "/g1/g5", "/g1/g5") < 0) TEST_ERROR; /* Rename group */ - if (H5Gmove( file2_id, "/g3/g4/g1", "/g3/g4/g1a" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g3/g4/g1a/g5" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g1a/g5" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if (H5Gmove( file2_id, "/g3/g4/g1", "/g3/g4/g1a" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1a" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if(check_name(group5_id, "/g3/g4/g1a/g5", "/g3/g4/g1a/g5") < 0) TEST_ERROR; + if(check_name(group2_id, "/g1a/g5", "/g1a/g5") < 0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1a" )!=0) goto out; + if(check_name(group6_id, "/g3/g4/g1a", "/g3/g4/g1a") < 0) TEST_ERROR; + if(check_name(group_id, "/g1a", "/g1a") < 0) TEST_ERROR; /* Rename middle group back, using relative path */ - if (H5Gmove( group3_id, "g4/g1a", "g4/g1" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g3/g4/g1/g5" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g1/g5" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g3/g4/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Gmove( group3_id, "g4/g1a", "g4/g1" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1" )!=0) goto out; + if(check_name(group5_id, "/g3/g4/g1/g5", "/g3/g4/g1/g5") < 0) TEST_ERROR; + if(check_name(group2_id, "/g1/g5", "/g1/g5") < 0) TEST_ERROR; + if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR; + if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR; /* Rename end group back, using relative path */ - if (H5Gmove( group3_id, "g4/g1/g5", "g4/g1/g2" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if (H5Gmove( group3_id, "g4/g1/g5", "g4/g1/g2" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g3/g4/g1/g2" )!=0) goto out; + if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR; + if(check_name(group2_id, "/g1/g2", "/g1/g2") < 0) TEST_ERROR; + if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR; + if(check_name(group_id, "/g1", "/g1") < 0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + /* Rename mount point */ + if (H5Gmove( file2_id, "/g3/g4", "/g3/g4a" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1/g2" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if(check_name(group4_id, "/g3/g4a", "/g3/g4a") < 0) TEST_ERROR; + if(check_name(group5_id, "/g3/g4a/g1/g2", "/g3/g4a/g1/g2") < 0) TEST_ERROR; + if(check_name(group6_id, "/g3/g4a/g1", "/g3/g4a/g1") < 0) TEST_ERROR; - /* Verify */ - if (check_name( name, "/g3/g4/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + /* Rename mount point back, using relative path*/ + if (H5Gmove( group3_id, "g4a", "g4" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g1" )!=0) goto out; + if(check_name(group4_id, "/g3/g4", "/g3/g4") < 0) TEST_ERROR; + if(check_name(group5_id, "/g3/g4/g1/g2", "/g3/g4/g1/g2") < 0) TEST_ERROR; + if(check_name(group6_id, "/g3/g4/g1", "/g3/g4/g1") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1783,125 +1513,71 @@ PASSED(); TESTING("H5Iget_name with H5Glink hard"); /* Create group "g19/g1" */ - if ((group_id = H5Gcreate( file_id, "/g19", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g19/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g19", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g19/g1", 0 ))<0) TEST_ERROR; /* Create hard link to "g19/g1/ group */ - if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g1" )!=0) goto out; + if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g19/g2" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g19/g2" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g2" )!=0) goto out; + if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; /* Rename original group */ - if (H5Gmove( file_id, "/g19/g1", "/g19/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g19/g1", "/g19/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g19/g2" )!=0) goto out; + if(check_name(group2_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR; + if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; /* Rename original group back, using relative path */ - if (H5Gmove( group_id, "g3", "g1" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gmove( group_id, "g3", "g1" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g19/g2" )!=0) goto out; + if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; + if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; /* Create another hard link to "/g19/g1" group */ - if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g3")<0) goto out; + if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g3")<0) TEST_ERROR; /* Open the group */ - if ((group4_id = H5Gopen( file_id, "/g19/g3" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; + if ((group4_id = H5Gopen( file_id, "/g19/g3" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g3" )!=0) goto out; + if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR; /* Delete group */ - if (H5Gunlink( file_id, "/g19/g3")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g19/g3")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g19/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g19/g2" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; + if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; /* Close the unlinked group */ H5Gclose( group4_id ); /* Create another hard link to "/g19/g1" group */ - if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g3")<0) goto out; + if (H5Glink(file_id, H5G_LINK_HARD, "/g19/g1", "/g19/g3")<0) TEST_ERROR; /* Open the group */ - if ((group4_id = H5Gopen( file_id, "/g19/g3" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; + if ((group4_id = H5Gopen( file_id, "/g19/g3" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g3" )!=0) goto out; + if(check_name(group4_id, "/g19/g3", "/g19/g3") < 0) TEST_ERROR; /* Delete group, using relative path */ - if (H5Gunlink( group_id, "g3")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Gunlink( group_id, "g3")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g19/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g19/g2" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g19/g1", "/g19/g1") < 0) TEST_ERROR; + if(check_name(group3_id, "/g19/g2", "/g19/g2") < 0) TEST_ERROR; /* Close the unlinked group */ H5Gclose( group4_id ); @@ -1923,26 +1599,20 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic"); /* Create group "g20/g1" */ - if ((group_id = H5Gcreate( file_id, "/g20", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g20/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g20", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g20/g1", 0 ))<0) TEST_ERROR; /* Create symbolic link to "g20/g1/ group */ - if (H5Glink(file_id, H5G_LINK_SOFT, "/g20/g1", "/g20/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_SOFT, "/g20/g1", "/g20/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g20/g1" )!=0) goto out; + if(check_name(group2_id, "/g20/g1", "/g20/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g20/g2" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g20/g2" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g20/g2" )!=0) goto out; + if(check_name(group3_id, "/g20/g2", "/g20/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -1960,35 +1630,24 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and move target"); /* Create group "g21/g1" */ - if ((group_id = H5Gcreate( file_id, "/g21", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g21/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g21", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g21/g1", 0 ))<0) TEST_ERROR; /* Create symbolic link to "g21/g1/ group */ - if (H5Glink(file_id, H5G_LINK_SOFT, "/g21/g1", "/g21/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_SOFT, "/g21/g1", "/g21/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g21/g1" )!=0) goto out; + if(check_name(group2_id, "/g21/g1", "/g21/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g21/g2" ))<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g21/g2" ))<0) TEST_ERROR; /* Rename group */ - if (H5Gmove( file_id, "/g21/g1", "/g21/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g21/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g21/g1", "/g21/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g21/g2" )!=0) goto out; + if(check_name(group2_id, "/g21/g3", "/g21/g3") < 0) TEST_ERROR; + if(check_name(group3_id, "/g21/g2", "/g21/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2006,50 +1665,31 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and move source"); /* Create group "g22/g1" */ - if ((group_id = H5Gcreate( file_id, "/g22", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g22/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g22", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g22/g1", 0 ))<0) TEST_ERROR; /* Create symbolic link to "g22/g1/ group */ - if (H5Glink(file_id, H5G_LINK_SOFT, "/g22/g1", "/g22/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_SOFT, "/g22/g1", "/g22/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g22/g1" )!=0) goto out; + if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g22/g2" ))<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g22/g2" ))<0) TEST_ERROR; /* Rename soft link */ - if (H5Gmove( file_id, "/g22/g2", "/g22/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g22/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove( file_id, "/g22/g2", "/g22/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g22/g3" )!=0) goto out; + if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR; + if(check_name(group3_id, "/g22/g3", "/g22/g3") < 0) TEST_ERROR; /* Rename soft link, using relative paths */ - if (H5Gmove( group_id, "g3", "g2" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g22/g1" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gmove( group_id, "g3", "g2" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g22/g2" )!=0) goto out; + if(check_name(group2_id, "/g22/g1", "/g22/g1") < 0) TEST_ERROR; + if(check_name(group3_id, "/g22/g2", "/g22/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2068,29 +1708,23 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and unlink target"); /* Create group "g23/g1" */ - if ((group_id = H5Gcreate( file_id, "/g23", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g23/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g23", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g23/g1", 0 ))<0) TEST_ERROR; /* Create symbolic link to "g23/g1/ group */ - if (H5Glink(file_id, H5G_LINK_SOFT, "/g23/g1", "/g23/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_SOFT, "/g23/g1", "/g23/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g23/g1" )!=0) goto out; + if(check_name(group2_id, "/g23/g1", "/g23/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g23/g2" ))<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g23/g2" ))<0) TEST_ERROR; /* Delete group */ - if (H5Gunlink( file_id, "/g23/g1")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g23/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g23/g2" )!=0) goto out; + if(check_name(group3_id, "/g23/g2", "/g23/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2107,29 +1741,23 @@ PASSED(); TESTING("H5Iget_name with H5Glink symbolic and unlink source"); /* Create group "g24/g1" */ - if ((group_id = H5Gcreate( file_id, "/g24", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g24/g1", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g24", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g24/g1", 0 ))<0) TEST_ERROR; /* Create symbolic link to "g24/g1/ group */ - if (H5Glink(file_id, H5G_LINK_SOFT, "/g24/g1", "/g24/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_SOFT, "/g24/g1", "/g24/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g24/g1" )!=0) goto out; + if(check_name(group2_id, "/g24/g1", "/g24/g1") < 0) TEST_ERROR; /* Open the group */ - if ((group3_id = H5Gopen( file_id, "/g24/g2" ))<0) goto out; + if ((group3_id = H5Gopen( file_id, "/g24/g2" ))<0) TEST_ERROR; /* Delete group */ - if (H5Gunlink( file_id, "/g24/g2")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Gunlink( file_id, "/g24/g2")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2146,9 +1774,9 @@ PASSED(); TESTING("H5Iget_name with several nested mounted files"); /* Create a group "g25/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g25", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g25/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g25/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g25", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g25/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g25/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2158,9 +1786,9 @@ PASSED(); /* Create second file and group "/g26/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g26", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g26/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g26/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g26", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g26/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g26/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2170,9 +1798,9 @@ PASSED(); /* Create third file and group "/g27/g5/g6" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g27", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file2_id, "/g27/g5", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g27/g5/g6", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file2_id, "/g27", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g27/g5", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g27/g5/g6", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2182,9 +1810,9 @@ PASSED(); /* Create fourth file and group "/g28/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g28", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file3_id, "/g28/g7", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file3_id, "/g28/g7/g8", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file3_id, "/g28", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g28/g7", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g28/g7/g8", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2192,135 +1820,75 @@ PASSED(); H5Gclose( group3_id ); /* Access group which will be hidden in the first file */ - if ((group_id = H5Gopen( file_id, "/g25/g1/g2"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g25/g1/g2"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g25/g1/g2" )!=0) goto out; + if(check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) TEST_ERROR; /* Mount second file under "/g25/g1" in the first file */ - if (H5Fmount(file_id, "/g25/g1", file1_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g25/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR; /* Access group which will be hidden in the second file */ - if ((group2_id = H5Gopen( file_id, "/g25/g1/g26/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if ((group2_id = H5Gopen( file_id, "/g25/g1/g26/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g25/g1/g26/g3/g4" )!=0) goto out; + if(check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; /* Mount third file under "/g25/g1/g26/g3" in the first file */ - if (H5Fmount(file_id, "/g25/g1/g26/g3", file2_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g25/g1/g26/g3", file2_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; /* Access group in the third file */ - if ((group3_id = H5Gopen( file_id, "/g25/g1/g26/g3/g27/g5/g6"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if ((group3_id = H5Gopen( file_id, "/g25/g1/g26/g3/g27/g5/g6"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g25/g1/g26/g3/g27/g5/g6" )!=0) goto out; + if(check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR; /* Mount fourth file under "/g25/g1/g26/g3/g27/g5" in the first file */ - if (H5Fmount(file_id, "/g25/g1/g26/g3/g27/g5", file3_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g25/g1/g26/g3/g27/g5", file3_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR; /* Access group in the fourth file */ - if ((group4_id = H5Gopen( file_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g25/g1/g26/g3/g27/g5/g28/g7/g8" )!=0) goto out; - - if (H5Funmount(file_id, "/g25/g1/g26/g3/g27/g5")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if ((group4_id = H5Gopen( file_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g25/g1/g26/g3/g27/g5/g6" )!=0) goto out; + if(check_name(group4_id, "/g25/g1/g26/g3/g27/g5/g28/g7/g8", "/g25/g1/g26/g3/g27/g5/g28/g7/g8") < 0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g25/g1/g26/g3/g27/g5")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g25/g1/g26/g3/g27/g5/g6", "/g25/g1/g26/g3/g27/g5/g6") < 0) TEST_ERROR; + if(check_name(group2_id, "", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; + if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group4_id ); H5Fclose( file3_id ); - if (H5Funmount(file_id, "/g25/g1/g26/g3")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g25/g1/g26/g3/g4" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g25/g1/g26/g3")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g25/g1/g26/g3/g4", "/g25/g1/g26/g3/g4") < 0) TEST_ERROR; + if(check_name(group_id, "", "/g25/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group3_id ); H5Fclose( file2_id ); - if (H5Funmount(file_id, "/g25/g1")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g25/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g25/g1/g2" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g25/g1/g2", "/g25/g1/g2") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2339,50 +1907,31 @@ PASSED(); TESTING("H5Iget_name and H5Gmove with repeated path components"); /* Create a group "g29/g1/g2/g1/g2" in a file */ - if ((group_id = H5Gcreate( file_id, "/g29", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g29/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g29/g1/g2", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file_id, "/g29/g1/g2/g1", 0 ))<0) goto out; - if ((group5_id = H5Gcreate( file_id, "/g29/g1/g2/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g29", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g29/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g29/g1/g2", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file_id, "/g29/g1/g2/g1", 0 ))<0) TEST_ERROR; + if ((group5_id = H5Gcreate( file_id, "/g29/g1/g2/g1/g2", 0 ))<0) TEST_ERROR; /* Rename group */ - if (H5Gmove( file_id, "/g29/g1/g2/g1/g2", "/g29/g1/g2/g1/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )< 0) goto out; + if (H5Gmove( file_id, "/g29/g1/g2/g1/g2", "/g29/g1/g2/g1/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g29/g1/g2/g1/g3" )!=0) goto out; + if(check_name(group5_id, "/g29/g1/g2/g1/g3", "/g29/g1/g2/g1/g3") < 0) TEST_ERROR; /* Rename group in middle of path, keeping within the same group */ - if (H5Gmove( file_id, "/g29/g1/g2/g1", "/g29/g1/g2/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g29/g1/g2/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )< 0) goto out; + if (H5Gmove( file_id, "/g29/g1/g2/g1", "/g29/g1/g2/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g29/g1/g2/g3/g3" )!=0) goto out; + if(check_name(group4_id, "/g29/g1/g2/g3", "/g29/g1/g2/g3") < 0) TEST_ERROR; + if(check_name(group5_id, "/g29/g1/g2/g3/g3", "/g29/g1/g2/g3/g3") < 0) TEST_ERROR; /* Rename group in middle of path, moving to another group in file */ - if (H5Gmove( file_id, "/g29/g1/g2/g3", "/g29/g3" )<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; + if (H5Gmove( file_id, "/g29/g1/g2/g3", "/g29/g3" )<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g29/g3" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g29/g3/g3" )!=0) goto out; + if(check_name(group4_id, "/g29/g3", "/g29/g3") < 0) TEST_ERROR; + if(check_name(group5_id, "/g29/g3/g3", "/g29/g3/g3") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2402,9 +1951,9 @@ PASSED(); TESTING("H5Iget_name with higher mounted file"); /* Create a group "/g30/g1/g2" in the first file */ - if ((group_id = H5Gcreate( file_id, "/g30", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g30/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g30/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g30", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g30/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g30/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2414,9 +1963,9 @@ PASSED(); /* Create second file and group "/g31/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g31", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g31/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g31/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g31", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g31/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g31/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2426,9 +1975,9 @@ PASSED(); /* Create third file and group "/g32/g5/g6" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g32", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file2_id, "/g32/g5", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g32/g5/g6", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file2_id, "/g32", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g32/g5", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g32/g5/g6", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2438,9 +1987,9 @@ PASSED(); /* Create fourth file and group "/g33/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g33", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file3_id, "/g33/g7", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file3_id, "/g33/g7/g8", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file3_id, "/g33", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g33/g7", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g33/g7/g8", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2448,148 +1997,73 @@ PASSED(); H5Gclose( group3_id ); /* Access group which will be hidden in the first file */ - if ((group_id = H5Gopen( file_id, "/g30/g1/g2"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if ((group_id = H5Gopen( file_id, "/g30/g1/g2"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g30/g1/g2" )!=0) goto out; + if(check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) TEST_ERROR; /* Mount second file under "/g30/g1" in the first file */ - if (H5Fmount(file_id, "/g30/g1", file1_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g30/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR; /* Access group which will be hidden in the second file */ - if ((group2_id = H5Gopen( file_id, "/g30/g1/g31/g3/g4"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if ((group2_id = H5Gopen( file_id, "/g30/g1/g31/g3/g4"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g30/g1/g31/g3/g4" )!=0) goto out; + if(check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; /* Mount third file under "/g30/g1/g31/g3" in the first file */ - if (H5Fmount(file_id, "/g30/g1/g31/g3", file2_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g30/g1/g31/g3", file2_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; /* Access group which will be hidden in the third file */ - if ((group3_id = H5Gopen( file_id, "/g30/g1/g31/g3/g32/g5/g6"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if ((group3_id = H5Gopen( file_id, "/g30/g1/g31/g3/g32/g5/g6"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g30/g1/g31/g3/g32/g5/g6" )!=0) goto out; + if(check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR; /* Mount fourth file under "/g30" in the first file, hiding the files below it */ - if (H5Fmount(file_id, "/g30", file3_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if (H5Fmount(file_id, "/g30", file3_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group3_id, "", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR; /* Access group which will be in the fourth file */ - if ((group4_id = H5Gopen( file_id, "/g30/g33/g7/g8"))<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; + if ((group4_id = H5Gopen( file_id, "/g30/g33/g7/g8"))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g30/g33/g7/g8" )!=0) goto out; + if(check_name(group4_id, "/g30/g33/g7/g8", "/g30/g33/g7/g8") < 0) TEST_ERROR; /* Unmount fourth file */ - if (H5Funmount(file_id, "/g30")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g30/g1/g31/g3/g32/g5/g6" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g30")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "/g30/g1/g31/g3/g32/g5/g6", "/g30/g1/g31/g3/g32/g5/g6") < 0) TEST_ERROR; + if(check_name(group2_id, "", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; + if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR; /* Unmount third file */ - if (H5Funmount(file_id, "/g30/g1/g31/g3")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g30/g1/g31/g3")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g30/g1/g31/g3/g4" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "/g30/g1/g31/g3/g4", "/g30/g1/g31/g3/g4") < 0) TEST_ERROR; + if(check_name(group_id, "", "/g30/g1/g2") < 0) TEST_ERROR; /* Unmount second file */ - if (H5Funmount(file_id, "/g30/g1")<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )< 0) goto out; + if (H5Funmount(file_id, "/g30/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )< 0) goto out; - - /* Verify */ - if (check_name( name, "/g30/g1/g2" )!=0) goto out; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g30/g1/g2", "/g30/g1/g2") < 0) TEST_ERROR; /* Close groups */ H5Gclose( group_id ); @@ -2615,9 +2089,9 @@ PASSED(); /* Create second file and group "/g35/g3/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g35", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g35/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g35/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g35", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g35/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g35/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2625,57 +2099,35 @@ PASSED(); H5Gclose( group3_id ); /* Create group "/g34/g1/g2" in first file */ - if ((group_id = H5Gcreate( file_id, "/g34", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g34/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g34/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g34", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g34/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g34/g1/g2", 0 ))<0) TEST_ERROR; /* Create hard link to "/g34/g1/g2 group */ - if (H5Glink(file_id, H5G_LINK_HARD, "/g34/g1/g2", "/g34/g2a")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Glink(file_id, H5G_LINK_HARD, "/g34/g1/g2", "/g34/g2a")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g34/g1/g2" )!=0) goto out; + if(check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) TEST_ERROR; /* Open the link to the group */ - if ((group4_id = H5Gopen( file_id, "/g34/g2a" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; + if ((group4_id = H5Gopen( file_id, "/g34/g2a" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g34/g2a" )!=0) goto out; + if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR; /* Mount second file under "/g34/g1" in the first file */ - if (H5Fmount(file_id, "/g34/g1", file1_id, H5P_DEFAULT)<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Fmount(file_id, "/g34/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g34/g2a" )!=0) goto out; + if(check_name(group3_id, "", "/g34/g1/g2") < 0) TEST_ERROR; + if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR; /* Unmount second file */ - if (H5Funmount(file_id, "/g34/g1")<0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; + if (H5Funmount(file_id, "/g34/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g34/g1/g2" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g34/g2a" )!=0) goto out; + if(check_name(group3_id, "/g34/g1/g2", "/g34/g1/g2") < 0) TEST_ERROR; + if(check_name(group4_id, "/g34/g2a", "/g34/g2a") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2696,9 +2148,9 @@ PASSED(); TESTING("H5Iget_name with mounted files and unlinking"); /* Create group "/g36/g1/g2" in first file */ - if ((group_id = H5Gcreate( file_id, "/g36", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file_id, "/g36/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file_id, "/g36/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file_id, "/g36", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file_id, "/g36/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file_id, "/g36/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2708,92 +2160,52 @@ PASSED(); /* Create second file and group "/g37/g4" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g37", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g37/g4", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g37/g4/g5a", 0 ))<0) goto out; - if ((group4_id = H5Gcreate( file1_id, "/g37/g4/g5b", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g37", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g37/g4", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g37/g4/g5a", 0 ))<0) TEST_ERROR; + if ((group4_id = H5Gcreate( file1_id, "/g37/g4/g5b", 0 ))<0) TEST_ERROR; /* Mount second file under "/g36/g1" in the first file */ - if (H5Fmount(file_id, "/g36/g1", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file_id, "/g36/g1", file1_id, H5P_DEFAULT)<0) TEST_ERROR; /* Open group in mounted file */ - if ((group5_id = H5Gopen( file_id, "/g36/g1/g37/" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group5_id, name, size )<0) goto out; + if ((group5_id = H5Gopen( file_id, "/g36/g1/g37/" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g36/g1/g37" )!=0) goto out; + if(check_name(group5_id, "/g36/g1/g37", "/g36/g1/g37") < 0) TEST_ERROR; /* Open group to delete in mounted file */ - if ((group6_id = H5Gopen( file_id, "/g36/g1/g37/g4/g5a" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if ((group6_id = H5Gopen( file_id, "/g36/g1/g37/g4/g5a" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g36/g1/g37/g4/g5a" )!=0) goto out; + if(check_name(group6_id, "/g36/g1/g37/g4/g5a", "/g36/g1/g37/g4/g5a") < 0) TEST_ERROR; /* Delete end group in mounted file, using relative paths */ - if (H5Gunlink( group5_id, "g4/g5a")<0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if (H5Gunlink( group5_id, "g4/g5a")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group3_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group6_id, "", "") < 0) TEST_ERROR; + if(check_name(group3_id, "", "") < 0) TEST_ERROR; /* Close deleted group */ H5Gclose( group6_id ); /* Open groups to delete in mounted file */ - if ((group6_id = H5Gopen( file_id, "/g36/g1/g37/g4" ))<0) goto out; - if ((group7_id = H5Gopen( file_id, "/g36/g1/g37/g4/g5b" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if ((group6_id = H5Gopen( file_id, "/g36/g1/g37/g4" ))<0) TEST_ERROR; + if ((group7_id = H5Gopen( file_id, "/g36/g1/g37/g4/g5b" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g36/g1/g37/g4" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group7_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g36/g1/g37/g4/g5b" )!=0) goto out; + if(check_name(group6_id, "/g36/g1/g37/g4", "/g36/g1/g37/g4") < 0) TEST_ERROR; + if(check_name(group7_id, "/g36/g1/g37/g4/g5b", "/g36/g1/g37/g4/g5b") < 0) TEST_ERROR; /* Delete middle group in mounted file, using relative paths */ - if (H5Gunlink( group5_id, "g4")<0) goto out; - - /* Get name */ - if (H5Iget_name( group6_id, name, size )<0) goto out; + if (H5Gunlink( group5_id, "g4")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group7_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group4_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group6_id, "", "") < 0) TEST_ERROR; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group7_id, "", "") < 0) TEST_ERROR; + if(check_name(group4_id, "", "") < 0) TEST_ERROR; /* Close deleted groups */ H5Gclose( group6_id ); @@ -2802,7 +2214,7 @@ PASSED(); /* Close group in mounted file */ H5Gclose( group5_id ); - if (H5Funmount(file_id, "/g36/g1")<0) goto out; + if (H5Funmount(file_id, "/g36/g1")<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2825,9 +2237,9 @@ PASSED(); /* Create file and group "/g38/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g38", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g38/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g38/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g38", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g38/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g38/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2837,9 +2249,9 @@ PASSED(); /* Create second file and group "/g39/g1/g2" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g39", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file2_id, "/g39/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g39/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file2_id, "/g39", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g39/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g39/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2849,9 +2261,9 @@ PASSED(); /* Create third file and group "/g40/g5/g6" in it */ file3_id = H5Fcreate(filename3, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file3_id, "/g40", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file3_id, "/g40/g5", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file3_id, "/g40/g5/g6", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file3_id, "/g40", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file3_id, "/g40/g5", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file3_id, "/g40/g5/g6", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2859,56 +2271,34 @@ PASSED(); H5Gclose( group3_id ); /* Mount second file under "/g38/g1" in the first file */ - if (H5Fmount(file1_id, "/g38/g1", file2_id, H5P_DEFAULT)<0) goto out; - - if ((group_id = H5Gopen( file1_id, "/g38/g1/g39/g3/g4" ))<0) goto out; + if (H5Fmount(file1_id, "/g38/g1", file2_id, H5P_DEFAULT)<0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if ((group_id = H5Gopen( file1_id, "/g38/g1/g39/g3/g4" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g38/g1/g39/g3/g4" )!=0) goto out; + if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR; /* Mount first file under "/g40/g5" in the third file */ - if (H5Fmount(file3_id, "/g40/g5", file1_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file3_id, "/g40/g5", file1_id, H5P_DEFAULT)<0) TEST_ERROR; - if ((group2_id = H5Gopen( file3_id, "/g40/g5/g38/g1/g39/g3/g4" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if ((group2_id = H5Gopen( file3_id, "/g40/g5/g38/g1/g39/g3/g4" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g40/g5/g38/g1/g39/g3/g4" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "/g38/g1/g39/g3/g4" )!=0) goto out; + if(check_name(group2_id, "/g40/g5/g38/g1/g39/g3/g4", "/g40/g5/g38/g1/g39/g3/g4") < 0) TEST_ERROR; + if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR; /* Unmount first file */ - if (H5Funmount(file3_id, "/g40/g5")<0) goto out; - - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; - - /* Verify */ - if (check_name( name, "" )!=0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Funmount(file3_id, "/g40/g5")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g38/g1/g39/g3/g4" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; + if(check_name(group_id, "/g38/g1/g39/g3/g4", "/g38/g1/g39/g3/g4") < 0) TEST_ERROR; /* Unmount second file */ - if (H5Funmount(file1_id, "/g38/g1")<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if (H5Funmount(file1_id, "/g38/g1")<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2929,9 +2319,9 @@ PASSED(); /* Create file and group "/g39/g1/g2" in it */ file1_id = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file1_id, "/g41", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file1_id, "/g41/g1", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file1_id, "/g41/g1/g2", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file1_id, "/g41", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file1_id, "/g41/g1", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file1_id, "/g41/g1/g2", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2941,9 +2331,9 @@ PASSED(); /* Create second file and group "/g42/g1/g2" in it */ file2_id = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - if ((group_id = H5Gcreate( file2_id, "/g42", 0 ))<0) goto out; - if ((group2_id = H5Gcreate( file2_id, "/g42/g3", 0 ))<0) goto out; - if ((group3_id = H5Gcreate( file2_id, "/g42/g3/g4", 0 ))<0) goto out; + if ((group_id = H5Gcreate( file2_id, "/g42", 0 ))<0) TEST_ERROR; + if ((group2_id = H5Gcreate( file2_id, "/g42/g3", 0 ))<0) TEST_ERROR; + if ((group3_id = H5Gcreate( file2_id, "/g42/g3/g4", 0 ))<0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2951,26 +2341,20 @@ PASSED(); H5Gclose( group3_id ); /* Mount second file under "/g41/g1" in the first file */ - if (H5Fmount(file1_id, "/g41/g1", file2_id, H5P_DEFAULT)<0) goto out; + if (H5Fmount(file1_id, "/g41/g1", file2_id, H5P_DEFAULT)<0) TEST_ERROR; - if ((group_id = H5Gopen( file1_id, "/g41/g1/g42/g3" ))<0) goto out; - - /* Get name */ - if (H5Iget_name( group_id, name, size )<0) goto out; + if ((group_id = H5Gopen( file1_id, "/g41/g1/g42/g3" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "/g41/g1/g42/g3" )!=0) goto out; + if(check_name(group_id, "/g41/g1/g42/g3", "/g41/g1/g42/g3") < 0) TEST_ERROR; /* Unmount file */ - if (H5Funmount(file1_id, "/g41/g1")<0) goto out; - - if ((group2_id = H5Gopen( group_id, "g4" ))<0) goto out; + if (H5Funmount(file1_id, "/g41/g1")<0) TEST_ERROR; - /* Get name */ - if (H5Iget_name( group2_id, name, size )<0) goto out; + if ((group2_id = H5Gopen( group_id, "g4" ))<0) TEST_ERROR; /* Verify */ - if (check_name( name, "" )!=0) goto out; + if(check_name(group2_id, "", "") < 0) TEST_ERROR; /* Close */ H5Gclose( group_id ); @@ -2992,7 +2376,7 @@ PASSED(); h5_cleanup(FILENAME, fapl); return 0; -out: +error: H5Fclose( file_id ); H5_FAILED(); return 1; diff --git a/test/tfile.c b/test/tfile.c index 0de304c..53c72c9 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -936,7 +936,7 @@ test_get_file_id(void) * this attribute. And close it. */ datatype_id=H5Tcopy(H5T_NATIVE_INT); - CHECK(ret, FAIL, "H5Acreate"); + CHECK(ret, FAIL, "H5Tcopy"); ret = H5Tcommit(fid, TYPE_NAME, datatype_id); CHECK(ret, FAIL, "H5Tcommit"); |