summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5A.c24
-rw-r--r--src/H5Aint.c58
-rw-r--r--src/H5Apkg.h2
-rw-r--r--src/H5Aprivate.h3
4 files changed, 49 insertions, 38 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 513b764..f1a6408 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -666,6 +666,7 @@ hid_t
H5Aget_space(hid_t attr_id)
{
H5A_t *attr; /* Attribute object for ID */
+ H5S_t *ds = NULL;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -675,10 +676,19 @@ H5Aget_space(hid_t attr_id)
if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
- if((ret_value = H5A_get_space(attr)) < 0)
+ if(NULL == (ds = H5A_get_space(attr)))
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute")
+ /* Atomize */
+ if((ret_value = H5I_register(H5I_DATASPACE, ds, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
+
done:
+ if(ret_value < 0) {
+ if(ds && (H5S_close(ds) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
+ } /* end if */
+
FUNC_LEAVE_API(ret_value)
} /* H5Aget_space() */
@@ -703,6 +713,7 @@ hid_t
H5Aget_type(hid_t attr_id)
{
H5A_t *attr; /* Attribute object for ID */
+ H5T_t *dt = NULL;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -712,10 +723,19 @@ H5Aget_type(hid_t attr_id)
if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
- if((ret_value = H5A_get_type(attr)) < 0)
+ if(NULL == (dt = H5A_get_type(attr)))
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute")
+ /* Create an atom */
+ if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+
done:
+ if(ret_value < 0) {
+ if(dt && (H5T_close(dt) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
+ } /* end if */
+
FUNC_LEAVE_API(ret_value)
} /* H5Aget_type() */
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 520d4cd..81fa8b0 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -691,39 +691,31 @@ done:
/*-------------------------------------------------------------------------
* Function: H5A_get_space
*
- * Purpose: Returns and ID for the dataspace of the attribute.
+ * Purpose: Returns dataspace of the attribute.
*
- * Return: Success: ID for dataspace
+ * Return: Success: dataspace
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
+H5S_t *
H5A_get_space(H5A_t *attr)
{
- H5S_t *ds = NULL;
- hid_t ret_value = FAIL;
+ H5S_t *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
- /* Copy the attribute's dataspace */
- if(NULL == (ds = H5S_copy(attr->shared->ds, FALSE, TRUE)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace")
+ HDassert(attr);
- /* Atomize */
- if((ret_value = H5I_register(H5I_DATASPACE, ds, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
+ /* Copy the attribute's dataspace */
+ if(NULL == (ret_value = H5S_copy(attr->shared->ds, FALSE, TRUE)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to copy dataspace")
done:
- if(ret_value < 0 && ds) {
- if(H5S_close(ds) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
- } /* end if */
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_get_space() */
@@ -731,28 +723,30 @@ done:
/*-------------------------------------------------------------------------
* Function: H5A_get_type
*
- * Purpose: Returns and ID for the datatype of the dataset.
+ * Purpose: Returns datatype of the dataset.
*
- * Return: Success: ID for datatype
+ * Return: Success: datatype
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
+H5T_t *
H5A_get_type(H5A_t *attr)
{
- H5T_t *dt = NULL;
- hid_t ret_value = FAIL;
+ H5T_t *dt = NULL;
+ H5T_t *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
+ HDassert(attr);
+
/* Patch the datatype's "top level" file pointer */
if(H5T_patch_file(attr->shared->dt, attr->oloc.file) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to patch datatype's file pointer")
/*
* Copy the attribute's datatype. If the type is a named type then
@@ -760,25 +754,21 @@ H5A_get_type(H5A_t *attr)
* read-only.
*/
if(NULL == (dt = H5T_copy(attr->shared->dt, H5T_COPY_REOPEN)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy datatype")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to copy datatype")
/* Mark any datatypes as being in memory now */
if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
/* Lock copied type */
if(H5T_lock(dt, FALSE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to lock transient datatype")
- /* Create an atom */
- if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
+ ret_value = dt;
done:
- if(ret_value < 0) {
- if(dt && H5T_close(dt) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
- } /* end if */
+ if(!ret_value && dt && (H5T_close(dt) < 0))
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A_get_type() */
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index f587f81..f5e588c 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -198,8 +198,6 @@ H5_DLL herr_t H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_
H5_DLL ssize_t H5A_get_name(H5A_t *attr, size_t buf_size, char *buf);
H5_DLL H5A_t *H5A_copy(H5A_t *new_attr, const H5A_t *old_attr);
H5_DLL herr_t H5A_get_info(const H5A_t *attr, H5A_info_t *ainfo);
-H5_DLL hid_t H5A_get_type(H5A_t *attr);
-H5_DLL hid_t H5A_get_space(H5A_t *attr);
H5_DLL hid_t H5A_get_create_plist(H5A_t* attr);
H5_DLL herr_t H5A_free(H5A_t *attr);
H5_DLL herr_t H5A_close(H5A_t *attr);
diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h
index 6646fa2..6b62692 100644
--- a/src/H5Aprivate.h
+++ b/src/H5Aprivate.h
@@ -25,6 +25,7 @@
/* Private headers needed by this file */
#include "H5Gprivate.h" /* Groups */
#include "H5Oprivate.h" /* Object headers */
+#include "H5Sprivate.h" /* Dataspace */
#include "H5Tprivate.h" /* Datatypes */
@@ -77,6 +78,8 @@ typedef struct H5A_attr_iter_op_t {
H5_DLL struct H5O_loc_t *H5A_oloc(H5A_t *attr);
H5_DLL H5G_name_t *H5A_nameof(H5A_t *attr);
H5_DLL H5T_t *H5A_type(const H5A_t *attr);
+H5_DLL H5T_t *H5A_get_type(H5A_t *attr);
+H5_DLL H5S_t *H5A_get_space(H5A_t *attr);
H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc,
hid_t dxpl_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip,
hsize_t *last_attr, const H5A_attr_iter_op_t *attr_op, void *op_data);