summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2009-01-26 19:18:40 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2009-01-26 19:18:40 (GMT)
commit0682bfceb764bd4f4b4fb61695ca8d99440f39b1 (patch)
treef5cd663ffd21253c6328a80a7248774f0468f594 /src/H5T.c
parent2a1a78a0b4187870df86097590d70a9655e19750 (diff)
downloadhdf5-0682bfceb764bd4f4b4fb61695ca8d99440f39b1.zip
hdf5-0682bfceb764bd4f4b4fb61695ca8d99440f39b1.tar.gz
hdf5-0682bfceb764bd4f4b4fb61695ca8d99440f39b1.tar.bz2
[svn-r16347] Purpose: enhancements the H5Tinsert, H5Tpack
Description: H5Tinsert will now detect when a compound type that was previously not packed becomes packed due to out of offset order insertion of a member. H5Tinsert will now attempt to keep members sorted by offset order. This should improve performance of H5Tinsert in all cases due to the fact that it no longer needs to check every other member for overlapping, and should improve performance of H5Tpack and possibly type conversion when compounds are packed out of order. Tested: jam, smirom (h5committest)
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/H5T.c b/src/H5T.c
index ee02016..d6bc1ed 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2973,8 +2973,10 @@ H5T_create(H5T_class_t type, size_t size)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->shared->type = type;
- if(type==H5T_COMPOUND)
+ if(type==H5T_COMPOUND) {
dt->shared->u.compnd.packed=TRUE; /* Start out packed */
+ dt->shared->u.compnd.sorted=H5T_SORT_VALUE; /* Start out sorted by value */
+ } /* end if */
else if(type==H5T_OPAQUE)
/* Initialize the tag in case it's not set later. A null tag will
* cause problems for later operations. */
@@ -3173,13 +3175,16 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* name and type fields of each new member with copied values.
* That is, H5T_copy() is a deep copy.
*/
- new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc *
- sizeof(H5T_cmemb_t));
- if (NULL==new_dt->shared->u.compnd.memb)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
-
- HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
- new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t));
+ /* Only malloc if space has been allocated for members - NAF */
+ if(new_dt->shared->u.compnd.nalloc > 0) {
+ new_dt->shared->u.compnd.memb = H5MM_malloc(new_dt->shared->u.compnd.nalloc *
+ sizeof(H5T_cmemb_t));
+ if (NULL==new_dt->shared->u.compnd.memb)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+
+ HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb,
+ new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t));
+ } /* end if */
for(i = 0; i < new_dt->shared->u.compnd.nmembs; i++) {
unsigned j;