summaryrefslogtreecommitdiffstats
path: root/src/H5Aint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Aint.c')
-rw-r--r--src/H5Aint.c633
1 files changed, 309 insertions, 324 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 8268a01..2b43a64 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -13,11 +13,11 @@
/*-------------------------------------------------------------------------
*
- * Created: H5Aint.c
- * Dec 18 2006
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5Aint.c
+ * Dec 18 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
*
- * Purpose: Internal routines for managing attributes.
+ * Purpose: Internal routines for managing attributes.
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,7 @@
/****************/
#include "H5Amodule.h" /* This source code file is part of the H5A module */
-#define H5O_FRIEND /*suppress error about including H5Opkg */
+#define H5O_FRIEND /*suppress error about including H5Opkg */
/***********/
@@ -42,6 +42,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared Object Header Messages */
+#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -107,6 +108,8 @@ static herr_t H5A__iterate_common(hid_t loc_id, H5_index_t idx_type,
const unsigned H5O_attr_ver_bounds[] = {
H5O_ATTR_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_ATTR_VERSION_3, /* H5F_LIBVER_V18 */
+ H5O_ATTR_VERSION_3, /* H5F_LIBVER_V110 */
+ H5O_ATTR_VERSION_3, /* H5F_LIBVER_V112 */
H5O_ATTR_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -119,19 +122,19 @@ const unsigned H5O_attr_ver_bounds[] = {
/* Local Variables */
/*******************/
-typedef H5A_t* H5A_t_ptr;
+typedef H5A_t* H5A_t_ptr;
H5FL_SEQ_DEFINE(H5A_t_ptr);
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__create
+ * Function: H5A__create
*
* Purpose: This is the guts of creating an attribute.
*
* Return: Attribute structure on success, NULL on Failure.
*
- * Programmer: Quincey Koziol
- * April 2, 1998
+ * Programmer: Quincey Koziol
+ * April 2, 1998
*
*-------------------------------------------------------------------------
*/
@@ -139,11 +142,11 @@ H5A_t *
H5A__create(const H5G_loc_t *loc, const char *attr_name, const H5T_t *type,
const H5S_t *space, hid_t acpl_id)
{
- H5A_t *attr = NULL; /* Attribute created */
- hssize_t snelmts; /* elements in attribute */
- size_t nelmts; /* elements in attribute */
+ H5A_t *attr = NULL; /* Attribute created */
+ hssize_t snelmts; /* elements in attribute */
+ size_t nelmts; /* elements in attribute */
htri_t exists; /* Whether attribute exists */
- H5A_t *ret_value = NULL; /* Return value */
+ H5A_t *ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE_TAG(loc->oloc->addr)
@@ -284,16 +287,16 @@ done:
FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* H5A__create() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__create_by_name
+ * Function: H5A__create_by_name
*
- * Purpose: Create an attribute on object, according to it's name
+ * Purpose: Create an attribute on object, according to it's name
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * December 6, 2017
+ * Programmer: Quincey Koziol
+ * December 6, 2017
*
*-------------------------------------------------------------------------
*/
@@ -302,8 +305,8 @@ H5A__create_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr
const H5T_t *type, const H5S_t *space, hid_t acpl_id)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
H5A_t *attr = NULL; /* Attribute from object header */
H5A_t *ret_value = NULL; /* Return value */
@@ -345,9 +348,9 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__create_by_name() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__open_common
+ * Function: H5A__open_common
*
* Purpose:
* Finishes initializing an attributes the open
@@ -359,8 +362,8 @@ done:
*
* Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * December 18, 2006
+ * Programmer: Quincey Koziol
+ * December 18, 2006
*
*-------------------------------------------------------------------------
*/
@@ -402,16 +405,16 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__open_common() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__open
+ * Function: H5A__open
*
- * Purpose: Open an attribute in an object header
+ * Purpose: Open an attribute in an object header
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * December 9, 2017
+ * Programmer: Quincey Koziol
+ * December 9, 2017
*
*-------------------------------------------------------------------------
*/
@@ -447,16 +450,16 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__open() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__open_by_idx
+ * Function: H5A__open_by_idx
*
- * Purpose: Open an attribute according to its index order
+ * Purpose: Open an attribute according to its index order
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * April 2, 1998
+ * Programmer: Quincey Koziol
+ * April 2, 1998
*
*-------------------------------------------------------------------------
*/
@@ -465,8 +468,8 @@ H5A__open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type
H5_iter_order_t order, hsize_t n)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
H5A_t *attr = NULL; /* Attribute from object header */
H5A_t *ret_value = NULL; /* Return value */
@@ -511,7 +514,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__open_by_idx() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__open_by_name
*
@@ -519,8 +522,8 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * December 11, 2006
+ * Programmer: Quincey Koziol
+ * December 11, 2006
*
*-------------------------------------------------------------------------
*/
@@ -528,8 +531,8 @@ H5A_t *
H5A__open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
H5A_t *attr = NULL; /* Attribute from object header */
H5A_t *ret_value = NULL; /* Return value */
@@ -575,7 +578,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__open_by_name() */
-
+
/*--------------------------------------------------------------------------
NAME
H5A__read
@@ -595,16 +598,16 @@ done:
herr_t
H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf)
{
- uint8_t *tconv_buf = NULL; /* datatype conv buffer*/
- uint8_t *bkg_buf = NULL; /* background buffer */
- hssize_t snelmts; /* elements in attribute */
- size_t nelmts; /* elements in attribute*/
- H5T_path_t *tpath = NULL; /* type conversion info */
- hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/
- size_t src_type_size; /* size of source type */
- size_t dst_type_size; /* size of destination type */
- size_t buf_size; /* desired buffer size */
- herr_t ret_value = SUCCEED;
+ uint8_t *tconv_buf = NULL; /* datatype conv buffer*/
+ uint8_t *bkg_buf = NULL; /* background buffer */
+ hssize_t snelmts; /* elements in attribute */
+ size_t nelmts; /* elements in attribute*/
+ H5T_path_t *tpath = NULL; /* type conversion info */
+ hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/
+ size_t src_type_size; /* size of source type */
+ size_t dst_type_size; /* size of destination type */
+ size_t buf_size; /* desired buffer size */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr)
@@ -645,21 +648,21 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Copy the attribute data into the buffer for conversion */
- HDmemcpy(tconv_buf, attr->shared->data, (src_type_size * nelmts));
+ H5MM_memcpy(tconv_buf, attr->shared->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) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed")
/* Copy the converted data into the user's buffer */
- HDmemcpy(buf, tconv_buf, (dst_type_size * nelmts));
+ H5MM_memcpy(buf, tconv_buf, (dst_type_size * nelmts));
} /* end if */
/* No type conversion necessary */
else {
HDassert(dst_type_size == src_type_size);
/* Copy the attribute data into the user's buffer */
- HDmemcpy(buf, attr->shared->data, (dst_type_size * nelmts));
+ H5MM_memcpy(buf, attr->shared->data, (dst_type_size * nelmts));
} /* end else */
} /* end else */
} /* end if */
@@ -673,12 +676,12 @@ done:
if(tconv_buf)
tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf);
if(bkg_buf)
- bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf);
+ bkg_buf = H5FL_BLK_FREE(attr_buf, bkg_buf);
FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* H5A__read() */
-
+
/*--------------------------------------------------------------------------
NAME
H5A__write
@@ -698,17 +701,17 @@ done:
herr_t
H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf)
{
- uint8_t *tconv_buf = NULL; /* datatype conv buffer */
+ uint8_t *tconv_buf = NULL; /* datatype conv buffer */
hbool_t tconv_owned = FALSE; /* Whether the datatype conv buffer is owned by attribute */
- uint8_t *bkg_buf = NULL; /* temp conversion buffer */
- hssize_t snelmts; /* elements in attribute */
- size_t nelmts; /* elements in attribute */
- H5T_path_t *tpath = NULL; /* conversion information*/
- hid_t src_id = -1, dst_id = -1;/* temporary type atoms */
- size_t src_type_size; /* size of source type */
- size_t dst_type_size; /* size of destination type*/
- size_t buf_size; /* desired buffer size */
- herr_t ret_value = SUCCEED;
+ uint8_t *bkg_buf = NULL; /* temp conversion buffer */
+ hssize_t snelmts; /* elements in attribute */
+ size_t nelmts; /* elements in attribute */
+ H5T_path_t *tpath = NULL; /* conversion information*/
+ hid_t src_id = -1, dst_id = -1;/* temporary type atoms */
+ size_t src_type_size; /* size of source type */
+ size_t dst_type_size; /* size of destination type*/
+ size_t buf_size; /* desired buffer size */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE_TAG(attr->oloc.addr)
@@ -746,7 +749,7 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf)
HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed")
/* Copy the user's data into the buffer for conversion */
- HDmemcpy(tconv_buf, buf, (src_type_size * nelmts));
+ H5MM_memcpy(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) < 0)
@@ -769,8 +772,8 @@ H5A__write(H5A_t *attr, const H5T_t *mem_type, const void *buf)
if(NULL == (attr->shared->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->shared->data, buf, (dst_type_size * nelmts));
+ /* Copy the attribute data into the attribute data buffer */
+ H5MM_memcpy(attr->shared->data, buf, (dst_type_size * nelmts));
} /* end else */
/* Modify the attribute in the object header */
@@ -792,7 +795,7 @@ done:
FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* H5A__write() */
-
+
/*--------------------------------------------------------------------------
NAME
H5A__get_name
@@ -813,7 +816,7 @@ ssize_t
H5A__get_name(H5A_t *attr, size_t buf_size, char *buf)
{
size_t copy_len, nbytes;
- ssize_t ret_value = -1; /* Return value */
+ ssize_t ret_value = -1; /* Return value */
FUNC_ENTER_PACKAGE_NOERR
@@ -826,7 +829,7 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf)
/* Copy all/some of the name */
if(buf && copy_len > 0) {
- HDmemcpy(buf, attr->shared->name, copy_len);
+ H5MM_memcpy(buf, attr->shared->name, copy_len);
/* Terminate the string */
buf[copy_len]='\0';
@@ -838,7 +841,7 @@ H5A__get_name(H5A_t *attr, size_t buf_size, char *buf)
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__get_name() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A_get_space
*
@@ -875,7 +878,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_get_space() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__get_type
*
@@ -883,7 +886,7 @@ done:
*
* Return: Success: A valid ID for the datatype of an attribute
*
- * Failure: H5I_INVALID_HID
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
@@ -917,8 +920,18 @@ H5A__get_type(H5A_t *attr)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to lock transient datatype")
/* Atomize */
- if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype")
+ if (H5T_is_named(dt)) {
+ /* If this is a committed datatype, we need to recreate the
+ * two level IDs, where the VOL object is a copy of the
+ * returned datatype
+ */
+ if ((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle")
+ }
+ else {
+ if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype")
+ }
done:
if(H5I_INVALID_HID == ret_value)
@@ -928,7 +941,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__get_type() */
-
+
/*--------------------------------------------------------------------------
NAME
H5A__get_create_plist
@@ -960,7 +973,7 @@ H5A__get_create_plist(H5A_t* attr)
/* Create the property list object to return */
if((new_plist_id = H5P_copy_plist(plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy attribute creation properties")
if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_plist_id)))
HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list")
@@ -974,16 +987,16 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__get_create_plist() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__get_info
+ * Function: H5A__get_info
*
- * Purpose: Retrieve information about an attribute.
+ * Purpose: Retrieve information about an attribute.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* February 6, 2007
*
*-------------------------------------------------------------------------
@@ -1015,7 +1028,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__get_info() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__copy
*
@@ -1025,17 +1038,17 @@ done:
*
* Failure: NULL
*
- * Programmer: Robb Matzke
- * Thursday, December 4, 1997
+ * Programmer: Robb Matzke
+ * Thursday, December 4, 1997
*
*-------------------------------------------------------------------------
*/
H5A_t *
H5A__copy(H5A_t *_new_attr, const H5A_t *old_attr)
{
- H5A_t *new_attr = NULL;
+ H5A_t *new_attr = NULL;
hbool_t allocated_attr = FALSE; /* Whether the attribute was allocated */
- H5A_t *ret_value = NULL; /* Return value */
+ H5A_t *ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -1078,52 +1091,59 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__copy() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__free
+ * Function: H5A__shared_free
+ *
+ * Purpose: Cleans up the shared attribute data. This will free
+ * the attribute's shared structure as well.
*
- * Purpose: Frees all memory associated with an attribute, but does not
- * free the H5A_t structure (which should be done in H5T_close).
+ * attr and attr->shared must not be NULL
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Monday, November 15, 2004
+ * Programmer: Quincey Koziol
+ * Monday, November 15, 2004
*
*-------------------------------------------------------------------------
*/
herr_t
-H5A__free(H5A_t *attr)
+H5A__shared_free(H5A_t *attr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(attr);
+ HDassert(attr->shared);
- /* Free dynamically allocated items */
+ /* Free dynamically allocated items.
+ * When possible, keep trying to shut things down (via HDONE_ERROR).
+ */
if(attr->shared->name) {
H5MM_xfree(attr->shared->name);
attr->shared->name = NULL;
}
if(attr->shared->dt) {
if(H5T_close_real(attr->shared->dt) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info")
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release datatype info")
attr->shared->dt = NULL;
}
if(attr->shared->ds) {
if(H5S_close(attr->shared->ds) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info")
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release dataspace info")
attr->shared->ds = NULL;
}
if(attr->shared->data)
attr->shared->data = H5FL_BLK_FREE(attr_buf, attr->shared->data);
-done:
+ /* Destroy shared attribute struct */
+ attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
+
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5A__free() */
+} /* end H5A__shared_free() */
+
-
/*-------------------------------------------------------------------------
* Function: H5A__close_cb
*
@@ -1134,25 +1154,28 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5A__close_cb(H5A_t *attr)
+H5A__close_cb(H5VL_object_t *attr_vol_obj)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity check */
- HDassert(attr);
- HDassert(attr->shared);
+ HDassert(attr_vol_obj);
/* Close the attribute */
- if(H5A__close(attr) < 0)
+ if((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute")
+ /* Free the VOL object */
+ if(H5VL_free_object(attr_vol_obj) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__close_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__close
*
@@ -1160,8 +1183,8 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Robb Matzke
- * Monday, December 8, 1997
+ * Programmer: Robb Matzke
+ * Monday, December 8, 1997
*
*-------------------------------------------------------------------------
*/
@@ -1182,11 +1205,9 @@ H5A__close(H5A_t *attr)
/* Reference count can be 0. It only happens when H5A__create fails. */
if(attr->shared->nrefs <= 1) {
/* Free dynamically allocated items */
- if(H5A__free(attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
-
- /* Destroy shared attribute struct */
- attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
+ if(attr->shared)
+ if(H5A__shared_free(attr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
} /* end if */
else {
/* There are other references to the shared part of the attribute.
@@ -1205,18 +1226,18 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__close() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A_oloc
+ * Function: H5A_oloc
*
- * Purpose: Return the object location for an attribute. It's the
- * object location for the object to which the attribute
- * belongs, not the attribute itself.
+ * Purpose: Return the object location for an attribute. It's the
+ * object location for the object to which the attribute
+ * belongs, not the attribute itself.
*
- * Return: Success: Ptr to entry
- * Failure: NULL
+ * Return: Success: Ptr to entry
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, August 6, 1998
*
*-------------------------------------------------------------------------
@@ -1237,18 +1258,18 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_oloc() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A_nameof
+ * Function: H5A_nameof
*
- * Purpose: Return the group hier. path for an attribute. It's the
- * group hier. path for the object to which the attribute
- * belongs, not the attribute itself.
+ * Purpose: Return the group hier. path for an attribute. It's the
+ * group hier. path for the object to which the attribute
+ * belongs, not the attribute itself.
*
- * Return: Success: Ptr to entry
- * Failure: NULL
+ * Return: Success: Ptr to entry
+ * Failure: NULL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Monday, September 12, 2005
*
*-------------------------------------------------------------------------
@@ -1269,7 +1290,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_nameof() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A_type
*
@@ -1299,7 +1320,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_type() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__exists_by_name
*
@@ -1307,7 +1328,7 @@ done:
*
* Return: TRUE/FALSE/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Thursday, November 1, 2007
*
*-------------------------------------------------------------------------
@@ -1316,10 +1337,10 @@ htri_t
H5A__exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
- htri_t ret_value = FAIL; /* Return value */
+ htri_t ret_value = FAIL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -1345,18 +1366,18 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__exists_by_name() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__compact_build_table_cb
+ * Function: H5A__compact_build_table_cb
*
- * Purpose: Object header iterator callback routine to copy attribute
+ * Purpose: Object header iterator callback routine to copy attribute
* into table.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Dec 18 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Dec 18 2006
*
* Modification:Raymond Lu
* 24 June 2008
@@ -1406,9 +1427,9 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__compact_build_table_cb() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__compact_build_table
+ * Function: H5A__compact_build_table
*
* Purpose: Builds a table containing a sorted list of attributes for
* an object
@@ -1418,8 +1439,8 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Dec 18, 2006
+ * Programmer: Quincey Koziol
+ * Dec 18, 2006
*
*-------------------------------------------------------------------------
*/
@@ -1469,19 +1490,19 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__compact_build_table() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__dense_build_table_cb
+ * Function: H5A__dense_build_table_cb
*
- * Purpose: Callback routine for building table of attributes from dense
+ * Purpose: Callback routine for building table of attributes from dense
* attribute storage.
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Dec 11 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Dec 11 2006
*
*-------------------------------------------------------------------------
*/
@@ -1513,7 +1534,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__dense_build_table_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__dense_build_table
*
@@ -1526,8 +1547,8 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Dec 11, 2006
+ * Programmer: Quincey Koziol
+ * Dec 11, 2006
*
*-------------------------------------------------------------------------
*/
@@ -1598,22 +1619,22 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__dense_build_table() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__attr_cmp_name_inc
+ * Function: H5A__attr_cmp_name_inc
*
- * Purpose: Callback routine for comparing two attribute names, in
+ * Purpose: Callback routine for comparing two attribute names, in
* increasing alphabetic order
*
- * Return: An integer less than, equal to, or greater than zero if the
+ * Return: An integer less than, equal to, or greater than zero if the
* first argument is considered to be respectively less than,
* equal to, or greater than the second. If two members compare
* as equal, their order in the sorted array is undefined.
* (i.e. same as strcmp())
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Dec 11 2006
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Dec 11 2006
*
*-------------------------------------------------------------------------
*/
@@ -1626,22 +1647,22 @@ H5A__attr_cmp_name_inc(const void *attr1, const void *attr2)
(*(const H5A_t * const *)attr2)->shared->name))
} /* end H5A__attr_cmp_name_inc() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__attr_cmp_name_dec
+ * Function: H5A__attr_cmp_name_dec
*
- * Purpose: Callback routine for comparing two attribute names, in
+ * Purpose: Callback routine for comparing two attribute names, in
* decreasing alphabetic order
*
- * Return: An integer less than, equal to, or greater than zero if the
+ * Return: An integer less than, equal to, or greater than zero if the
* second argument is considered to be respectively less than,
* equal to, or greater than the first. If two members compare
* as equal, their order in the sorted array is undefined.
* (i.e. opposite of strcmp())
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Feb 8 2007
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Feb 8 2007
*
*-------------------------------------------------------------------------
*/
@@ -1654,21 +1675,21 @@ H5A__attr_cmp_name_dec(const void *attr1, const void *attr2)
(*(const H5A_t * const *)attr1)->shared->name))
} /* end H5A__attr_cmp_name_dec() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__attr_cmp_corder_inc
+ * Function: H5A__attr_cmp_corder_inc
*
- * Purpose: Callback routine for comparing two attributes, in
+ * Purpose: Callback routine for comparing two attributes, in
* increasing creation order
*
- * Return: An integer less than, equal to, or greater than zero if the
+ * Return: An integer less than, equal to, or greater than zero if the
* first argument is considered to be respectively less than,
* equal to, or greater than the second. If two members compare
* as equal, their order in the sorted array is undefined.
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Feb 8 2007
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Feb 8 2007
*
*-------------------------------------------------------------------------
*/
@@ -1689,21 +1710,21 @@ H5A__attr_cmp_corder_inc(const void *attr1, const void *attr2)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__attr_cmp_corder_inc() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__attr_cmp_corder_dec
+ * Function: H5A__attr_cmp_corder_dec
*
- * Purpose: Callback routine for comparing two attributes, in
+ * Purpose: Callback routine for comparing two attributes, in
* decreasing creation order
*
- * Return: An integer less than, equal to, or greater than zero if the
+ * Return: An integer less than, equal to, or greater than zero if the
* second argument is considered to be respectively less than,
* equal to, or greater than the first. If two members compare
* as equal, their order in the sorted array is undefined.
*
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Feb 8 2007
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Feb 8 2007
*
*-------------------------------------------------------------------------
*/
@@ -1724,17 +1745,17 @@ H5A__attr_cmp_corder_dec(const void *attr1, const void *attr2)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__attr_cmp_corder_dec() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__attr_sort_table
+ * Function: H5A__attr_sort_table
*
* Purpose: Sort table containing a list of attributes for an object
*
- * Return: Success: Non-negative
- * Failure: Negative
+ * Return: Success: Non-negative
+ * Failure: Negative
*
- * Programmer: Quincey Koziol
- * Dec 11, 2006
+ * Programmer: Quincey Koziol
+ * Dec 11, 2006
*
*-------------------------------------------------------------------------
*/
@@ -1769,7 +1790,7 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type,
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5A__attr_sort_table() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__attr_iterate_table
*
@@ -1778,8 +1799,8 @@ H5A__attr_sort_table(H5A_attr_table_t *atable, H5_index_t idx_type,
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Dec 18, 2006
+ * Programmer: Quincey Koziol
+ * Dec 18, 2006
*
*-------------------------------------------------------------------------
*/
@@ -1851,7 +1872,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__attr_iterate_table() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__attr_release_table
*
@@ -1859,15 +1880,15 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * Dec 11, 2006
+ * Programmer: Quincey Koziol
+ * Dec 11, 2006
*
*-------------------------------------------------------------------------
*/
herr_t
H5A__attr_release_table(H5A_attr_table_t *atable)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -1892,7 +1913,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__attr_release_table() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__get_ainfo
*
@@ -1923,11 +1944,11 @@ H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo)
/* Check if the "attribute info" message exists */
if((ret_value = H5O_msg_exists_oh(oh, H5O_AINFO_ID)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header")
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "unable to check object header")
if(ret_value > 0) {
/* Retrieve the "attribute info" structure */
if(NULL == H5O_msg_read_oh(f, oh, H5O_AINFO_ID, ainfo))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't read AINFO message")
/* Check if we don't know how many attributes there are */
if(ainfo->nattrs == HSIZET_MAX) {
@@ -1956,7 +1977,7 @@ done:
FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5A__get_ainfo() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__set_version
*
@@ -2018,7 +2039,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__set_version() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__attr_copy_file
*
@@ -2049,11 +2070,11 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
hid_t tid_mem = -1; /* Datatype ID for memory datatype */
void *buf = NULL; /* Buffer for copying data */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
- void *bkg_buf = NULL; /* Background buffer */
+ void *bkg_buf = NULL; /* Background buffer */
hid_t buf_sid = -1; /* ID for buffer dataspace */
- hssize_t sdst_nelmts; /* # of elements in destination attribute (signed) */
- size_t dst_nelmts; /* # of elements in destination attribute */
- size_t dst_dt_size; /* Size of destination attribute datatype */
+ hssize_t sdst_nelmts; /* # of elements in destination attribute (signed) */
+ size_t dst_nelmts; /* # of elements in destination attribute */
+ size_t dst_dt_size; /* Size of destination attribute datatype */
H5A_t *ret_value = NULL; /* Return value */
FUNC_ENTER_PACKAGE
@@ -2226,35 +2247,35 @@ H5A__attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_s
if(NULL == (buf = H5FL_BLK_MALLOC(attr_buf, buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation NULLed for raw data chunk")
- HDmemcpy(buf, attr_src->shared->data, attr_src->shared->data_size);
+ H5MM_memcpy(buf, attr_src->shared->data, attr_src->shared->data_size);
- /* Allocate background memory */
- if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst))
- if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed")
+ /* Allocate background memory */
+ if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst))
+ if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed")
/* Convert from source file to memory */
if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed")
- HDmemcpy(reclaim_buf, buf, buf_size);
+ H5MM_memcpy(reclaim_buf, buf, buf_size);
- /* Set background buffer to all zeros */
- if(bkg_buf)
- HDmemset(bkg_buf, 0, buf_size);
+ /* Set background buffer to all zeros */
+ if(bkg_buf)
+ HDmemset(bkg_buf, 0, buf_size);
/* Convert from memory to destination file */
if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg_buf) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "datatype conversion NULLed")
- HDmemcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size);
+ H5MM_memcpy(attr_dst->shared->data, buf, attr_dst->shared->data_size);
- if(H5D_vlen_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
+ if(H5T_reclaim(tid_mem, buf_space, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, NULL, "unable to reclaim variable-length data")
} /* end if */
else {
HDassert(attr_dst->shared->data_size == attr_src->shared->data_size);
- HDmemcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size);
+ H5MM_memcpy(attr_dst->shared->data, attr_src->shared->data, attr_src->shared->data_size);
} /* end else */
} /* end if(attr_src->shared->data) */
@@ -2301,7 +2322,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__attr_copy_file() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__attr_post_copy_file
*
@@ -2339,7 +2360,7 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src,
HDassert(file_src);
HDassert(file_dst);
- if(H5T_is_named(attr_src->shared->dt)) {
+ if (H5T_is_named(attr_src->shared->dt)) {
H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */
H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */
@@ -2380,13 +2401,9 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src,
/* Check for expanding references */
if(cpy_info->expand_ref) {
- size_t ref_count;
-
- /* Determine # of reference elements to copy */
- ref_count = attr_dst->shared->data_size / H5T_get_size(attr_dst->shared->dt);
-
/* Copy objects referenced in source buffer to destination file and set destination elements */
- if(H5O_copy_expand_ref(file_src, attr_dst->shared->data, file_dst, attr_dst->shared->data, ref_count, H5T_get_ref_type(attr_dst->shared->dt), cpy_info) < 0)
+ if(H5O_copy_expand_ref(file_src, H5I_INVALID_HID, attr_src->shared->dt,
+ attr_src->shared->data, attr_src->shared->data_size, file_dst, attr_dst->shared->data, cpy_info) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
} /* end if */
else
@@ -2398,7 +2415,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__attr_post_copy_file() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__dense_post_copy_file_cb
*
@@ -2456,7 +2473,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__dense_post_copy_file_cb() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__dense_post_copy_file_all
*
@@ -2503,7 +2520,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__dense_post_copy_file_all */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__rename_by_name
*
@@ -2511,7 +2528,7 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* February 20, 2007
*
*-------------------------------------------------------------------------
@@ -2521,10 +2538,10 @@ H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_na
const char *new_attr_name)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -2553,7 +2570,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__rename_by_name() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__iterate_common
*
@@ -2561,7 +2578,7 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* December 6, 2017
*
*-------------------------------------------------------------------------
@@ -2588,7 +2605,7 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__iterate_common() */
-
+
/*-------------------------------------------------------------------------
* Function: H5A__iterate
*
@@ -2596,16 +2613,20 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
- * December 6, 2017
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
+H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *idx, H5A_operator2_t op, void *op_data)
{
+ H5G_loc_t obj_loc; /* Location used to open group */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
+ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
+ hid_t obj_loc_id = H5I_INVALID_HID; /* ID for object located */
H5A_attr_iter_op_t attr_op; /* Attribute operator */
+ void *temp_obj = NULL;
+ H5I_type_t obj_type;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -2614,16 +2635,42 @@ H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order,
attr_op.op_type = H5A_ATTR_OP_APP2;
attr_op.u.app_op2 = op;
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object's location */
+ if(H5G_loc_find(loc, obj_name, &obj_loc) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found");
+ loc_found = TRUE;
+
+ /* Open the object */
+ if(NULL == (temp_obj = H5O_open_by_loc(&obj_loc, &obj_type)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object");
+
+ /* Get an ID for the object */
+ if((obj_loc_id = H5VL_wrap_register(obj_type, temp_obj, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+
/* Call internal attribute iteration routine */
- if((ret_value = H5A__iterate_common(loc_id, idx_type, order, idx, &attr_op, op_data)) < 0)
+ if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes")
done:
+ /* Release resources */
+ if(obj_loc_id != H5I_INVALID_HID) {
+ if(H5I_dec_app_ref(obj_loc_id) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object");
+ } /* end if */
+ else if(loc_found && H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location");
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__iterate() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
-
+
/*-------------------------------------------------------------------------
* Function: H5A__iterate_old
*
@@ -2631,7 +2678,7 @@ done:
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* December 6, 2017
*
*-------------------------------------------------------------------------
@@ -2644,7 +2691,7 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op,
hsize_t idx; /* Index of attribute to start iterating at */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_PACKAGE_NOERR
/* Build attribute operator info */
attr_op.op_type = H5A_ATTR_OP_APP;
@@ -2655,87 +2702,25 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op,
/* Call internal attribute iteration routine */
if((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes")
+ HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes");
/* Translate hsize_t index value to legacy unsigned index value*/
if(attr_num)
*attr_num = (unsigned)idx;
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__iterate_old() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
-/*-------------------------------------------------------------------------
- * Function: H5A__iterate_by_name
- *
- * Purpose: Private version of H5Aiterate_by_name
- *
- * Return: SUCCEED/FAIL
- *
- * Programmer: Quincey Koziol
- * December 6, 2017
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op,
- void *op_data)
-{
- H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
- hid_t obj_loc_id = (-1); /* ID for object located */
- H5A_attr_iter_op_t attr_op; /* Attribute operator */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object's location */
- if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
-
- /* Open the object */
- if((obj_loc_id = H5O_open_by_loc(&obj_loc, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
- /* Build attribute operator info */
- attr_op.op_type = H5A_ATTR_OP_APP2;
- attr_op.u.app_op2 = op;
-
- /* Call attribute iteration routine */
- if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes")
-
-done:
- /* Release resources */
- if(obj_loc_id > 0) {
- if(H5I_dec_app_ref(obj_loc_id) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
- }
- else if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5A__iterate_by_name() */
-
-
/*-------------------------------------------------------------------------
- * Function: H5A__delete_by_name
+ * Function: H5A__delete_by_name
*
* Purpose: Private version of H5Adelete_by_name
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* December 6, 2017
*
*-------------------------------------------------------------------------
@@ -2744,8 +2729,8 @@ herr_t
H5A__delete_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_name)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2773,15 +2758,15 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5A__delete_by_name() */
-
+
/*-------------------------------------------------------------------------
- * Function: H5A__delete_by_idx
+ * Function: H5A__delete_by_idx
*
* Purpose: Private version of H5Adelete_by_idx
*
* Return: SUCCEED/FAIL
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* December 6, 2017
*
*-------------------------------------------------------------------------
@@ -2791,8 +2776,8 @@ H5A__delete_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_ty
H5_iter_order_t order, hsize_t n)
{
H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
herr_t ret_value = SUCCEED; /* Return value */