summaryrefslogtreecommitdiffstats
path: root/src/H5Tcompound.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-10-01 14:04:36 (GMT)
commitf1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch)
treeebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /src/H5Tcompound.c
parent10343c197906415388f2a4c8d292e21d25cf7381 (diff)
downloadhdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz
hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2
Source formatted
Diffstat (limited to 'src/H5Tcompound.c')
-rw-r--r--src/H5Tcompound.c235
1 files changed, 107 insertions, 128 deletions
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index ea8d756..e8fd7e8 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -20,34 +20,30 @@
/* Module Setup */
/****************/
-#include "H5Tmodule.h" /* This source code file is part of the H5T module */
-
+#include "H5Tmodule.h" /* This source code file is part of the H5T module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /*generic functions */
-#include "H5CXprivate.h" /*API Contexts */
-#include "H5Eprivate.h" /*error handling */
-#include "H5Iprivate.h" /*ID functions */
-#include "H5MMprivate.h" /*memory management */
-#include "H5Tpkg.h" /*data-type functions */
+#include "H5private.h" /*generic functions */
+#include "H5CXprivate.h" /*API Contexts */
+#include "H5Eprivate.h" /*error handling */
+#include "H5Iprivate.h" /*ID functions */
+#include "H5MMprivate.h" /*memory management */
+#include "H5Tpkg.h" /*data-type functions */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
@@ -55,28 +51,22 @@ static herr_t H5T__pack(const H5T_t *dt);
static htri_t H5T__is_packed(const H5T_t *dt);
static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno);
-
/*********************/
/* Public Variables */
/*********************/
-
/*********************/
/* Package Variables */
/*********************/
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5Tget_member_offset
*
@@ -98,17 +88,17 @@ static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno);
size_t
H5Tget_member_offset(hid_t type_id, unsigned membno)
{
- H5T_t *dt; /* Datatype to query */
- size_t ret_value; /* Return value */
+ H5T_t *dt; /* Datatype to query */
+ size_t ret_value; /* Return value */
FUNC_ENTER_API(0)
H5TRACE2("z", "iIu", type_id, membno);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype")
- if(membno >= dt->shared->u.compnd.nmembs)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number")
+ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound datatype")
+ if (membno >= dt->shared->u.compnd.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number")
/* Value */
ret_value = H5T_GET_MEMBER_OFFSET(dt->shared, membno);
@@ -117,7 +107,6 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_member_offset() */
-
/*-------------------------------------------------------------------------
* Function: H5T_get_member_offset
*
@@ -148,7 +137,6 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno)
FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].offset)
} /* end H5T_get_member_offset() */
-
/*-------------------------------------------------------------------------
* Function: H5Tget_member_class
*
@@ -166,16 +154,16 @@ H5T_get_member_offset(const H5T_t *dt, unsigned membno)
H5T_class_t
H5Tget_member_class(hid_t type_id, unsigned membno)
{
- H5T_t *dt; /* Datatype to query */
- H5T_class_t ret_value; /* Return value */
+ H5T_t * dt; /* Datatype to query */
+ H5T_class_t ret_value; /* Return value */
FUNC_ENTER_API(H5T_NO_CLASS)
H5TRACE2("Tt", "iIu", type_id, membno);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
+ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound datatype")
- if(membno >= dt->shared->u.compnd.nmembs)
+ if (membno >= dt->shared->u.compnd.nmembs)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number")
/* Get the type's class. We have to use this function to get type class
@@ -187,7 +175,6 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_member_class() */
-
/*-------------------------------------------------------------------------
* Function: H5Tget_member_type
*
@@ -209,36 +196,35 @@ done:
hid_t
H5Tget_member_type(hid_t type_id, unsigned membno)
{
- H5T_t *dt; /* Datatype to query */
- H5T_t *memb_dt = NULL; /* Member datatype */
- hid_t ret_value; /* Return value */
+ H5T_t *dt; /* Datatype to query */
+ H5T_t *memb_dt = NULL; /* Member datatype */
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "iIu", type_id, membno);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
+ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a compound datatype")
- if(membno >= dt->shared->u.compnd.nmembs)
+ if (membno >= dt->shared->u.compnd.nmembs)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid member number")
/* Retrieve the datatype for the member */
- if(NULL == (memb_dt = H5T__reopen_member_type(dt, membno)))
+ if (NULL == (memb_dt = H5T__reopen_member_type(dt, membno)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to retrieve member type")
/* Get an ID for the datatype */
- if((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0)
+ if ((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable register datatype atom")
done:
- if(ret_value < 0)
- if(memb_dt && H5T_close(memb_dt) < 0)
+ if (ret_value < 0)
+ if (memb_dt && H5T_close(memb_dt) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype")
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_member_type() */
-
/*-------------------------------------------------------------------------
* Function: H5T_get_member_type
*
@@ -258,7 +244,7 @@ done:
H5T_t *
H5T_get_member_type(const H5T_t *dt, unsigned membno)
{
- H5T_t *ret_value = NULL; /* Return value */
+ H5T_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -267,14 +253,13 @@ H5T_get_member_type(const H5T_t *dt, unsigned membno)
HDassert(membno < dt->shared->u.compnd.nmembs);
/* Copy datatype */
- if(NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype")
+ if (NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_get_member_type() */
-
/*-------------------------------------------------------------------------
* Function: H5T__reopen_member_type
*
@@ -295,7 +280,7 @@ done:
static H5T_t *
H5T__reopen_member_type(const H5T_t *dt, unsigned membno)
{
- H5T_t *ret_value = NULL; /* Return value */
+ H5T_t *ret_value = NULL; /* Return value */
FUNC_ENTER_STATIC
@@ -304,14 +289,13 @@ H5T__reopen_member_type(const H5T_t *dt, unsigned membno)
HDassert(membno < dt->shared->u.compnd.nmembs);
/* Copy datatype, possibly re-opening it */
- if(NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype")
+ if (NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__reopen_member_type() */
-
/*-------------------------------------------------------------------------
* Function: H5T__get_member_size
*
@@ -336,7 +320,6 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno)
FUNC_LEAVE_NOAPI(dt->shared->u.compnd.memb[membno].type->shared->size)
} /* end H5T__get_member_size() */
-
/*-------------------------------------------------------------------------
* Function: H5Tinsert
*
@@ -362,34 +345,34 @@ H5T__get_member_size(const H5T_t *dt, unsigned membno)
herr_t
H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)
{
- H5T_t *parent; /* The compound parent datatype */
- H5T_t *member; /* The member datatype */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t *parent; /* The compound parent datatype */
+ H5T_t *member; /* The member datatype */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*szi", parent_id, name, offset, member_id);
/* Check args */
- if(parent_id == member_id)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself")
- if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_COMPOUND != parent->shared->type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
- if(H5T_STATE_TRANSIENT != parent->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only")
- if(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name")
- if(NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if (parent_id == member_id)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself")
+ if (NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) ||
+ H5T_COMPOUND != parent->shared->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
+ if (H5T_STATE_TRANSIENT != parent->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only")
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name")
+ if (NULL == (member = (H5T_t *)H5I_object_verify(member_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Insert */
- if(H5T__insert(parent, name, offset, member) < 0)
+ if (H5T__insert(parent, name, offset, member) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tinsert() */
-
/*-------------------------------------------------------------------------
* Function: H5Tpack
*
@@ -406,25 +389,25 @@ done:
herr_t
H5Tpack(hid_t type_id)
{
- H5T_t *dt; /* Datatype to modify */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype to modify */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", type_id);
/* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
+ if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) ||
+ H5T_detect_class(dt, H5T_COMPOUND, TRUE) <= 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
/* Pack */
- if(H5T__pack(dt) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype")
+ if (H5T__pack(dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tpack() */
-
/*-------------------------------------------------------------------------
* Function: H5T__insert
*
@@ -443,10 +426,10 @@ done:
herr_t
H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
{
- unsigned idx; /* Index of member to insert */
- size_t total_size;
- unsigned i; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned idx; /* Index of member to insert */
+ size_t total_size;
+ unsigned i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -457,45 +440,44 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
HDassert(name && *name);
/* Does NAME already exist in PARENT? */
- for(i = 0; i < parent->shared->u.compnd.nmembs; i++)
- if(!HDstrcmp(parent->shared->u.compnd.memb[i].name, name))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique")
+ for (i = 0; i < parent->shared->u.compnd.nmembs; i++)
+ if (!HDstrcmp(parent->shared->u.compnd.memb[i].name, name))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique")
/* Does the new member overlap any existing member ? */
total_size = member->shared->size;
- for(i = 0; i < parent->shared->u.compnd.nmembs; i++)
- if((offset <= parent->shared->u.compnd.memb[i].offset &&
- (offset + total_size) > parent->shared->u.compnd.memb[i].offset) ||
- (parent->shared->u.compnd.memb[i].offset <= offset &&
- (parent->shared->u.compnd.memb[i].offset +
- parent->shared->u.compnd.memb[i].size) > offset))
+ for (i = 0; i < parent->shared->u.compnd.nmembs; i++)
+ if ((offset <= parent->shared->u.compnd.memb[i].offset &&
+ (offset + total_size) > parent->shared->u.compnd.memb[i].offset) ||
+ (parent->shared->u.compnd.memb[i].offset <= offset &&
+ (parent->shared->u.compnd.memb[i].offset + parent->shared->u.compnd.memb[i].size) > offset))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member")
/* Does the new member overlap the end of the compound type? */
- if((offset + total_size) > parent->shared->size)
+ if ((offset + total_size) > parent->shared->size)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type")
/* Increase member array if necessary */
- if(parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) {
- unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2);
+ if (parent->shared->u.compnd.nmembs >= parent->shared->u.compnd.nalloc) {
+ unsigned na = MAX(1, parent->shared->u.compnd.nalloc * 2);
H5T_cmemb_t *x = (H5T_cmemb_t *)H5MM_realloc(parent->shared->u.compnd.memb, na * sizeof(H5T_cmemb_t));
- if(!x)
+ if (!x)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "memory allocation failed")
parent->shared->u.compnd.nalloc = na;
- parent->shared->u.compnd.memb = x;
+ parent->shared->u.compnd.memb = x;
} /* end if */
/* Add member to end of member array */
- idx = parent->shared->u.compnd.nmembs;
- parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name);
+ idx = parent->shared->u.compnd.nmembs;
+ parent->shared->u.compnd.memb[idx].name = H5MM_xstrdup(name);
parent->shared->u.compnd.memb[idx].offset = offset;
- parent->shared->u.compnd.memb[idx].size = total_size;
- parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL);
+ parent->shared->u.compnd.memb[idx].size = total_size;
+ parent->shared->u.compnd.memb[idx].type = H5T_copy(member, H5T_COPY_ALL);
parent->shared->u.compnd.sorted = H5T_SORT_NONE;
parent->shared->u.compnd.nmembs++;
- parent->shared->u.compnd.memb_size+=total_size;
+ parent->shared->u.compnd.memb_size += total_size;
/* It should not be possible to get this far if the type is already packed
* - the new member would overlap something */
@@ -505,23 +487,22 @@ H5T__insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
H5T__update_packed(parent);
/* Set the "force conversion" flag if the field's datatype indicates */
- if(member->shared->force_conv == TRUE)
+ if (member->shared->force_conv == TRUE)
parent->shared->force_conv = TRUE;
/* Check for member having a later version than the parent */
- if(parent->shared->version < member->shared->version)
+ if (parent->shared->version < member->shared->version)
/* Upgrade parent datatype (and all other members also) */
/* (can't use a partial datatype and later versions of the format are
* more efficient, so might as well upgrade all members also... -QAK)
*/
- if(H5T__upgrade_version(parent, member->shared->version) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version")
+ if (H5T__upgrade_version(parent, member->shared->version) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't upgrade member encoding version")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__insert() */
-
/*-------------------------------------------------------------------------
* Function: H5T__pack
*
@@ -538,48 +519,49 @@ done:
static herr_t
H5T__pack(const H5T_t *dt)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
HDassert(dt);
- if(H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) {
+ if (H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) {
/* If datatype has been packed, skip packing it and indicate success */
- if(TRUE == H5T__is_packed(dt))
+ if (TRUE == H5T__is_packed(dt))
HGOTO_DONE(SUCCEED)
/* Check for packing unmodifiable datatype */
- if(H5T_STATE_TRANSIENT != dt->shared->state)
+ if (H5T_STATE_TRANSIENT != dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only")
- if(dt->shared->parent) {
- if(H5T__pack(dt->shared->parent) < 0)
+ if (dt->shared->parent) {
+ if (H5T__pack(dt->shared->parent) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype")
/* Adjust size of datatype appropriately */
- if(dt->shared->type == H5T_ARRAY)
+ if (dt->shared->type == H5T_ARRAY)
dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem;
- else if(dt->shared->type != H5T_VLEN)
+ else if (dt->shared->type != H5T_VLEN)
dt->shared->size = dt->shared->parent->shared->size;
} /* end if */
- else if(dt->shared->type == H5T_COMPOUND) {
- size_t offset; /* Offset of member */
- unsigned i; /* Local index variable */
+ else if (dt->shared->type == H5T_COMPOUND) {
+ size_t offset; /* Offset of member */
+ unsigned i; /* Local index variable */
/* Recursively pack the members */
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- if(H5T__pack(dt->shared->u.compnd.memb[i].type) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype")
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ if (H5T__pack(dt->shared->u.compnd.memb[i].type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to pack part of a compound datatype")
/* Update the member size */
dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].type)->shared->size;
} /* end for */
/* Remove padding between members */
- if(H5T__sort_value(dt, NULL) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed")
- for(i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ if (H5T__sort_value(dt, NULL) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed")
+ for (i = 0, offset = 0; i < dt->shared->u.compnd.nmembs; i++) {
dt->shared->u.compnd.memb[i].offset = offset;
offset += dt->shared->u.compnd.memb[i].size;
}
@@ -590,13 +572,12 @@ H5T__pack(const H5T_t *dt)
/* Mark the type as packed now */
dt->shared->u.compnd.packed = TRUE;
} /* end if */
- } /* end if */
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__pack() */
-
/*-------------------------------------------------------------------------
* Function: H5T__is_packed
*
@@ -613,24 +594,23 @@ done:
static htri_t
H5T__is_packed(const H5T_t *dt)
{
- htri_t ret_value = TRUE; /* Return value */
+ htri_t ret_value = TRUE; /* Return value */
FUNC_ENTER_STATIC_NOERR
HDassert(dt);
/* Go up the chain as far as possible */
- while(dt->shared->parent)
+ while (dt->shared->parent)
dt = dt->shared->parent;
/* If this is a compound datatype, check if it is packed */
- if(dt->shared->type == H5T_COMPOUND)
+ if (dt->shared->type == H5T_COMPOUND)
ret_value = (htri_t)(dt->shared->u.compnd.packed);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__is_packed() */
-
/*-------------------------------------------------------------------------
* Function: H5T__update_packed
*
@@ -649,7 +629,7 @@ H5T__is_packed(const H5T_t *dt)
void
H5T__update_packed(const H5T_t *dt)
{
- unsigned i; /* Index */
+ unsigned i; /* Index */
FUNC_ENTER_PACKAGE_NOERR
@@ -657,20 +637,19 @@ H5T__update_packed(const H5T_t *dt)
HDassert(dt->shared->type == H5T_COMPOUND);
/* First check if all space is used in the "top level" type */
- if(dt->shared->size == dt->shared->u.compnd.memb_size) {
+ if (dt->shared->size == dt->shared->u.compnd.memb_size) {
/* Set the packed flag to TRUE */
dt->shared->u.compnd.packed = TRUE;
/* Now check if all members are packed */
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++)
- if(!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) {
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++)
+ if (!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) {
dt->shared->u.compnd.packed = FALSE;
break;
} /* end if */
- } /* end if */
+ } /* end if */
else
dt->shared->u.compnd.packed = FALSE;
FUNC_LEAVE_NOAPI_VOID
} /* end H5T__update_packed() */
-