From 9c3d062c267e98526c00e0162f222f84e867d49d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 3 Jan 2002 21:41:57 -0500 Subject: [svn-r4772] Purpose: Bug Fix. Description: Equation to compute size of attribute in memory was incorrectly using the disk's datatype (and dataspace, but that turns out not to have been the actual issue) and when a variable length datatype was used for the attribute, the wrong size is being computed. Also, the variable-length datatype conversions aren't handling the default dataset transfer property list (H5P_DEFAULT) correctly. Solution: Changed attribute code to compute the attribute size in memory correctly by using the memory datatype & dataspace. Changed the variable-length datatype conversion code to use the default dataset transfer property list when H5P_DEFAULT is passed as the property list ID. Platforms tested: FreeBSD 4.5 (sleipnir) --- src/H5A.c | 2 +- src/H5Tvlen.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 5b474d0..45abb48 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -247,7 +247,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type, /* Compute the internal sizes */ attr->dt_size=(H5O_DTYPE[0].raw_size)(attr->ent.file,type); attr->ds_size=(H5O_SDSPACE[0].raw_size)(attr->ent.file,&(space->extent.u.simple)); - H5_ASSIGN_OVERFLOW(attr->data_size,H5S_get_simple_extent_npoints(space)*H5T_get_size(type),hssize_t,size_t); + H5_ASSIGN_OVERFLOW(attr->data_size,H5S_get_simple_extent_npoints(attr->ds)*H5T_get_size(attr->dt),hssize_t,size_t); /* Hold the symbol table entry (and file) open */ if (H5O_open(&(attr->ent)) < 0) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 0556078..fc898c5 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -222,9 +222,13 @@ herr_t H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo /* Use the user's memory allocation routine is one is defined */ + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == plist_id) + plist_id= H5P_DATASET_XFER_DEFAULT; + /* Get the allocation function & info */ if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0) @@ -343,9 +347,13 @@ herr_t H5T_vlen_str_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo /* Use the user's memory allocation routine if one is defined */ + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == plist_id) + plist_id= H5P_DATASET_XFER_DEFAULT; + /* Get the allocation function & info */ if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0) @@ -645,9 +653,13 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == plist_id) + plist_id= H5P_DATASET_XFER_DEFAULT; + /* Get the free func & information */ if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&free_func)<0) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value"); if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&free_info)<0) -- cgit v0.12