summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5T.c15
-rw-r--r--src/H5Tcompound.c34
-rw-r--r--src/H5Tpkg.h1
3 files changed, 38 insertions, 12 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 9662983..bf6a209 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2959,7 +2959,7 @@ H5T_open (H5G_entry_t *ent, hid_t dxpl_id)
{
shared_fo->fo_count++;
- if(NULL == (dt = H5FL_CALLOC(H5T_t)))
+ if(NULL == (dt = H5FL_MALLOC(H5T_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
dt->shared=shared_fo;
@@ -3012,15 +3012,9 @@ H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id)
assert (ent);
- if(NULL==(dt=H5FL_CALLOC(H5T_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- if(NULL==(dt->shared=H5FL_MALLOC(H5T_shared_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
-
if (H5O_open (ent)<0)
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type");
- /* The fourth argument to H5O_read is dt because we've already CALLOC'ed memory for it */
- if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, dt, dxpl_id)))
+ if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, NULL, dxpl_id)))
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header");
/* Mark the type as named and open */
@@ -3568,10 +3562,7 @@ H5T_set_size(H5T_t *dt, size_t size)
}
}
- if((memb_type = H5T_get_member_type(dt, max_index))==NULL)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get type of member");
-
- max_size = H5T_get_size(memb_type);
+ max_size = H5T_get_member_size(dt, max_index);
if(size<(max_offset+max_size))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member ");
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index cbb269c..f29342f 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -300,6 +300,40 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5T_get_member_size
+ *
+ * Purpose: Returns the size of the specified member.
+ *
+ * Return: Success: The size in bytes of the member's datatype.
+ *
+ * Failure: 0
+ *
+ * Programmer: Quincey Koziol
+ * October 4, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5T_get_member_size(H5T_t *dt, int membno)
+{
+ size_t ret_value = 0;
+
+ FUNC_ENTER_NOAPI(H5T_get_member_size, 0);
+
+ assert(dt);
+ assert(membno >=0 && membno < dt->shared->u.compnd.nmembs);
+
+ /* Value */
+ ret_value = dt->shared->u.compnd.memb[membno].type->shared->size;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5Tinsert
*
* Purpose: Adds another member to the compound datatype PARENT_ID. The
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 8999d6e..2993f2f 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -1091,6 +1091,7 @@ H5_DLL H5T_t * H5T_array_create(H5T_t *base, int ndims,
/* Compound functions */
H5_DLL H5T_t *H5T_get_member_type(const H5T_t *dt, unsigned membno);
H5_DLL size_t H5T_get_member_offset(const H5T_t *dt, unsigned membno);
+H5_DLL size_t H5T_get_member_size(H5T_t *dt, int membno);
H5_DLL htri_t H5T_is_packed(const H5T_t *dt);
#endif