diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 1997-10-08 20:38:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 1997-10-08 20:38:12 (GMT) |
commit | 8b66e90352aab1c3e7e2013a76c443be296367d8 (patch) | |
tree | 0cf251ddd03130bde57041d7b0115d0d5dbc430e | |
parent | 25b702e2bed191bcba75dd715863e94f926e70ea (diff) | |
download | hdf5-8b66e90352aab1c3e7e2013a76c443be296367d8.zip hdf5-8b66e90352aab1c3e7e2013a76c443be296367d8.tar.gz hdf5-8b66e90352aab1c3e7e2013a76c443be296367d8.tar.bz2 |
[svn-r114] Mostly changes to add new parameter to the H5Ainit_group call. The H5D, H5P
& H5T interfaces now share datatypes & dataspaces properly also.
-rw-r--r-- | src/H5C.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 108 | ||||
-rw-r--r-- | src/H5E.c | 2 | ||||
-rw-r--r-- | src/H5F.c | 2 | ||||
-rw-r--r-- | src/H5P.c | 111 | ||||
-rw-r--r-- | src/H5Ppublic.h | 4 | ||||
-rw-r--r-- | src/H5T.c | 150 | ||||
-rw-r--r-- | src/H5Tprivate.h | 1 | ||||
-rw-r--r-- | src/H5Tpublic.h | 6 |
9 files changed, 306 insertions, 80 deletions
@@ -83,7 +83,7 @@ static herr_t H5C_init_interface(void) FUNC_ENTER (H5C_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ - if((ret_value=H5Ainit_group(H5_TEMPLATE,H5A_TEMPID_HASHSIZE,0))!=FAIL) + if((ret_value=H5Ainit_group(H5_TEMPLATE,H5A_TEMPID_HASHSIZE,0,NULL))!=FAIL) ret_value=H5_add_exit(&H5C_term_interface); FUNC_LEAVE(ret_value); @@ -49,12 +49,12 @@ static char RcsId[] = "@(#)$Revision$"; * A dataset is the following struct. */ typedef struct H5D_t { - H5F_t *file; /* File store for this object */ - H5G_entry_t *ent; /* Cached object header stuff */ - h5_datatype_t *type; /* Datatype of this dataset */ - H5P_dim_t *dim; /* Dimensionality of this dataset */ - haddr_t data_addr; /* Data storage address */ - hbool_t dirty; /* Header messages not updated yet */ + H5F_t *file; /* File store for this object */ + H5G_entry_t *ent; /* Cached object header stuff */ + hid_t tid; /* Datatype ID of this dataset */ + hid_t sid; /* Dataspace ID of this dataset */ + haddr_t data_addr; /* Data storage address */ + hbool_t dirty; /* Header messages not updated yet */ } H5D_t; /*--------------------- Locally scoped variables -----------------------------*/ @@ -81,7 +81,7 @@ static herr_t H5D_init_interface(void) FUNC_ENTER (H5D_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ - if((ret_value=H5Ainit_group(H5_DATASET,H5A_DATASETID_HASHSIZE,H5D_RESERVED_ATOMS))!=FAIL) + if((ret_value=H5Ainit_group(H5_DATASET,H5A_DATASETID_HASHSIZE,H5D_RESERVED_ATOMS,NULL))!=FAIL) ret_value=H5_add_exit(&H5D_term_interface); FUNC_LEAVE(ret_value); @@ -147,8 +147,8 @@ hid_t H5D_create(hid_t owner_id, hobjtype_t type, const char *name) /* Initialize the dataset object */ new_dset->file = file; - new_dset->type=NULL; /* No type yet */ - new_dset->dim=NULL; /* No dimensions yet */ + new_dset->tid=(-1); /* No type yet */ + new_dset->sid=(-1); /* No dimensions yet */ new_dset->data_addr = -1; /* No data yet */ new_dset->dirty = FALSE; /* There are no messages yet */ @@ -188,10 +188,12 @@ done: DESCRIPTION This function finds for a dataset by name in a directory. --------------------------------------------------------------------------*/ -hid_t H5D_find_name(hid_t grp_id, hobjtype_t type, const char *name) +hid_t H5D_find_name(hid_t grp_id, hobjtype_t obj_type, const char *name) { H5F_t *file; /* Pointer to the file-store of this object */ - H5D_t *dset = NULL; /* The dataset */ + H5D_t *dset = NULL; /* The dataset */ + h5_datatype_t *type; /* The dataset's type */ + H5P_dim_t *dim; /* The dataset's dataspace */ hid_t ret_value = SUCCEED; H5O_std_store_t store; @@ -219,19 +221,23 @@ hid_t H5D_find_name(hid_t grp_id, hobjtype_t type, const char *name) } /* Get the dataset's type (currently only atomic types) */ - if((dset->type=HDcalloc(1,sizeof(h5_datatype_t)))==NULL) + if((type=HDcalloc(1,sizeof(h5_datatype_t)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_SIM_DTYPE, 0, - dset->type)) + type)) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL); + if((dset->tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)type))==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); /* Get the dataset's dimensionality (currently only simple dataspaces) */ - if((dset->dim=HDcalloc(1,sizeof(H5P_dim_t)))==NULL) + if((dim=HDcalloc(1,sizeof(H5P_dim_t)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); - dset->dim->type=H5P_TYPE_SIMPLE; /* for now... */ - if (NULL==(dset->dim->s=H5O_read (dset->file, NO_ADDR, dset->ent, + dim->type=H5P_TYPE_SIMPLE; /* for now... */ + if (NULL==(dim->s=H5O_read (dset->file, NO_ADDR, dset->ent, H5O_SIM_DIM, 0, NULL))) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL); + if((dset->sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)dim))==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); /* Get the dataset's data offset (currently only standard storage) */ if (NULL==H5O_read (dset->file, NO_ADDR, dset->ent, H5O_STD_STORE, 0, @@ -268,13 +274,13 @@ done: herr_t H5Dset_info(oid) hid_t oid; IN: Dataset object to modify hid_t tid; IN: Datatype object to use as node element - hid_t did; IN: Dimensionality object to use as dataspace + hid_t sid; IN: Dimensionality object to use as dataspace RETURNS SUCCEED/FAIL DESCRIPTION This function sets the datatype and dataspace of a dataset. --------------------------------------------------------------------------*/ -herr_t H5Dset_info(hid_t oid, hid_t tid, hid_t did) +herr_t H5Dset_info(hid_t oid, hid_t tid, hid_t sid) { H5D_t *dataset = NULL; /* dataset object to modify */ herr_t ret_value = SUCCEED; @@ -285,19 +291,27 @@ herr_t H5Dset_info(hid_t oid, hid_t tid, hid_t did) H5ECLEAR; /* Check that we've received correctly typed parameters */ - if(H5Aatom_group(tid)!=H5_DATATYPE || H5Aatom_group(did)!=H5_DATASPACE) + if(H5Aatom_group(tid)!=H5_DATATYPE || H5Aatom_group(sid)!=H5_DATASPACE) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, FAIL); /* Get the object */ if((dataset=H5Aatom_object(oid))==NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /* Check that the datatype & dataspace haven't already been initialized */ - if(dataset->type || dataset->dim) + if(dataset->tid!=(-1) || dataset->sid!=(-1)) HGOTO_ERROR(H5E_FUNC, H5E_ALREADYINIT, FAIL); - /* Update the dataset in memory */ - dataset->type=H5Aatom_object(tid); - dataset->dim=H5Aatom_object(did); + /* Increment the reference count for the datatype */ + if(H5Ainc_ref(tid)==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + dataset->tid=tid; + + /* Increment the reference count for the datatype */ + if(H5Ainc_ref(sid)==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + dataset->sid=sid; + + /* Mark the dataset as modified (Huh? - QAK) */ dataset->dirty = TRUE; done: @@ -346,13 +360,16 @@ herr_t H5Dget_info(hid_t oid, hid_t *tid, hid_t *sid) if((dataset=H5Aatom_object(oid))==NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /* Check that the datatype & dataspace have already been initialized */ - if(dataset->type==NULL || dataset->dim==NULL) + if(dataset->tid==(-1) || dataset->sid==(-1)) HGOTO_ERROR(H5E_DATASET, H5E_UNINITIALIZED, FAIL); - if((*tid=H5Aregister_atom(H5_DATATYPE, (const VOIDP)(dataset->type)))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); - if((*sid=H5Aregister_atom(H5_DATASPACE, (const VOIDP)(dataset->dim)))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); + /* Get the Dataset's IDs */ + if(H5Ainc_ref(dataset->tid)==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + *tid=dataset->tid; + if(H5Ainc_ref(dataset->sid)==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + *sid=dataset->sid; done: if(ret_value == FAIL) @@ -408,18 +425,18 @@ herr_t H5Dread(hid_t oid, hid_t did, VOIDP buf) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /* Check that the datatype & dataspace have already been initialized */ - if(dataset->type==NULL || dataset->dim==NULL || dataset->data_addr<0) + if(dataset->tid==(-1) || dataset->sid==(-1) || dataset->data_addr<0) HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL); /* Compute the number of bytes to read */ if(did==H5P_SCALAR) /* Check if we are reading the entire dataset */ - toread=H5T_size(dataset->type,BTRUE)*H5P_nelem(dataset->dim); + toread=H5Tsize(dataset->tid,BTRUE)*H5Pnelem(dataset->sid); else HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); /* Check memory to disk datatype conversions, etc. */ /* This is totally hacked up code, but I'm in a hurry. ;-/ -QAK */ - if(dataset->type->dt.arch!=H5T_ARCH_TYPE) + if(H5Tarch(dataset->tid)!=H5T_ARCH_TYPE) { if((readbuf=HDmalloc(toread))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); @@ -434,7 +451,7 @@ herr_t H5Dread(hid_t oid, hid_t did, VOIDP buf) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL); if(free_buf!=0) - H5D_convert_buf(buf,readbuf,toread,dataset->type->dt.len); + H5D_convert_buf(buf,readbuf,toread,H5Tsize(dataset->tid,BTRUE)); done: if(ret_value == FAIL) @@ -492,12 +509,12 @@ herr_t H5Dwrite(hid_t oid, hid_t did, VOIDP buf) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /* Check that the datatype & dataspace have already been initialized */ - if(dataset->type==NULL || dataset->dim==NULL) + if(dataset->tid==(-1) || dataset->sid==(-1)) HGOTO_ERROR(H5E_FUNC, H5E_UNINITIALIZED, FAIL); /* Compute the number of bytes to write out */ if(did==H5P_SCALAR) /* Check if we are writing out the entire dataset */ - towrite=H5T_size(dataset->type,BTRUE)*H5P_nelem(dataset->dim); + towrite=H5Tsize(dataset->tid,BTRUE)*H5Pnelem(dataset->sid); else HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL); @@ -510,11 +527,11 @@ herr_t H5Dwrite(hid_t oid, hid_t did, VOIDP buf) /* Check memory to disk datatype conversions, etc. */ /* This is totally hacked up code, but I'm in a hurry. ;-/ -QAK */ - if(dataset->type->dt.arch!=H5T_ARCH_TYPE) + if(H5Tarch(dataset->tid)!=H5T_ARCH_TYPE) { if((writebuf=HDmalloc(towrite))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); - H5D_convert_buf(writebuf,buf,towrite,dataset->type->dt.len); + H5D_convert_buf(writebuf,buf,towrite,H5Tsize(dataset->tid,BTRUE)); free_buf=1; } /* end if */ else @@ -573,9 +590,11 @@ herr_t H5D_flush(hid_t oid) * Modify/create messages for this dataset. Begin with the * type information. */ - if (H5T_is_atomic (dataset->type)) { + if (H5Tis_atomic (dataset->tid)) { + h5_datatype_t *type=H5Aatom_object(dataset->tid); + if (H5O_modify (dataset->file, NO_ADDR, dataset->ent, - H5O_SIM_DTYPE, 0, dataset->type)<0) { + H5O_SIM_DTYPE, 0, type)<0) { /* Can't create/update type message */ HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL); } @@ -587,9 +606,11 @@ herr_t H5D_flush(hid_t oid) /* * Modify/create the dimensionality information. */ - if (H5P_is_simple (dataset->dim)) { + if (H5Pis_simple (dataset->sid)) { + H5P_dim_t *dim=H5Aatom_object(dataset->sid); + if (H5O_modify (dataset->file, NO_ADDR, dataset->ent, - H5O_SIM_DIM, 0, dataset->dim->s)<0) { + H5O_SIM_DIM, 0, dim->s)<0) { /* Can't create/update dimensionality message */ HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL); } @@ -604,8 +625,7 @@ herr_t H5D_flush(hid_t oid) if (dataset->data_addr>=0) { H5O_std_store_t store; /* standard storage info */ - store.len = H5T_size (dataset->type, BTRUE) * - H5P_nelem (dataset->dim); + store.len = H5Tsize (dataset->tid, BTRUE) * H5Pnelem (dataset->sid); store.off = dataset->data_addr; if (H5O_modify (dataset->file, NO_ADDR, dataset->ent, H5O_STD_STORE, 0, &store)<0) { @@ -664,6 +684,10 @@ herr_t H5D_release(hid_t oid) /* Close the dataset object */ H5G_close (dataset->file, dataset->ent); dataset->ent = NULL; + + /* Release the atoms for the datatype and dataspace */ + H5Adec_ref(dataset->tid); + H5Adec_ref(dataset->sid); /* release the memory used for the dataset */ H5MM_xfree (dataset); @@ -135,7 +135,7 @@ static herr_t H5E_init_interface(void) FUNC_ENTER (H5E_init_interface, NULL, FAIL); /* Initialize the atom group for the error stacks */ - if((ret_value=H5Ainit_group(H5_ERR,H5A_ERRSTACK_HASHSIZE,0))!=FAIL) + if((ret_value=H5Ainit_group(H5_ERR,H5A_ERRSTACK_HASHSIZE,0,NULL))!=FAIL) ret_value=H5_add_exit(&H5E_term_interface); FUNC_LEAVE(ret_value); @@ -89,7 +89,7 @@ static herr_t H5F_init_interface(void) FUNC_ENTER (H5F_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ - if((ret_value=H5Ainit_group(H5_FILE,H5A_FILEID_HASHSIZE,0))!=FAIL) + if((ret_value=H5Ainit_group(H5_FILE,H5A_FILEID_HASHSIZE,0,NULL))!=FAIL) ret_value=H5_add_exit(&H5F_term_interface); FUNC_LEAVE(ret_value); @@ -63,7 +63,7 @@ static herr_t H5P_init_interface(void) FUNC_ENTER (H5P_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ - if((ret_value=H5Ainit_group(H5_DATASPACE,H5A_DATASPACEID_HASHSIZE,H5P_RESERVED_ATOMS))!=FAIL) + if((ret_value=H5Ainit_group(H5_DATASPACE,H5A_DATASPACEID_HASHSIZE,H5P_RESERVED_ATOMS,H5P_destroy))!=FAIL) ret_value=H5_add_exit(&H5P_term_interface); FUNC_LEAVE(ret_value); @@ -198,7 +198,7 @@ hbool_t H5P_is_simple(H5P_dim_t *sdim) { hbool_t ret_value = BFAIL; - FUNC_ENTER(H5P_get_lrank, H5P_init_interface, UFAIL); + FUNC_ENTER(H5P_is_simple, H5P_init_interface, UFAIL); /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; @@ -224,6 +224,46 @@ done: /*-------------------------------------------------------------------------- NAME + H5Pis_simple + PURPOSE + Check if a dataspace is simple + USAGE + hbool_t H5Pis_simple(sid) + hid_t sid; IN: ID of dataspace object to query + RETURNS + BTRUE/BFALSE/BFAIL + DESCRIPTION + This function determines the if a dataspace is "simple". ie. if it + has orthogonal, evenly spaced dimensions. +--------------------------------------------------------------------------*/ +hbool_t H5Pis_simple(hid_t sid) +{ + H5P_dim_t *space=NULL; /* dataspace to modify */ + hbool_t ret_value = BFAIL; + + FUNC_ENTER(H5Pis_simple, H5P_init_interface, BFAIL); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + + if((space=H5Aatom_object(sid))==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + + ret_value=H5P_is_simple(space); + +done: + if(ret_value == BFAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + + FUNC_LEAVE(ret_value); +} /* end H5Pis_simple() */ + +/*-------------------------------------------------------------------------- + NAME H5Pset_space PURPOSE Determine the size of a dataspace @@ -437,30 +477,26 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_release + H5P_destroy PURPOSE - Release access to an HDF5 dimensionality object. + Private function to destroy dataspace objects. USAGE - herr_t H5P_release(oid) - hid_t oid; IN: Object to release access to + void H5P_destroy(dataspace) + void *dataspace; IN: Pointer to dataspace object to destroy RETURNS - SUCCEED/FAIL + none DESCRIPTION - This function releases a dimensionality from active use by a user. + This function releases whatever memory is used by a dataspace object. + It should only be called from the atom manager when the reference count + for a dataspace drops to zero. --------------------------------------------------------------------------*/ -herr_t H5P_release(hid_t oid) +void H5P_destroy(void *dataspace) { - H5P_dim_t *dim; /* dimensionality object to release */ - herr_t ret_value = SUCCEED; + H5P_dim_t *dim=(H5P_dim_t *)dataspace; /* dimensionality object to release */ - FUNC_ENTER(H5P_release, H5P_init_interface, FAIL); + /* Don't call standard init/leave code, this is a private void function */ + /* FUNC_ENTER(H5T_destroy, H5T_init_interface, FAIL); */ - /* Clear errors and check args and all the boring stuff. */ - H5ECLEAR; - - /* Chuck the object! :-) */ - if((dim=H5Aremove_atom(oid))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); if(dim->type==H5P_TYPE_SIMPLE) { if(dim->s!=NULL) @@ -476,6 +512,45 @@ herr_t H5P_release(hid_t oid) } /* end if */ HDfree(dim); +#ifdef LATER +done: + if(ret_value == FAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + FUNC_LEAVE(ret_value); +#endif /* LATER */ + +} /* H5P_destroy */ + +/*-------------------------------------------------------------------------- + NAME + H5P_release + PURPOSE + Release access to an HDF5 dimensionality object. + USAGE + herr_t H5P_release(oid) + hid_t oid; IN: Object to release access to + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function releases a dimensionality from active use by a user. +--------------------------------------------------------------------------*/ +herr_t H5P_release(hid_t oid) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER(H5P_release, H5P_init_interface, FAIL); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + + /* Chuck the object! :-) */ + if(H5Adec_ref(oid)==FAIL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + done: if(ret_value == FAIL) { /* Error condition cleanup */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 0fd9c9a..4dac9df 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -43,8 +43,12 @@ extern "C" { /* Functions in H5P.c */ uintn H5Pnelem(hid_t dim_id); +hbool_t H5Pis_simple(hid_t dim_id); herr_t H5Pset_space(hid_t sid, uint32 rank, uint32 *dims); + +/* Private functions which need to be globally visible */ void H5P_term_interface (void); +void H5P_destroy(void *dataspace); #ifdef __cplusplus } @@ -74,7 +74,7 @@ static herr_t H5T_init_interface(void) FUNC_ENTER (H5T_init_interface, NULL, FAIL); /* Initialize the atom group for the file IDs */ - if((ret_value=H5Ainit_group(H5_DATATYPE,H5A_DATATYPEID_HASHSIZE,H5T_RESERVED_ATOMS))!=FAIL) + if((ret_value=H5Ainit_group(H5_DATATYPE,H5A_DATATYPEID_HASHSIZE,H5T_RESERVED_ATOMS,H5T_destroy))!=FAIL) ret_value=H5_add_exit(&H5T_term_interface); FUNC_LEAVE(ret_value); @@ -528,7 +528,7 @@ herr_t H5Tadd_field(hid_t tid, const char *name, hid_t base, uint8 len, uint8 ar else { new_field->dt.base=H5Mcopy(base); /* Make a copy of the datatype for the field */ - new_field->dt.len=H5Tsize(base,len,arch,BTRUE); + new_field->dt.len=H5Tsize(base,BTRUE); new_field->dt.arch=arch; } /* end else */ @@ -549,7 +549,7 @@ done: PURPOSE Determine the size of a datatype (internal) USAGE - uintn H5Tsize(dt, mem_flag) + uintn H5T_size(dt, mem_flag) h5_datatype_t *dt; IN: Pointer to Datatype object to query hbool_t mem_flag; IN: Whether the memory or disk size is desired RETURNS @@ -584,8 +584,7 @@ uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag) /* Grab the number of fields */ for(i=0; i<=dt->ci->n; i++) - ret_value+=H5Tsize(dt->ci->flist[i].dt.base, dt->ci->flist[i].dt.len, - dt->ci->flist[i].dt.arch,mem_flag)*H5Pnelem(dt->ci->flist[i].dim_id); + ret_value+=H5Tsize(dt->ci->flist[i].dt.base,mem_flag)*H5Pnelem(dt->ci->flist[i].dim_id); } /* end if */ else { /* Simple, user-defined datatypes */ @@ -636,16 +635,20 @@ done: Determine the size of a datatype USAGE uintn H5Tsize(tid, mem_flag) - hid_t tid; IN: Datatype object to query + hid_t tid; IN: Datatype object to query hbool_t mem_flag; IN: Whether the memory or disk size is desired RETURNS The size of the datatype on success or UFAIL on failure. DESCRIPTION - Ths function returns the size of the datatype in bytes as it is stored + This function returns the size of the datatype in bytes as it is stored on disk or in memory, depending on the mem_flag. Setting the mem_flag to BTRUE returns the size in memory, BFALSE returns the size on disk. + NOTE: + This function does not compute the number of bytes for a predefined + library type (ie. H5T_CHAR, H5T_INT) which has not been "named" by the + user as field or new type. --------------------------------------------------------------------------*/ -uintn H5Tsize(hid_t tid, uint8 len, uint8 arch, hbool_t mem_flag) +uintn H5Tsize(hid_t tid, hbool_t mem_flag) { uintn ret_value = UFAIL; @@ -656,6 +659,7 @@ uintn H5Tsize(hid_t tid, uint8 len, uint8 arch, hbool_t mem_flag) if((H5Ais_reserved(tid)==BTRUE) && tid!=H5T_COMPOUND) /* Check if this is a "simple" datatype */ { +#ifdef LATER switch(tid) { case H5T_CHAR: @@ -683,6 +687,8 @@ uintn H5Tsize(hid_t tid, uint8 len, uint8 arch, hbool_t mem_flag) default: HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL); } /* end switch */ +#endif /* LATER */ + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, UFAIL); } /* end if */ else { @@ -708,6 +714,83 @@ done: /*-------------------------------------------------------------------------- NAME + H5T_arch + PURPOSE + Determine the architecture of a datatype (internal) + USAGE + uintn H5T_arch(dt) + h5_datatype_t *dt; IN: Pointer to Datatype object to query + RETURNS + The architure type of the datatype on success or FAIL on failure. + DESCRIPTION + Ths function returns the architure type of the datatype. +--------------------------------------------------------------------------*/ +intn H5T_arch(h5_datatype_t *dt) +{ + intn ret_value = FAIL; + + FUNC_ENTER(H5T_arch, H5T_init_interface, FAIL); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + + assert(dt); + + ret_value=dt->dt.arch; + +done: + if(ret_value == FAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + + FUNC_LEAVE(ret_value); +} /* end H5T_arch() */ + +/*-------------------------------------------------------------------------- + NAME + H5Tarch + PURPOSE + Determine the architecture of a datatype + USAGE + intn H5Tarch(tid) + hid_t tid; IN: Datatype object to query + RETURNS + The architecture of the datatype on success or FAIL on failure. + DESCRIPTION + Ths function returns the architecture of the datatype. +--------------------------------------------------------------------------*/ +intn H5Tarch(hid_t tid) +{ + h5_datatype_t *dt; /* datatype pointer */ + intn ret_value = FAIL; + + FUNC_ENTER(H5Tarch, H5T_init_interface, FAIL); + + /* Clear errors and check args and all the boring stuff. */ + H5ECLEAR; + + /* Go get the object */ + if((dt=H5Aatom_object(tid))==NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); + + ret_value=H5T_arch(dt); + +done: + if(ret_value == FAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + + FUNC_LEAVE(ret_value); +} /* end H5Tarch() */ + +/*-------------------------------------------------------------------------- + NAME H5Tget_fields PURPOSE Determine the size of a datatype @@ -748,6 +831,48 @@ done: /*-------------------------------------------------------------------------- NAME + H5T_destroy + PURPOSE + Private function to destroy datatype objects. + USAGE + void H5T_destroy(datatype) + void *datatype; IN: Pointer to datatype object to destroy + RETURNS + none + DESCRIPTION + This function releases whatever memory is used by a datatype object. + It should only be called from the atom manager when the reference count + for a datatype drops to zero. +--------------------------------------------------------------------------*/ +void H5T_destroy(void *datatype) +{ + h5_datatype_t *dt=(h5_datatype_t *)datatype; /* data-type object to destroy */ + + /* Don't call standard init/leave code, this is a private void function */ + /* FUNC_ENTER(H5T_destroy, H5T_init_interface, FAIL); */ + + if(dt->name!=NULL) + HDfree(dt->name); + if(dt->ci!=NULL) + { + } /* end if */ + HDfree(dt); + +#ifdef LATER +done: + if(ret_value == FAIL) + { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + FUNC_LEAVE(ret_value); +#endif /* LATER */ + +} /* H5T_destroy */ + +/*-------------------------------------------------------------------------- + NAME H5T_release PURPOSE Release access to an HDF5 datatype object. @@ -761,7 +886,6 @@ done: --------------------------------------------------------------------------*/ herr_t H5T_release(hid_t oid) { - h5_datatype_t *dt; /* new data-type object to create */ herr_t ret_value = SUCCEED; FUNC_ENTER(H5T_release, H5T_init_interface, FAIL); @@ -770,14 +894,8 @@ herr_t H5T_release(hid_t oid) H5ECLEAR; /* Chuck the object! :-) */ - if((dt=H5Aremove_atom(oid))==NULL) + if(H5Adec_ref(oid)==FAIL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); - if(dt->name!=NULL) - HDfree(dt->name); - if(dt->ci!=NULL) - { - } /* end if */ - HDfree(dt); done: if(ret_value == FAIL) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 1578d47..0a3f2eb 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -54,6 +54,7 @@ typedef struct { hid_t H5T_create(hid_t owner_id, hobjtype_t type, const char *name); hbool_t H5T_is_atomic(h5_datatype_t *type); uintn H5T_size(h5_datatype_t *dt, hbool_t mem_flag); +intn H5T_arch(h5_datatype_t *dt); herr_t H5T_release(hid_t oid); #endif diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index d74404b..10f86b5 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -70,11 +70,15 @@ hbool_t H5Tis_field_atomic(hid_t tid,uintn fidx); hbool_t H5Tis_atomic(hid_t tid); herr_t H5Tset_type(hid_t tid,hid_t base,uint8 len,uint8 arch); herr_t H5Tget_type(hid_t tid,hid_t *base,uint8 *len,uint8 *arch); -uintn H5Tsize(hid_t tid, uint8 len, uint8 arch, hbool_t mem_flag); +uintn H5Tsize(hid_t tid, hbool_t mem_flag); +intn H5Tarch(hid_t tid); herr_t H5Tadd_field (hid_t tid, const char *name, hid_t base, uint8 len, uint8 arch, hid_t space); herr_t H5Tget_fields(hid_t tid, hid_t *field_list); + +/* Private functions which need to be globally visible */ void H5T_term_interface (void); +void H5T_destroy(void *datatype); #ifdef __cplusplus } |