diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 1999-07-17 23:59:54 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 1999-07-17 23:59:54 (GMT) |
commit | 9b50a916c5b0f71cee33cdd040e074bd6f0d3c83 (patch) | |
tree | 44eb45f596b5d5391f2503690a576fc121d385f3 /src | |
parent | e6fc1366cb7b7b89deedac35d39981318574bbb5 (diff) | |
download | hdf5-9b50a916c5b0f71cee33cdd040e074bd6f0d3c83.zip hdf5-9b50a916c5b0f71cee33cdd040e074bd6f0d3c83.tar.gz hdf5-9b50a916c5b0f71cee33cdd040e074bd6f0d3c83.tar.bz2 |
[svn-r1506] Bug fixes to get VL datatype fields in compound datatypes working. Also, some
memory leaks plugged in other routines.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Shyper.c | 9 | ||||
-rw-r--r-- | src/H5T.c | 43 | ||||
-rw-r--r-- | src/H5Tpkg.h | 3 | ||||
-rw-r--r-- | src/H5Tvlen.c | 11 |
4 files changed, 26 insertions, 40 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 50704bd..8227c87 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -2844,6 +2844,10 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf) } /* end if */ } /* end for */ + /* Free temporary buffers */ + H5MM_xfree(start); + H5MM_xfree(count); + done: FUNC_LEAVE (ret_value); } /* H5S_hyper_select_deserialize() */ @@ -3160,9 +3164,11 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t iter_info.src=buf; iter_info.lo_bounds=lo_bounds; iter_info.hi_bounds=hi_bounds; + /* Set up the size of the memory space */ HDmemcpy(iter_info.mem_size, space->extent.u.simple.size, space->extent.u.simple.rank*sizeof(hsize_t)); iter_info.mem_size[space->extent.u.simple.rank]=iter_info.elem_size; + /* Copy the location of the region in the file */ iter_info.op=operator; iter_info.op_data=operator_data; @@ -3175,6 +3181,9 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t H5MM_xfree(lo_bounds); H5MM_xfree(hi_bounds); + /* Release selection iterator */ + H5S_sel_iter_release(space,&iter); + done: FUNC_LEAVE (ret_value); } /* H5S_hyper_select_iterate() */ @@ -4698,36 +4698,6 @@ H5T_open_oid (H5G_entry_t *ent) /*------------------------------------------------------------------------- - * Function: H5T_cmp_field_off - * - * Purpose: Compares field offsets for qsort - * - * Return: <0, 0, or >0 if field1's offset is less than, equal to, or greater - * than field2's offset - * - * Programmer: Quincey Koziol - * Thursday, July 15th, 1999 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5T_cmp_field_off(const void *_field1, const void *_field2) -{ - const H5T_cmemb_t *field1=(const H5T_cmemb_t *)_field1, - *field2=(const H5T_cmemb_t *)_field2; - - if(field1->offset < field2->offset) - return(-1); - else if(field1->offset > field2->offset) - return(1); - else - return(0); -} - - -/*------------------------------------------------------------------------- * Function: H5T_copy * * Purpose: Copies datatype OLD_DT. The resulting data type is not @@ -4836,12 +4806,13 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } - HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb, - new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t)); /* Sort the fields based on offsets */ - qsort(new_dt->u.compnd.memb, new_dt->u.compnd.nmembs, sizeof(H5T_cmemb_t), H5T_cmp_field_off); + H5T_sort_value(old_dt,NULL); + HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb, + new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t)); + for (i=0; i<new_dt->u.compnd.nmembs; i++) { s = new_dt->u.compnd.memb[i].name; new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s); @@ -4852,8 +4823,12 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) new_dt->u.compnd.memb[i].offset += accum_change; /* If the field changed size, add that change to the accumulated size change */ - if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[i].type->size) + if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[i].type->size) { + /* Adjust the size of the member */ + new_dt->u.compnd.memb[i].size = (old_dt->u.compnd.memb[i].size*tmp->size)/old_dt->u.compnd.memb[i].type->size; + accum_change += (new_dt->u.compnd.memb[i].type->size - old_dt->u.compnd.memb[i].type->size); + } /* end if */ } /* Apply the accumulated size change to the size of the compound struct */ diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index bb41580..bfd59cf 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -206,9 +206,6 @@ __DLLVAR__ size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g; __DLLVAR__ size_t H5T_NATIVE_INT_FAST64_ALIGN_g; __DLLVAR__ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; -/* H5Tcopy support functions */ -__DLL__ int H5T_cmp_field_off(const void *_field1, const void *_field2); - /* Conversion functions */ __DLL__ herr_t H5T_conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t stride, void *buf, diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index c9d0e35..ce4b342 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -506,7 +506,7 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) size_t old_size; /* Preview size of a field */ /* Sort the fields based on offsets */ - qsort(dt->u.compnd.memb, dt->u.compnd.nmembs, sizeof(H5T_cmemb_t), H5T_cmp_field_off); + H5T_sort_value(dt,NULL); for (i=0; i<dt->u.compnd.nmembs; i++) { /* Apply the accumulated size change to the offset of the field */ @@ -521,9 +521,14 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc) if(H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc)<0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); - /* If the field changed size, add that change to the accumulated size change */ - if(old_size != dt->u.compnd.memb[i].type->size) + /* Check if the field changed size */ + if(old_size != dt->u.compnd.memb[i].type->size) { + /* Adjust the size of the member */ + dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size; + + /* Add that change to the accumulated size change */ accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size); + } /* end if */ } /* end if */ } /* end for */ |