summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST23
-rw-r--r--src/H5D.c103
-rw-r--r--src/H5FDmulti.c2
-rw-r--r--src/H5Fpkg.h2
-rw-r--r--src/H5G.c48
-rw-r--r--src/H5O.c604
-rw-r--r--src/H5Oattr.c10
-rw-r--r--src/H5Obogus.c6
-rw-r--r--src/H5Ocache.c210
-rw-r--r--src/H5Ocont.c5
-rw-r--r--src/H5Odtype.c11
-rw-r--r--src/H5Oefl.c5
-rw-r--r--src/H5Ofill.c12
-rw-r--r--src/H5Olayout.c5
-rw-r--r--src/H5Omtime.c12
-rw-r--r--src/H5Oname.c6
-rw-r--r--src/H5Opkg.h29
-rw-r--r--src/H5Opline.c5
-rw-r--r--src/H5Oprivate.h7
-rw-r--r--src/H5Osdspace.c5
-rw-r--r--src/H5Oshared.c132
-rw-r--r--src/H5Ostab.c5
-rw-r--r--src/H5T.c212
-rw-r--r--src/H5Tarray.c5
-rw-r--r--src/H5Tcommit.c212
-rw-r--r--src/H5Tconv.c1
-rw-r--r--src/H5Tenum.c5
-rw-r--r--src/H5Tpkg.h5
-rw-r--r--src/H5Tprivate.h8
-rw-r--r--src/H5Tvlen.c5
-rw-r--r--src/Makefile.in2
-rw-r--r--test/group_new.h5bin0 -> 2280 bytes
-rw-r--r--test/links.c6
-rw-r--r--test/stab.c72
34 files changed, 651 insertions, 1129 deletions
diff --git a/MANIFEST b/MANIFEST
index 2e23eee..9c9d9a3 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1224,6 +1224,7 @@
./src/H5O.c
./src/H5Oattr.c
./src/H5Obogus.c
+./src/H5Ocache.c
./src/H5Ocont.c
./src/H5Odtype.c
./src/H5Oefl.c
@@ -1337,8 +1338,19 @@
./test/gass_append.c
./test/gass_read.c
./test/gass_write.c
+./test/gen_deflate.c _DO_NOT_DISTRIBUTE_
+./test/gen_old_array.c _DO_NOT_DISTRIBUTE_
+./test/gen_old_group.c _DO_NOT_DISTRIBUTE_
+./test/gen_old_layout.c _DO_NOT_DISTRIBUTE_
+./test/gen_old_mtime.c _DO_NOT_DISTRIBUTE_
+./test/gen_new_array.c _DO_NOT_DISTRIBUTE_
+./test/gen_new_fill.c _DO_NOT_DISTRIBUTE_
+./test/gen_new_mtime.c _DO_NOT_DISTRIBUTE_
+./test/gen_new_super.c _DO_NOT_DISTRIBUTE_
+./test/gen_nullspace.c _DO_NOT_DISTRIBUTE_
./test/getname.c
./test/gheap.c
+./test/group_new.h5
./test/h5test.c
./test/h5test.h
./test/hyperslab.c
@@ -1351,17 +1363,8 @@
./test/ntypes.c
./test/ohdr.c
./test/reserved.c
-./test/space_overflow.c _DO_NOT_DISTRIBUTE_
-./test/gen_deflate.c _DO_NOT_DISTRIBUTE_
-./test/gen_old_array.c _DO_NOT_DISTRIBUTE_
-./test/gen_new_array.c _DO_NOT_DISTRIBUTE_
-./test/gen_new_fill.c _DO_NOT_DISTRIBUTE_
-./test/gen_old_layout.c _DO_NOT_DISTRIBUTE_
-./test/gen_old_mtime.c _DO_NOT_DISTRIBUTE_
-./test/gen_new_mtime.c _DO_NOT_DISTRIBUTE_
-./test/gen_new_super.c _DO_NOT_DISTRIBUTE_
-./test/gen_nullspace.c _DO_NOT_DISTRIBUTE_
./test/set_extent.c
+./test/space_overflow.c _DO_NOT_DISTRIBUTE_
./test/srb_append.c
./test/srb_read.c
./test/srb_write.c
diff --git a/src/H5D.c b/src/H5D.c
index dd3b497..d398b21 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -64,7 +64,7 @@ static herr_t H5D_init_storage(H5D_t *dataset, hbool_t full_overwrite, hid_t dxp
static H5D_shared_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type);
static H5D_t * H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id,
const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id);
-static H5D_t * H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id);
+static herr_t H5D_open_oid(H5D_t *dset, hid_t dxpl_id);
static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id);
static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id);
static haddr_t H5D_get_offset(const H5D_t *dset);
@@ -2316,13 +2316,21 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
/* check args */
assert (ent);
+ /* Allocate the dataset structure */
+ if(NULL == (dataset = H5FL_CALLOC(H5D_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for dataset")
+
+ /* Shallow copy (take ownership) of the group entry object */
+ if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0)
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry")
+
/* Check if dataset was already open */
if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) {
/* Clear any errors from H5FO_opened() */
H5E_clear();
/* Open the dataset object */
- if ((dataset=H5D_open_oid(ent, dxpl_id)) ==NULL)
+ if (H5D_open_oid(dataset, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found")
/* Add the dataset to the list of opened objects in the file */
@@ -2333,18 +2341,14 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
if(H5FO_top_incr(dataset->ent.file, dataset->ent.header) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, NULL, "can't increment object count")
+ /* We're the first dataset to use the the shared info */
dataset->shared->fo_count = 1;
} /* end if */
else {
- if(NULL == (dataset = H5FL_CALLOC(H5D_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for dataset")
-
- /* Shallow copy (take ownership) of the group entry object */
- if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry")
-
+ /* Point to shared info */
dataset->shared=shared_fo;
+ /* Increment # of datasets using shared information */
shared_fo->fo_count++;
/* Check if the object has been opened through the top file yet */
@@ -2388,51 +2392,42 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5D_t *
-H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
+static herr_t
+H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
{
- H5D_t *dataset = NULL; /*new dataset struct */
H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_CRT_FILL_TIME_DEF, TRUE};
unsigned alloc_time_state; /* Allocation time state */
H5O_fill_t *fill_prop; /* Pointer to dataset's fill value area */
H5O_pline_t pline; /* I/O pipeline information */
H5P_genplist_t *plist; /* Property list */
- H5D_t *ret_value = NULL; /*return value */
+ herr_t ret_value = SUCCEED; /*return value */
- FUNC_ENTER_NOAPI(H5D_open_oid, NULL)
+ FUNC_ENTER_NOAPI(H5D_open_oid, FAIL)
/* check args */
- assert (ent);
-
- /* Allocate the dataset structure */
- if(NULL==(dataset=H5FL_CALLOC(H5D_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ assert (dataset);
/* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */
if(NULL==(dataset->shared = H5D_new(H5P_DATASET_CREATE_DEFAULT,FALSE,FALSE)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
-
- /* Shallow copy (take ownership) of the group entry object */
- if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry")
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Find the dataset object */
if (H5O_open(&(dataset->ent)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open")
/* Get the type and space */
if (NULL==(dataset->shared->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load type info from dataset header")
/* Get a datatype ID for the dataset's datatype */
if((dataset->shared->type_id = H5I_register(H5I_DATATYPE, dataset->shared->type))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, NULL, "unable to register type")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type")
if (NULL==(dataset->shared->space=H5S_read(&(dataset->ent),dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load space info from dataset header")
/* Get dataset creation property list object */
if (NULL == (plist = H5I_object(dataset->shared->dcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list")
/* Get the optional filters message */
if(NULL == H5O_read(&(dataset->ent), H5O_PLINE_ID, 0, &pline, dxpl_id)) {
@@ -2440,7 +2435,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
HDmemset(&pline, 0, sizeof(pline));
}
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set pipeline")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline")
/*
* Get the raw data layout info. It's actually stored in two locations:
@@ -2449,9 +2444,9 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
* them.
*/
if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT_ID, 0, &(dataset->shared->layout), dxpl_id))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message")
if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->shared->layout.type) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set layout")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout")
switch (dataset->shared->layout.type) {
case H5D_CONTIGUOUS:
/* Compute the size of the contiguous storage for versions of the
@@ -2486,13 +2481,13 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
chunk_ndims = dataset->shared->layout.u.chunk.ndims - 1;
if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk dimensions")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk dimensions")
if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, dataset->shared->layout.u.chunk.dim) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set chunk size")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk size")
/* Initialize the chunk cache for the dataset */
if(H5D_istore_init(dataset->ent.file,dataset)<0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "can't initialize chunk cache")
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache")
}
/* Set the I/O functions for this layout type */
@@ -2507,7 +2502,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
break;
default:
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet")
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet")
} /* end switch */ /*lint !e788 All appropriate cases are covered */
/* Point at dataset's copy, to cache it for later */
@@ -2515,9 +2510,9 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
/* Retrieve & release the previous fill-value settings */
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't get fill value")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't get fill value")
if(H5O_reset(H5O_FILL_ID, fill_prop)<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "can't release fill info")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info")
/* Get the new fill value message */
if(NULL == H5O_read(&(dataset->ent), H5O_FILL_NEW_ID, 0, &fill, dxpl_id)) {
@@ -2539,7 +2534,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
break;
default:
- HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet")
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet")
} /* end switch */ /*lint !e788 All appropriate cases are covered */
/* Set the default fill time */
@@ -2547,7 +2542,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
} /* end if */
if(fill.fill_defined) {
if(NULL==H5O_copy(H5O_FILL_ID, &fill, fill_prop))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy fill value")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't copy fill value")
} else {
/* For compatibility with v1.4. Retrieve the old fill value message.
* If size is 0, make it -1 for undefined. */
@@ -2568,15 +2563,15 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
/* Set revised fill value properties */
if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set fill value")
dataset->shared->alloc_time=fill.alloc_time; /* Cache this for later */
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &fill.alloc_time) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set allocation time")
if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time state")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set allocation time state")
dataset->shared->fill_time=fill.fill_time; /* Cache this for later */
if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill.fill_time) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill time")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set fill time")
/* Get the external file list message, which might not exist. Space is
* also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */
@@ -2585,7 +2580,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
HDmemset(&dataset->shared->efl,0,sizeof(H5O_efl_t));
if(NULL != H5O_read(&(dataset->ent), H5O_EFL_ID, 0, &dataset->shared->efl, dxpl_id)) {
if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->shared->efl) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set external file list")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set external file list")
/* Override the I/O functions for this layout type */
dataset->shared->io_ops.readvv=H5D_efl_readvv;
@@ -2603,36 +2598,32 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
|| (dataset->shared->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->shared->layout.u.chunk.addr)))
&& IS_H5FD_MPI(dataset->ent.file)) {
if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset,H5D_ALLOC_OPEN, TRUE, FALSE)<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file storage")
}
/* Get the dataset's DCPL cache info */
if (H5D_get_dcpl_cache(dataset->shared->dcpl_id,&dataset->shared->dcpl_cache)<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't fill DCPL cache")
-
- /* Success */
- ret_value = dataset;
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill DCPL cache")
done:
/* Release fill value information */
if (H5O_reset(H5O_FILL_ID, &fill) <0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to release fill-value info")
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release fill-value info")
- if (ret_value==NULL && dataset) {
+ if (ret_value < 0 && dataset) {
if (H5F_addr_defined(dataset->ent.header)) {
if(H5O_close(&(dataset->ent))<0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header")
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
} /* end if */
if (dataset->shared->space) {
if(H5S_close(dataset->shared->space)<0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
} /* end if */
if (dataset->shared->type) {
if(H5I_dec_ref(dataset->shared->type_id)<0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
dataset->ent.file = NULL;
- H5FL_FREE(H5D_t,dataset);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_open_oid() */
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index b6c94d9..b2adf9e 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -778,8 +778,8 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/,
assert(7==H5FD_MEM_NTYPES);
for (m=H5FD_MEM_SUPER; m<H5FD_MEM_NTYPES; m=(H5FD_mem_t)(m+1))
buf[m-1] = (unsigned char)file->fa.memb_map[m];
+ buf[6] = 0;
buf[7] = 0;
- buf[8] = 0;
/*
* Copy the starting addresses and EOA values into the buffer in order of
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 76fec31..4a4a07e 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -58,7 +58,7 @@
#endif
/* Maximum size of super-block buffer */
-#define H5F_SUPERBLOCK_SIZE 256
+#define H5F_SUPERBLOCK_SIZE 128
#define H5F_DRVINFOBLOCK_SIZE 1024
/* Define the HDF5 file signature */
diff --git a/src/H5G.c b/src/H5G.c
index a747253..247d295 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -180,7 +180,7 @@ static herr_t H5G_traverse_slink(H5G_entry_t *grp_ent/*in,out*/,
static H5G_t *H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id);
static htri_t H5G_isa(H5G_entry_t *ent, hid_t dxpl_id);
static htri_t H5G_link_isa(H5G_entry_t *ent, hid_t dxpl_id);
-static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id);
+static herr_t H5G_open_oid(H5G_t *grp, hid_t dxpl_id);
static H5G_t *H5G_rootof(H5F_t *f);
static herr_t H5G_link(H5G_entry_t *cur_loc, const char *cur_name,
H5G_entry_t *new_loc, const char *new_name, H5G_link_t type,
@@ -1945,6 +1945,14 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
/* Check args */
assert(ent);
+ /* Allocate the group structure */
+ if(NULL == (grp = H5FL_CALLOC(H5G_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group")
+
+ /* Shallow copy (take ownership) of the group entry object */
+ if(H5G_ent_copy(&(grp->ent), ent, H5G_COPY_SHALLOW)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy group entry")
+
/* Check if group was already open */
if((shared_fo=H5FO_opened(ent->file, ent->header))==NULL) {
@@ -1952,12 +1960,11 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
H5E_clear();
/* Open the group object */
- if ((grp=H5G_open_oid(ent, dxpl_id)) ==NULL)
+ if (H5G_open_oid(grp, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found");
/* Add group to list of open objects in file */
- if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0)
- {
+ if(H5FO_insert(grp->ent.file, grp->ent.header, grp->shared)<0) {
H5FL_FREE(H5G_shared_t, grp->shared);
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects")
}
@@ -1970,13 +1977,6 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
grp->shared->fo_count = 1;
}
else {
- if(NULL == (grp = H5FL_CALLOC(H5G_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for group")
-
- /* Shallow copy (take ownership) of the group entry object */
- if(H5G_ent_copy(&(grp->ent), ent, H5G_COPY_SHALLOW)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, NULL, "can't copy group entry")
-
/* Point to shared group info */
grp->shared = shared_fo;
@@ -2026,47 +2026,37 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5G_t *
-H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id)
+static herr_t
+H5G_open_oid(H5G_t *grp, hid_t dxpl_id)
{
- H5G_t *grp = NULL;
- H5G_t *ret_value = NULL;
hbool_t ent_opened = FALSE;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5G_open_oid);
/* Check args */
- assert(ent);
+ assert(grp);
/* Open the object, making sure it's a group */
- if (NULL==(grp = H5FL_CALLOC(H5G_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
if (NULL==(grp->shared = H5FL_CALLOC(H5G_shared_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
-
- /* Copy over (take ownership) of the group entry object */
- H5G_ent_copy(&(grp->ent),ent,H5G_COPY_SHALLOW);
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Grab the object header */
if (H5O_open(&(grp->ent)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
ent_opened = TRUE;
/* Check if this object has the right message(s) to be treated as a group */
if(H5O_exists(&(grp->ent), H5O_STAB_ID, 0, dxpl_id) <= 0)
- HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group")
-
- /* Set return value */
- ret_value = grp;
+ HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "not a group")
done:
- if(!ret_value) {
+ if(ret_value < 0) {
if(grp) {
if(ent_opened)
H5O_close(&(grp->ent));
if(grp->shared)
H5FL_FREE(H5G_shared_t, grp->shared);
- H5FL_FREE(H5G_t,grp);
} /* end if */
} /* end if */
diff --git a/src/H5O.c b/src/H5O.c
index f654d57..30538b2 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -65,10 +65,9 @@ typedef herr_t (*H5O_operator_int_t)(H5O_mesg_t *mesg/*in,out*/, unsigned idx,
unsigned * oh_flags_ptr, void *operator_data/*in,out*/);
/* PRIVATE PROTOTYPES */
-static herr_t H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint,
+static herr_t H5O_new(H5F_t *f, hid_t dxpl_id, size_t size_hint,
H5G_entry_t *ent/*out*/, haddr_t header);
static herr_t H5O_reset_real(const H5O_class_t *type, void *native);
-static herr_t H5O_free_mesg(H5O_mesg_t *mesg);
static void * H5O_copy_real(const H5O_class_t *type, const void *mesg,
void *dst);
static int H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type,
@@ -103,26 +102,8 @@ static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_class_t *type,
static herr_t H5O_iterate_real(const H5G_entry_t *ent, const H5O_class_t *type,
H5AC_protect_t prot, hbool_t internal, void *op, void *op_data, hid_t dxpl_id);
-/* Metadata cache callbacks */
-static H5O_t *H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_udata1,
- void *_udata2);
-static herr_t H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh);
-static herr_t H5O_dest(H5F_t *f, H5O_t *oh);
-static herr_t H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy);
-static herr_t H5O_compute_size(const H5F_t *f, const H5O_t *oh, size_t *size_ptr);
-
-/* H5O inherits cache-like properties from H5AC */
-static const H5AC_class_t H5AC_OHDR[1] = {{
- H5AC_OHDR_ID,
- (H5AC_load_func_t)H5O_load,
- (H5AC_flush_func_t)H5O_flush,
- (H5AC_dest_func_t)H5O_dest,
- (H5AC_clear_func_t)H5O_clear,
- (H5AC_size_func_t)H5O_compute_size,
-}};
-
/* ID to type mapping */
-static const H5O_class_t *const message_type_g[] = {
+const H5O_class_t *const message_type_g[] = {
H5O_NULL, /*0x0000 Null */
H5O_SDSPACE, /*0x0001 Simple Dimensionality */
NULL, /*0x0002 Data space (fiber bundle?) */
@@ -160,16 +141,16 @@ static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *,
void *);
/* Declare a free list to manage the H5O_t struct */
-H5FL_DEFINE_STATIC(H5O_t);
+H5FL_DEFINE(H5O_t);
/* Declare a free list to manage the H5O_mesg_t sequence information */
-H5FL_SEQ_DEFINE_STATIC(H5O_mesg_t);
+H5FL_SEQ_DEFINE(H5O_mesg_t);
/* Declare a free list to manage the H5O_chunk_t sequence information */
-H5FL_SEQ_DEFINE_STATIC(H5O_chunk_t);
+H5FL_SEQ_DEFINE(H5O_chunk_t);
/* Declare a free list to manage the chunk image information */
-H5FL_BLK_DEFINE_STATIC(chunk_image);
+H5FL_BLK_DEFINE(chunk_image);
/* Declare external the free list for time_t's */
H5FL_EXTERN(time_t);
@@ -179,6 +160,33 @@ H5FL_EXTERN(H5O_cont_t);
/*-------------------------------------------------------------------------
+ * Function: H5O_init
+ *
+ * Purpose: Initialize the interface from some other package.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, September 28, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_init(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_init, FAIL)
+ /* FUNC_ENTER() does all the work */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_init() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_init_interface
*
* Purpose: Initialize the H5O interface.
@@ -255,7 +263,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/)
"file allocation failed for object header header");
/* initialize the object header */
- if (H5O_init(f, dxpl_id, size_hint, ent, header) != SUCCEED)
+ if (H5O_new(f, dxpl_id, size_hint, ent, header) != SUCCEED)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to initialize object header");
done:
@@ -264,7 +272,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_init
+ * Function: H5O_new
*
* Purpose: Initialize a new object header, sets the link count to 0,
* and caches the header. The object header is opened for
@@ -284,13 +292,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_init(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, haddr_t header)
+H5O_new(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, haddr_t header)
{
H5O_t *oh = NULL;
haddr_t tmp_addr;
herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_init);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_new);
/* check args */
assert(f);
@@ -457,518 +465,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5O_load
- *
- * Purpose: Loads an object header from disk.
- *
- * Return: Success: Pointer to the new object header.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
- *
- * Modifications:
- *
- * Robb Matzke, 1997-08-30
- * Plugged memory leaks that occur during error handling.
- *
- * Robb Matzke, 1998-01-07
- * Able to distinguish between constant and variable messages.
- *
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * Quincey Koziol, 2002-7-180
- * Added dxpl parameter to allow more control over I/O from metadata
- * cache.
- *-------------------------------------------------------------------------
- */
-static H5O_t *
-H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
- void UNUSED * _udata2)
-{
- H5O_t *oh = NULL;
- H5O_t *ret_value;
- uint8_t buf[16], *p;
- size_t mesg_size;
- size_t hdr_size;
- unsigned id;
- int mesgno;
- unsigned curmesg = 0, nmesgs;
- unsigned chunkno;
- haddr_t chunk_addr;
- size_t chunk_size;
- uint8_t flags;
-
- FUNC_ENTER_NOAPI(H5O_load, NULL);
-
- /* check args */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(!_udata1);
- assert(!_udata2);
-
- /* allocate ohdr and init chunk list */
- if (NULL==(oh = H5FL_CALLOC(H5O_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
-
- /* read fixed-lenth part of object header */
- hdr_size = H5O_SIZEOF_HDR(f);
- assert(hdr_size<=sizeof(buf));
- if (H5F_block_read(f, H5FD_MEM_OHDR, addr, hdr_size, dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header");
- p = buf;
-
- /* decode version */
- oh->version = *p++;
- if (H5O_VERSION != oh->version)
- HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header version number");
-
- /* reserved */
- p++;
-
- /* decode number of messages */
- UINT16DECODE(p, nmesgs);
-
- /* decode link count */
- UINT32DECODE(p, oh->nlink);
-
- /* decode first chunk info */
- chunk_addr = addr + (hsize_t)hdr_size;
- UINT32DECODE(p, chunk_size);
-
- /* build the message array */
- oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs);
- if (NULL==(oh->mesg=H5FL_SEQ_CALLOC(H5O_mesg_t,(size_t)oh->alloc_nmesgs)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
-
- /* read each chunk from disk */
- while (H5F_addr_defined(chunk_addr)) {
- /* increase chunk array size */
- if (oh->nchunks >= oh->alloc_nchunks) {
- unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
- H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, (size_t)na);
-
- if (!x)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- oh->alloc_nchunks = na;
- oh->chunk = x;
- }
-
- /* read the chunk raw data */
- chunkno = oh->nchunks++;
- oh->chunk[chunkno].dirty = FALSE;
- oh->chunk[chunkno].addr = chunk_addr;
- oh->chunk[chunkno].size = chunk_size;
- if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image,chunk_size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id,
- oh->chunk[chunkno].image) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data");
-
- /* load messages from this chunk */
- for (p = oh->chunk[chunkno].image; p < oh->chunk[chunkno].image + chunk_size; p += mesg_size) {
- UINT16DECODE(p, id);
- UINT16DECODE(p, mesg_size);
- assert (mesg_size==H5O_ALIGN (mesg_size));
- flags = *p++;
- p += 3; /*reserved*/
-
- /* Try to detect invalidly formatted object header messages */
- if (p + mesg_size > oh->chunk[chunkno].image + chunk_size)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "corrupt object header");
-
- /* Skip header messages we don't know about */
- /* (Usually from future versions of the library */
- if (id >= NELMTS(message_type_g) || NULL == message_type_g[id])
- continue;
-
- if (H5O_NULL_ID == id && oh->nmesgs > 0 &&
- H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id &&
- oh->mesg[oh->nmesgs - 1].chunkno == chunkno) {
- /* combine adjacent null messages */
- mesgno = oh->nmesgs - 1;
- oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR(f) + mesg_size;
- } else {
- /* new message */
- if (oh->nmesgs >= nmesgs)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header");
- mesgno = oh->nmesgs++;
- oh->mesg[mesgno].type = message_type_g[id];
- oh->mesg[mesgno].dirty = FALSE;
- oh->mesg[mesgno].flags = flags;
- oh->mesg[mesgno].native = NULL;
- oh->mesg[mesgno].raw = p;
- oh->mesg[mesgno].raw_size = mesg_size;
- oh->mesg[mesgno].chunkno = chunkno;
- }
- }
-
- assert(p == oh->chunk[chunkno].image + chunk_size);
-
- /* decode next object header continuation message */
- for (chunk_addr = HADDR_UNDEF; !H5F_addr_defined(chunk_addr) && curmesg < oh->nmesgs; ++curmesg) {
- if (H5O_CONT_ID == oh->mesg[curmesg].type->id) {
- H5O_cont_t *cont;
-
- cont = (H5O_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw, NULL);
- oh->mesg[curmesg].native = cont;
- chunk_addr = cont->addr;
- chunk_size = cont->size;
- cont->chunkno = oh->nchunks; /*the next chunk to allocate */
- }
- }
- }
-
- /* Set return value */
- ret_value = oh;
-
-done:
- if (!ret_value && oh) {
- if(H5O_dest(f,oh)<0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data");
- }
-
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_flush
- *
- * Purpose: Flushes (and destroys) an object header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
- *
- * Modifications:
- *
- * Robb Matzke, 1998-01-07
- * Handles constant vs non-constant messages.
- *
- * rky, 1998-08-28
- * Only p0 writes metadata to disk.
- *
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * Quincey Koziol, 2002-7-180
- * Added dxpl parameter to allow more control over I/O from metadata
- * cache.
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
-{
- uint8_t buf[16], *p;
- int id;
- unsigned u;
- H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
- H5O_cont_t *cont = NULL;
- herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
- unsigned combine=0; /* Whether to combine the object header prefix & the first chunk */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5O_flush, FAIL);
-
- /* check args */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(oh);
-
- /* flush */
- if (oh->cache_info.is_dirty) {
- p = buf;
-
- /* encode version */
- *p++ = oh->version;
-
- /* reserved */
- *p++ = 0;
-
- /* encode number of messages */
- UINT16ENCODE(p, oh->nmesgs);
-
- /* encode link count */
- UINT32ENCODE(p, oh->nlink);
-
- /* encode body size */
- UINT32ENCODE(p, oh->chunk[0].size);
-
- /* zero to alignment */
- HDmemset (p, 0, (size_t)(H5O_SIZEOF_HDR(f)-12));
-
- /* write the object header prefix */
-
- /* Check if we can combine the object header prefix & the first chunk into one I/O operation */
- if(oh->chunk[0].dirty && (addr+H5O_SIZEOF_HDR(f))==oh->chunk[0].addr) {
- combine=1;
- } /* end if */
- else {
- if (H5F_block_write(f, H5FD_MEM_OHDR, addr, (size_t)H5O_SIZEOF_HDR(f),
- dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header hdr to disk");
- } /* end else */
-
- /* encode messages */
- for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) {
- if (curr_msg->dirty) {
- p = curr_msg->raw - H5O_SIZEOF_MSGHDR(f);
-
- id = curr_msg->type->id;
- UINT16ENCODE(p, id);
- assert (curr_msg->raw_size<H5O_MAX_SIZE);
- UINT16ENCODE(p, curr_msg->raw_size);
- *p++ = curr_msg->flags;
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
- *p++ = 0; /*reserved*/
-
- if (curr_msg->native) {
- assert(curr_msg->type->encode);
-
- /* allocate file space for chunks that have none yet */
- if (H5O_CONT_ID == curr_msg->type->id &&
- !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr)) {
- cont = (H5O_cont_t *) (curr_msg->native);
- assert(cont->chunkno < oh->nchunks);
- assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr));
- cont->size = oh->chunk[cont->chunkno].size;
-
- /* Free the space we'd reserved in the file to hold this chunk */
- H5MF_free_reserved(f, (hsize_t)cont->size);
-
- if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)cont->size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for object header data");
- oh->chunk[cont->chunkno].addr = cont->addr;
- }
-
- /*
- * Encode the message. If the message is shared then we
- * encode a Shared Object message instead of the object
- * which is being shared.
- */
- assert(curr_msg->raw >=
- oh->chunk[curr_msg->chunkno].image);
- assert (curr_msg->raw_size ==
- H5O_ALIGN (curr_msg->raw_size));
- assert(curr_msg->raw + curr_msg->raw_size <=
- oh->chunk[curr_msg->chunkno].image +
- oh->chunk[curr_msg->chunkno].size);
- if (curr_msg->flags & H5O_FLAG_SHARED) {
- encode = H5O_SHARED->encode;
- } else {
- encode = curr_msg->type->encode;
- }
- if ((encode)(f, curr_msg->raw, curr_msg->native)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message");
- }
- curr_msg->dirty = FALSE;
- oh->chunk[curr_msg->chunkno].dirty = TRUE;
- }
- }
-
- /* write each chunk to disk */
- for (u = 0; u < oh->nchunks; u++) {
- if (oh->chunk[u].dirty) {
- assert(H5F_addr_defined(oh->chunk[u].addr));
- if(u==0 && combine) {
- /* Allocate space for the combined prefix and first chunk */
- if((p=H5FL_BLK_MALLOC(chunk_image,(H5O_SIZEOF_HDR(f)+oh->chunk[u].size)))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
-
- /* Copy in the prefix */
- HDmemcpy(p,buf,(size_t)H5O_SIZEOF_HDR(f));
-
- /* Copy in the first chunk */
- HDmemcpy(p+H5O_SIZEOF_HDR(f),oh->chunk[u].image,oh->chunk[u].size);
-
- /* Write the combined prefix/chunk out */
- if (H5F_block_write(f, H5FD_MEM_OHDR, addr,
- (H5O_SIZEOF_HDR(f)+oh->chunk[u].size),
- dxpl_id, p) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
-
- /* Release the memory for the combined prefix/chunk */
- p = H5FL_BLK_FREE(chunk_image,p);
- } /* end if */
- else {
- if (H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr,
- (oh->chunk[u].size),
- dxpl_id, oh->chunk[u].image) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
- } /* end else */
- oh->chunk[u].dirty = FALSE;
- } /* end if */
- } /* end for */
- oh->cache_info.is_dirty = FALSE;
- }
-
- if (destroy) {
- if(H5O_dest(f,oh)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data");
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_dest
- *
- * Purpose: Destroys an object header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jan 15 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_dest(H5F_t UNUSED *f, H5O_t *oh)
-{
- unsigned i;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dest);
-
- /* check args */
- assert(oh);
-
- /* Verify that node is clean */
- assert (oh->cache_info.is_dirty==FALSE);
-
- /* destroy chunks */
- for (i = 0; i < oh->nchunks; i++) {
- /* Verify that chunk is clean */
- assert (oh->chunk[i].dirty==0);
-
- oh->chunk[i].image = H5FL_BLK_FREE(chunk_image,oh->chunk[i].image);
- }
- if(oh->chunk)
- oh->chunk = H5FL_SEQ_FREE(H5O_chunk_t,oh->chunk);
-
- /* destroy messages */
- for (i = 0; i < oh->nmesgs; i++) {
- /* Verify that message is clean */
- assert (oh->mesg[i].dirty==0);
-
- H5O_free_mesg(&oh->mesg[i]);
- }
- if(oh->mesg)
- oh->mesg = H5FL_SEQ_FREE(H5O_mesg_t,oh->mesg);
-
- /* destroy object header */
- H5FL_FREE(H5O_t,oh);
-
- FUNC_LEAVE_NOAPI(SUCCEED);
-} /* end H5O_dest() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_clear
- *
- * Purpose: Mark a object header in memory as non-dirty.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Mar 20 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_clear(H5F_t *f, H5O_t *oh, hbool_t destroy)
-{
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_clear);
-
- /* check args */
- assert(oh);
-
- /* Mark chunks as clean */
- for (u = 0; u < oh->nchunks; u++)
- oh->chunk[u].dirty=FALSE;
-
- /* Mark messages as clean */
- for (u = 0; u < oh->nmesgs; u++)
- oh->mesg[u].dirty=FALSE;
-
- /* Mark whole header as clean */
- oh->cache_info.is_dirty=FALSE;
-
- if (destroy)
- if (H5O_dest(f, oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data");
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5O_clear() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_compute_size
- *
- * Purpose: Compute the size in bytes of the specified instance of
- * H5O_t on disk, and return it in *len_ptr. On failure,
- * the value of *len_ptr is undefined.
- *
- * The value returned will probably be low unless the object
- * has just been flushed, as we simply total up the size of
- * the header with the sizes of the chunks. Thus any message
- * that has been added since the last flush will not be
- * reflected in the total.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: John Mainzer
- * 5/13/04
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_compute_size(const H5F_t *f, const H5O_t *oh, size_t *size_ptr)
-{
- unsigned u;
- size_t size;
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_compute_size);
-
- /* check args */
- HDassert(f);
- HDassert(oh);
- HDassert(size_ptr);
-
- size = H5O_SIZEOF_HDR(f);
-
- for (u = 0; u < oh->nchunks; u++)
- size += oh->chunk[u].size;
-
- HDassert(size >= H5O_SIZEOF_HDR(f));
-
- *size_ptr = size;
-
- FUNC_LEAVE_NOAPI(SUCCEED);
-} /* H5O_compute_size() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5O_reset
*
* Purpose: Some message data structures have internal fields that
@@ -1102,7 +598,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5O_free_mesg(H5O_mesg_t *mesg)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_free_mesg)
@@ -1746,7 +1242,7 @@ H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t **type_p,
if (NULL == oh->mesg[u].native) {
assert(type->decode);
- oh->mesg[u].native = (type->decode) (f, dxpl_id, oh->mesg[u].raw, NULL);
+ oh->mesg[u].native = (type->decode) (f, dxpl_id, oh->mesg[u].raw);
if (NULL == oh->mesg[u].native)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, UFAIL, "unable to decode message");
}
@@ -3542,7 +3038,7 @@ H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link)
*/
if (NULL == mesg->native) {
assert(type->decode);
- mesg->native = (type->decode) (f, dxpl_id, mesg->raw, NULL);
+ mesg->native = (type->decode) (f, dxpl_id, mesg->raw);
if (NULL == mesg->native)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message");
} /* end if */
@@ -3750,7 +3246,7 @@ H5O_iterate_real(const H5G_entry_t *ent, const H5O_class_t *type, H5AC_protect_t
/* Decode the message if necessary */
HDassert(decode_type->decode);
- if (NULL == (idx_msg->native = (decode_type->decode) (ent->file, dxpl_id, idx_msg->raw, NULL)))
+ if (NULL == (idx_msg->native = (decode_type->decode) (ent->file, dxpl_id, idx_msg->raw)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message")
} /* end if */
@@ -3856,7 +3352,7 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
int *sequence;
haddr_t tmp_addr;
herr_t ret_value = SUCCEED;
- void *(*decode)(H5F_t*, hid_t, const uint8_t*, H5O_shared_t*);
+ void *(*decode)(H5F_t*, hid_t, const uint8_t*);
herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL;
FUNC_ENTER_NOAPI(H5O_debug, FAIL);
@@ -3972,7 +3468,7 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
debug = oh->mesg[i].type->debug;
}
if (NULL==oh->mesg[i].native && decode)
- oh->mesg[i].native = (decode)(f, dxpl_id, oh->mesg[i].raw, NULL);
+ oh->mesg[i].native = (decode)(f, dxpl_id, oh->mesg[i].raw);
if (NULL==oh->mesg[i].native)
debug = NULL;
@@ -3989,17 +3485,9 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
H5O_shared_t *shared = (H5O_shared_t*)(oh->mesg[i].native);
void *mesg = NULL;
- if (shared->in_gh) {
- void *p = H5HG_read (f, dxpl_id, oh->mesg[i].native, NULL);
- mesg = (oh->mesg[i].type->decode)(f, dxpl_id, p, oh->mesg[i].native);
- H5MM_xfree (p);
- } else {
- mesg = H5O_read_real(&(shared->u.ent), oh->mesg[i].type, 0, NULL, dxpl_id);
- }
- if (oh->mesg[i].type->debug) {
- (oh->mesg[i].type->debug)(f, dxpl_id, mesg, stream, indent+3,
- MAX (0, fwidth-3));
- }
+ mesg = H5O_read_real(&(shared->ent), oh->mesg[i].type, 0, NULL, dxpl_id);
+ if (oh->mesg[i].type->debug)
+ (oh->mesg[i].type->debug)(f, dxpl_id, mesg, stream, indent+3, MAX (0, fwidth-3));
H5O_free_real(oh->mesg[i].type, mesg);
}
}
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index ccd9784..7d278db 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -28,7 +28,7 @@
/* PRIVATE PROTOTYPES */
static herr_t H5O_attr_encode (H5F_t *f, uint8_t *p, const void *mesg);
-static void *H5O_attr_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_attr_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static void *H5O_attr_copy (const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_attr_size (const H5F_t *f, const void *_mesg);
static herr_t H5O_attr_reset (void *_mesg);
@@ -101,7 +101,7 @@ H5FL_EXTERN(H5S_extent_t);
*
--------------------------------------------------------------------------*/
static void *
-H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p)
{
H5A_t *attr = NULL;
H5S_extent_t *extent; /*extent dimensionality information */
@@ -151,7 +151,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
H5O_shared_t *shared; /* Shared information */
/* Get the shared information */
- if (NULL == (shared = (H5O_SHARED->decode) (f, dxpl_id, p, NULL)))
+ if (NULL == (shared = (H5O_SHARED->decode) (f, dxpl_id, p)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message");
/* Get the actual datatype information */
@@ -162,7 +162,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
H5O_free_real(H5O_SHARED, shared);
} /* end if */
else {
- if((attr->dt=(H5O_DTYPE->decode)(f,dxpl_id,p,NULL))==NULL)
+ if((attr->dt=(H5O_DTYPE->decode)(f,dxpl_id,p))==NULL)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype");
} /* end else */
if(version < H5O_ATTR_VERSION_NEW)
@@ -174,7 +174,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
if (NULL==(attr->ds = H5FL_CALLOC(H5S_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if((extent=(H5O_SDSPACE->decode)(f,dxpl_id,p,NULL))==NULL)
+ if((extent=(H5O_SDSPACE->decode)(f,dxpl_id,p))==NULL)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace");
/* Copy the extent information */
diff --git a/src/H5Obogus.c b/src/H5Obogus.c
index 64f94ac..13b6385 100644
--- a/src/H5Obogus.c
+++ b/src/H5Obogus.c
@@ -39,7 +39,7 @@
#ifdef H5O_ENABLE_BOGUS
/* PRIVATE PROTOTYPES */
-static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_bogus_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static size_t H5O_bogus_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_bogus_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
@@ -83,8 +83,7 @@ const H5O_class_t H5O_BOGUS[1] = {{
*-------------------------------------------------------------------------
*/
static void *
-H5O_bogus_decode(H5F_t UNUSED *f, hid_t dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_bogus_decode(H5F_t UNUSED *f, hid_t dxpl_id, const uint8_t *p)
{
H5O_bogus_t *mesg=NULL;
void *ret_value; /* Return value */
@@ -94,7 +93,6 @@ H5O_bogus_decode(H5F_t UNUSED *f, hid_t dxpl_id, const uint8_t *p,
/* check args */
assert(f);
assert(p);
- assert(!sh);
/* Allocate the bogus message */
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_bogus_t))))
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index e5e20e4..4289296 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -32,6 +32,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
+#include "H5MFprivate.h" /* File memory management */
#include "H5Opkg.h" /* Object headers */
/* Private typedefs */
@@ -91,6 +92,20 @@ H5O_cache_init_interface(void)
* matzke@llnl.gov
* Aug 5 1997
*
+ * Modifications:
+ *
+ * Robb Matzke, 1997-08-30
+ * Plugged memory leaks that occur during error handling.
+ *
+ * Robb Matzke, 1998-01-07
+ * Able to distinguish between constant and variable messages.
+ *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *
+ * Quincey Koziol, 2002-7-180
+ * Added dxpl parameter to allow more control over I/O from metadata
+ * cache.
*-------------------------------------------------------------------------
*/
static H5O_t *
@@ -112,13 +127,13 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
size_t chunk_size;
uint8_t flags;
- FUNC_ENTER_NOAPI(H5O_load, NULL)
+ FUNC_ENTER_NOAPI(H5O_load, NULL);
/* check args */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(!_udata1);
- HDassert(!_udata2);
+ assert(f);
+ assert(H5F_addr_defined(addr));
+ assert(!_udata1);
+ assert(!_udata2);
/* allocate ohdr and init chunk list */
if (NULL==(oh = H5FL_CALLOC(H5O_t)))
@@ -155,39 +170,40 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* read each chunk from disk */
- while(H5F_addr_defined(chunk_addr)) {
+ while (H5F_addr_defined(chunk_addr)) {
/* increase chunk array size */
- if(oh->nchunks >= oh->alloc_nchunks) {
+ if (oh->nchunks >= oh->alloc_nchunks) {
unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
H5O_chunk_t *x = H5FL_SEQ_REALLOC (H5O_chunk_t, oh->chunk, (size_t)na);
- if(!x)
+ if (!x)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
oh->alloc_nchunks = na;
oh->chunk = x;
- } /* end if */
+ }
/* read the chunk raw data */
chunkno = oh->nchunks++;
oh->chunk[chunkno].dirty = FALSE;
oh->chunk[chunkno].addr = chunk_addr;
oh->chunk[chunkno].size = chunk_size;
- if(NULL==(oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image, chunk_size)))
+ if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_MALLOC(chunk_image,chunk_size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if(H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id, oh->chunk[chunkno].image) < 0)
+ if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id,
+ oh->chunk[chunkno].image) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data");
/* load messages from this chunk */
- for(p = oh->chunk[chunkno].image; p < oh->chunk[chunkno].image + chunk_size; p += mesg_size) {
+ for (p = oh->chunk[chunkno].image; p < oh->chunk[chunkno].image + chunk_size; p += mesg_size) {
UINT16DECODE(p, id);
UINT16DECODE(p, mesg_size);
- HDassert(mesg_size==H5O_ALIGN (mesg_size));
+ assert (mesg_size==H5O_ALIGN (mesg_size));
flags = *p++;
p += 3; /*reserved*/
/* Try to detect invalidly formatted object header messages */
- if(p + mesg_size > oh->chunk[chunkno].image + chunk_size)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "corrupt object header")
+ if (p + mesg_size > oh->chunk[chunkno].image + chunk_size)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "corrupt object header");
/* Skip header messages we don't know about */
/* (Usually from future versions of the library */
@@ -196,9 +212,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
continue;
} /* end if */
- if(H5O_NULL_ID == id && oh->nmesgs > 0 &&
- H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id &&
- oh->mesg[oh->nmesgs - 1].chunkno == chunkno) {
+ if (H5O_NULL_ID == id && oh->nmesgs > 0 &&
+ H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id &&
+ oh->mesg[oh->nmesgs - 1].chunkno == chunkno) {
/* combine adjacent null messages */
mesgno = oh->nmesgs - 1;
oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR(f) + mesg_size;
@@ -215,14 +231,14 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
oh->mesg[mesgno].raw = p;
oh->mesg[mesgno].raw_size = mesg_size;
oh->mesg[mesgno].chunkno = chunkno;
- } /* end else */
- } /* end for */
+ }
+ }
- HDassert(p == oh->chunk[chunkno].image + chunk_size);
+ assert(p == oh->chunk[chunkno].image + chunk_size);
/* decode next object header continuation message */
- for(chunk_addr = HADDR_UNDEF; !H5F_addr_defined(chunk_addr) && curmesg < oh->nmesgs; ++curmesg) {
- if(H5O_CONT_ID == oh->mesg[curmesg].type->id) {
+ for (chunk_addr = HADDR_UNDEF; !H5F_addr_defined(chunk_addr) && curmesg < oh->nmesgs; ++curmesg) {
+ if (H5O_CONT_ID == oh->mesg[curmesg].type->id) {
H5O_cont_t *cont;
cont = (H5O_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw);
@@ -230,9 +246,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
chunk_addr = cont->addr;
chunk_size = cont->size;
cont->chunkno = oh->nchunks; /*the next chunk to allocate */
- } /* end if */
- } /* end for */
- } /* end while */
+ }
+ }
+ }
/* Sanity check for the correct # of messages in object header */
if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs)
@@ -242,13 +258,13 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
ret_value = oh;
done:
- if(!ret_value && oh) {
- if(H5O_dest(f,oh) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data")
- } /* end if */
+ if (!ret_value && oh) {
+ if(H5O_dest(f,oh)<0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "unable to destroy object header data");
+ }
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_load() */
+ FUNC_LEAVE_NOAPI(ret_value);
+}
/*-------------------------------------------------------------------------
@@ -262,6 +278,20 @@ done:
* matzke@llnl.gov
* Aug 5 1997
*
+ * Modifications:
+ *
+ * Robb Matzke, 1998-01-07
+ * Handles constant vs non-constant messages.
+ *
+ * rky, 1998-08-28
+ * Only p0 writes metadata to disk.
+ *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *
+ * Quincey Koziol, 2002-7-180
+ * Added dxpl parameter to allow more control over I/O from metadata
+ * cache.
*-------------------------------------------------------------------------
*/
static herr_t
@@ -269,18 +299,19 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
{
uint8_t buf[16], *p;
int id;
+ unsigned u;
H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ H5O_cont_t *cont = NULL;
herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
- unsigned combine = 0; /* Whether to combine the object header prefix & the first chunk */
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned combine=0; /* Whether to combine the object header prefix & the first chunk */
+ herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_flush, FAIL)
+ FUNC_ENTER_NOAPI(H5O_flush, FAIL);
/* check args */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
- HDassert(oh);
+ assert(f);
+ assert(H5F_addr_defined(addr));
+ assert(oh);
/* flush */
if(oh->cache_info.is_dirty) {
@@ -291,44 +322,56 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
id = curr_msg->type->id;
UINT16ENCODE(p, id);
- HDassert(curr_msg->raw_size < H5O_MAX_SIZE);
+ assert (curr_msg->raw_size<H5O_MAX_SIZE);
UINT16ENCODE(p, curr_msg->raw_size);
*p++ = curr_msg->flags;
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
*p++ = 0; /*reserved*/
- if(curr_msg->native) {
- HDassert(curr_msg->type->encode);
+ if (curr_msg->native) {
+ assert(curr_msg->type->encode);
/* allocate file space for chunks that have none yet */
- if(H5O_CONT_ID == curr_msg->type->id && !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr))
- /* We now allocate disk space on insertion, instead
- * of on flush from the cache, so this case is now an
- * error. -- JRM
- */
- HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "File space for message not allocated!?!")
+ if (H5O_CONT_ID == curr_msg->type->id &&
+ !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr)) {
+ cont = (H5O_cont_t *) (curr_msg->native);
+ assert(cont->chunkno < oh->nchunks);
+ assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr));
+ cont->size = oh->chunk[cont->chunkno].size;
+
+ /* Free the space we'd reserved in the file to hold this chunk */
+ H5MF_free_reserved(f, (hsize_t)cont->size);
+
+ if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)cont->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for object header data");
+ oh->chunk[cont->chunkno].addr = cont->addr;
+ }
/*
* Encode the message. If the message is shared then we
* encode a Shared Object message instead of the object
* which is being shared.
*/
- HDassert(curr_msg->raw >= oh->chunk[curr_msg->chunkno].image);
- HDassert(curr_msg->raw_size == H5O_ALIGN (curr_msg->raw_size));
- HDassert(curr_msg->raw + curr_msg->raw_size <=
- oh->chunk[curr_msg->chunkno].image + oh->chunk[curr_msg->chunkno].size);
- if(curr_msg->flags & H5O_FLAG_SHARED)
+ assert(curr_msg->raw >=
+ oh->chunk[curr_msg->chunkno].image);
+ assert (curr_msg->raw_size ==
+ H5O_ALIGN (curr_msg->raw_size));
+ assert(curr_msg->raw + curr_msg->raw_size <=
+ oh->chunk[curr_msg->chunkno].image +
+ oh->chunk[curr_msg->chunkno].size);
+ if (curr_msg->flags & H5O_FLAG_SHARED) {
encode = H5O_SHARED->encode;
- else
+ } else {
encode = curr_msg->type->encode;
- if((encode)(f, curr_msg->raw, curr_msg->native) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message")
- } /* end if */
+ }
+ if ((encode)(f, curr_msg->raw, curr_msg->native)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message");
+ }
curr_msg->dirty = FALSE;
oh->chunk[curr_msg->chunkno].dirty = TRUE;
- } /* end if */
- } /* end for */
+ }
+ }
/* Sanity check for the correct # of messages in object header */
if(oh->nmesgs != u)
@@ -366,48 +409,51 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header hdr to disk")
} /* end else */
+
/* write each chunk to disk */
- for(u = 0; u < oh->nchunks; u++) {
- if(oh->chunk[u].dirty) {
- HDassert(H5F_addr_defined(oh->chunk[u].addr));
- if(u == 0 && combine) {
+ for (u = 0; u < oh->nchunks; u++) {
+ if (oh->chunk[u].dirty) {
+ assert(H5F_addr_defined(oh->chunk[u].addr));
+ if(u==0 && combine) {
/* Allocate space for the combined prefix and first chunk */
- if((p = H5FL_BLK_MALLOC(chunk_image,(H5O_SIZEOF_HDR(f)+oh->chunk[u].size))) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if((p=H5FL_BLK_MALLOC(chunk_image,(H5O_SIZEOF_HDR(f)+oh->chunk[u].size)))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Copy in the prefix */
- HDmemcpy(p, buf, (size_t)H5O_SIZEOF_HDR(f));
+ HDmemcpy(p,buf,(size_t)H5O_SIZEOF_HDR(f));
/* Copy in the first chunk */
- HDmemcpy(p + H5O_SIZEOF_HDR(f), oh->chunk[u].image, oh->chunk[u].size);
+ HDmemcpy(p+H5O_SIZEOF_HDR(f),oh->chunk[u].image,oh->chunk[u].size);
/* Write the combined prefix/chunk out */
- if(H5F_block_write(f, H5FD_MEM_OHDR, addr,
- (H5O_SIZEOF_HDR(f) + oh->chunk[u].size), dxpl_id, p) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk")
+ if (H5F_block_write(f, H5FD_MEM_OHDR, addr,
+ (H5O_SIZEOF_HDR(f)+oh->chunk[u].size),
+ dxpl_id, p) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
/* Release the memory for the combined prefix/chunk */
p = H5FL_BLK_FREE(chunk_image,p);
} /* end if */
else {
- if(H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr,
- (oh->chunk[u].size), dxpl_id, oh->chunk[u].image) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk")
+ if (H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr,
+ (oh->chunk[u].size),
+ dxpl_id, oh->chunk[u].image) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
} /* end else */
oh->chunk[u].dirty = FALSE;
} /* end if */
} /* end for */
oh->cache_info.is_dirty = FALSE;
- } /* end if */
+ }
if (destroy) {
- if(H5O_dest(f,oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data")
- } /* end if */
+ if(H5O_dest(f,oh)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data");
+ }
done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_flush() */
+ FUNC_LEAVE_NOAPI(ret_value);
+}
/*-------------------------------------------------------------------------
@@ -421,6 +467,8 @@ done:
* koziol@ncsa.uiuc.edu
* Jan 15 2003
*
+ * Modifications:
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -474,6 +522,8 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh)
* koziol@ncsa.uiuc.edu
* Mar 20 2003
*
+ * Modifications:
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -525,6 +575,8 @@ done:
* Programmer: John Mainzer
* 5/13/04
*
+ * Modifications:
+ *
*-------------------------------------------------------------------------
*/
static herr_t
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 3030827..a829c55 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -38,7 +38,7 @@
/* PRIVATE PROTOTYPES */
-static void *H5O_cont_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_cont_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static size_t H5O_cont_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_cont_free(void *mesg);
@@ -85,7 +85,7 @@ H5FL_DEFINE(H5O_cont_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_cont_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_cont_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_cont_t *cont = NULL;
void *ret_value;
@@ -95,7 +95,6 @@ H5O_cont_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t U
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* decode */
if (NULL==(cont = H5FL_MALLOC(H5O_cont_t)))
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index cef2cd2..ccacdfd 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -26,7 +26,7 @@
/* PRIVATE PROTOTYPES */
static herr_t H5O_dtype_encode (H5F_t *f, uint8_t *p, const void *mesg);
-static void *H5O_dtype_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_dtype_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static void *H5O_dtype_copy (const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_dtype_size (const H5F_t *f, const void *_mesg);
static herr_t H5O_dtype_reset (void *_mesg);
@@ -812,8 +812,7 @@ done:
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
static void *
-H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5T_t *dt = NULL;
void *ret_value; /* Return value */
@@ -1112,8 +1111,7 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
/* If the address is defined, this had better be a named datatype */
HDassert (H5T_STATE_NAMED==dt->shared->state || H5T_STATE_OPEN==dt->shared->state);
- sh->in_gh = FALSE;
- sh->u.ent = dt->ent;
+ H5G_ent_copy(&(sh->ent), &(dt->ent), H5G_COPY_NULL);
} else
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is not sharable");
@@ -1149,10 +1147,9 @@ H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/,
assert (dt);
assert (sh);
- assert (!sh->in_gh);
/* NULL copy here, names not appropriate */
- H5G_ent_copy(&(dt->ent),&(sh->u.ent),H5G_COPY_NULL);
+ H5G_ent_copy(&(dt->ent), &(sh->ent), H5G_COPY_NULL);
/* Note that the datatype is a named datatype */
dt->shared->state = H5T_STATE_NAMED;
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 9f009b7..d97a462 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -28,7 +28,7 @@
#include "H5Opkg.h" /* Object headers */
/* PRIVATE PROTOTYPES */
-static void *H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_efl_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_efl_size(const H5F_t *f, const void *_mesg);
@@ -77,7 +77,7 @@ const H5O_class_t H5O_EFL[1] = {{
*-------------------------------------------------------------------------
*/
static void *
-H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p)
{
H5O_efl_t *mesg = NULL;
int version;
@@ -91,7 +91,6 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *s
/* Check args */
assert(f);
assert(p);
- assert (!sh);
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 3dc3dfc..646cff5 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -30,7 +30,7 @@
#include "H5Pprivate.h" /* Property lists */
-static void *H5O_fill_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_fill_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_fill_new_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_fill_new_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_fill_new_size(const H5F_t *f, const void *_mesg);
@@ -39,7 +39,7 @@ static herr_t H5O_fill_new_free(void *_mesg);
static herr_t H5O_fill_new_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
-static void *H5O_fill_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_fill_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_fill_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_fill_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_fill_size(const H5F_t *f, const void *_mesg);
@@ -115,8 +115,7 @@ H5FL_DEFINE(H5O_fill_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_fill_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_fill_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_fill_new_t *mesg=NULL;
int version;
@@ -126,7 +125,6 @@ H5O_fill_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
assert(f);
assert(p);
- assert(!sh);
if (NULL==(mesg=H5FL_CALLOC(H5O_fill_new_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message");
@@ -189,8 +187,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_fill_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_fill_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_fill_t *mesg=NULL;
void *ret_value;
@@ -199,7 +196,6 @@ H5O_fill_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
assert(f);
assert(p);
- assert(!sh);
if (NULL==(mesg=H5FL_CALLOC(H5O_fill_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message");
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 5367b11..cb87764 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -30,7 +30,7 @@
#include "H5Opkg.h" /* Object headers */
/* PRIVATE PROTOTYPES */
-static void *H5O_layout_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_layout_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_layout_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_layout_size(const H5F_t *f, const void *_mesg);
@@ -93,7 +93,7 @@ H5FL_DEFINE(H5O_layout_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_layout_t *mesg = NULL;
unsigned u;
@@ -104,7 +104,6 @@ H5O_layout_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* decode */
if (NULL==(mesg = H5FL_CALLOC(H5O_layout_t)))
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index aa8c085..3f10b98 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -32,11 +32,11 @@
#endif
-static void *H5O_mtime_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_mtime_new_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_mtime_new_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static size_t H5O_mtime_new_size(const H5F_t *f, const void *_mesg);
-static void *H5O_mtime_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_mtime_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_mtime_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_mtime_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_mtime_size(const H5F_t *f, const void *_mesg);
@@ -111,8 +111,7 @@ H5FL_DEFINE(time_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_mtime_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_mtime_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
time_t *mesg;
uint32_t tmp_time; /* Temporary copy of the time */
@@ -123,7 +122,6 @@ H5O_mtime_new_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* decode */
if(*p++ != H5O_MTIME_VERSION)
@@ -167,8 +165,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
time_t *mesg, the_time;
int i;
@@ -180,7 +177,6 @@ H5O_mtime_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* Initialize time zone information */
if (!ntzset) {
diff --git a/src/H5Oname.c b/src/H5Oname.c
index c67d5bb..ffefc96 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -34,7 +34,7 @@
/* PRIVATE PROTOTYPES */
-static void *H5O_name_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_name_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_name_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_name_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_name_size(const H5F_t *f, const void *_mesg);
@@ -80,8 +80,7 @@ const H5O_class_t H5O_NAME[1] = {{
*-------------------------------------------------------------------------
*/
static void *
-H5O_name_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_name_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_name_t *mesg;
void *ret_value; /* Return value */
@@ -91,7 +90,6 @@ H5O_name_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* decode */
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_name_t))) ||
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 5e15e54..80cccc3 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -22,6 +22,9 @@
/* Get package's private header */
#include "H5Oprivate.h" /* Object headers */
+/* Other private headers needed by this file */
+#include "H5ACprivate.h" /* Metadata cache */
+
/*
* Align messages on 8-byte boundaries because we would like to copy the
* object header chunks directly into memory and operate on them there, even
@@ -59,7 +62,7 @@ typedef struct H5O_class_t {
int id; /*message type ID on disk */
const char *name; /*for debugging */
size_t native_size; /*size of native message */
- void *(*decode)(H5F_t*, hid_t, const uint8_t*, struct H5O_shared_t*);
+ void *(*decode)(H5F_t*, hid_t, const uint8_t*);
herr_t (*encode)(H5F_t*, uint8_t*, const void*);
void *(*copy)(const void*, void*, unsigned); /*copy native value */
size_t (*raw_size)(const H5F_t*, const void*);/*sizeof raw val */
@@ -102,6 +105,24 @@ typedef struct H5O_t {
H5O_chunk_t *chunk; /*array of chunks */
} H5O_t;
+/* H5O inherits cache-like properties from H5AC */
+H5_DLLVAR const H5AC_class_t H5AC_OHDR[1];
+
+/* ID to type mapping */
+H5_DLLVAR const H5O_class_t *const message_type_g[19];
+
+/* Declare external the free list for H5O_t's */
+H5FL_EXTERN(H5O_t);
+
+/* Declare external the free list for H5O_mesg_t sequences */
+H5FL_SEQ_EXTERN(H5O_mesg_t);
+
+/* Declare external the free list for H5O_chunk_t sequences */
+H5FL_SEQ_EXTERN(H5O_chunk_t);
+
+/* Declare external the free list for chunk_image blocks */
+H5FL_BLK_EXTERN(chunk_image);
+
/*
* Null Message. (0x0000)
*/
@@ -198,6 +219,8 @@ H5_DLLVAR const H5O_class_t H5O_STAB[1];
H5_DLLVAR const H5O_class_t H5O_MTIME_NEW[1];
/* Package-local function prototypes */
+H5_DLL herr_t H5O_init(void);
+H5_DLL herr_t H5O_free_mesg(H5O_mesg_t *mesg);
H5_DLL void * H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type,
int sequence, void *mesg, hid_t dxpl_id);
H5_DLL void * H5O_free_real(const H5O_class_t *type, void *mesg);
@@ -210,4 +233,8 @@ H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared,
H5_DLL void *H5O_stab_fast(const H5G_cache_t *cache, const struct H5O_class_t *type,
void *_mesg);
+/* Useful metadata cache callbacks */
+H5_DLL herr_t H5O_dest(H5F_t *f, H5O_t *oh);
+
#endif /* _H5Opkg_H */
+
diff --git a/src/H5Opline.c b/src/H5Opline.c
index befc2b4..981c2af 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -31,7 +31,7 @@
#define H5O_PLINE_VERSION 1
static herr_t H5O_pline_encode (H5F_t *f, uint8_t *p, const void *mesg);
-static void *H5O_pline_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_pline_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static void *H5O_pline_copy (const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_pline_size (const H5F_t *f, const void *_mesg);
static herr_t H5O_pline_reset (void *_mesg);
@@ -79,8 +79,7 @@ H5FL_DEFINE(H5O_pline_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p,
- H5O_shared_t UNUSED *sh)
+H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_pline_t *pline = NULL;
void *ret_value;
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index baa7d33..ba278d0 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -35,7 +35,6 @@
#include "H5Spublic.h" /* Dataspace functions */
/* Private headers needed by this file */
-#include "H5HGprivate.h" /* Global heap functions */
#include "H5Tprivate.h" /* Datatype functions */
#include "H5Zprivate.h" /* I/O pipeline filters */
@@ -201,11 +200,7 @@ typedef struct H5O_name_t {
*/
typedef struct H5O_shared_t {
- hbool_t in_gh; /*shared by global heap? */
- union {
- H5HG_t gh; /*global heap info */
- H5G_entry_t ent; /*symbol table entry info */
- } u;
+ H5G_entry_t ent; /*symbol table entry info */
} H5O_shared_t;
/*
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 733d895..e2cf63b 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -25,7 +25,7 @@
/* PRIVATE PROTOTYPES */
-static void *H5O_sdspace_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_sdspace_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_sdspace_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg);
@@ -88,7 +88,7 @@ H5FL_ARR_EXTERN(hsize_t);
Added a version number and reformatted the message for aligment.
--------------------------------------------------------------------------*/
static void *
-H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5S_extent_t *sdim = NULL;/* New extent dimensionality structure */
void *ret_value;
@@ -100,7 +100,6 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_
/* check args */
assert(f);
assert(p);
- assert (!sh);
/* decode */
if ((sdim = H5FL_CALLOC(H5S_extent_t)) != NULL) {
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index ea0893d..9f39ed8 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -36,7 +36,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
-static void *H5O_shared_decode (H5F_t*, hid_t dxpl_id, const uint8_t*, H5O_shared_t *sh);
+static void *H5O_shared_decode (H5F_t*, hid_t dxpl_id, const uint8_t*);
static herr_t H5O_shared_encode (H5F_t*, uint8_t*, const void*);
static void *H5O_shared_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_shared_size (const H5F_t*, const void *_mesg);
@@ -103,28 +103,9 @@ H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared, const H5O_class_t
assert(type);
/* Get the shared message */
- if (shared->in_gh) {
- void *tmp_buf, *tmp_mesg;
-
- if (NULL==(tmp_buf = H5HG_read (f, dxpl_id, &(shared->u.gh), NULL)))
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to read shared message from global heap");
- tmp_mesg = (type->decode)(f, dxpl_id, tmp_buf, shared);
- tmp_buf = H5MM_xfree (tmp_buf);
- if (!tmp_mesg)
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to decode object header shared message");
- if (mesg) {
- HDmemcpy (mesg, tmp_mesg, type->native_size);
- H5MM_xfree (tmp_mesg);
- } /* end if */
- else
- ret_value = tmp_mesg;
- } /* end if */
- else {
- ret_value = H5O_read_real(&(shared->u.ent), type, 0, mesg, dxpl_id);
- if (type->set_share &&
- (type->set_share)(f, ret_value, shared)<0)
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information");
- } /* end else */
+ ret_value = H5O_read_real(&(shared->ent), type, 0, mesg, dxpl_id);
+ if (type->set_share && (type->set_share)(f, ret_value, shared)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information");
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -160,26 +141,16 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adj
assert(f);
assert(shared);
- if (shared->in_gh) {
- /*
- * The shared message is stored in the global heap.
- * Adjust the reference count on the global heap message.
- */
- if ((ret_value = H5HG_link (f, dxpl_id, &(shared->u.gh), adjust))<0)
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count");
- } /* end if */
- else {
- /*
- * The shared message is stored in some other object header.
- * The other object header must be in the same file as the
- * new object header. Adjust the reference count on that
- * object header.
- */
- if (shared->u.ent.file->shared != f->shared)
- HGOTO_ERROR(H5E_OHDR, H5E_LINK, FAIL, "interfile hard links are not allowed");
- if ((ret_value = H5O_link (&(shared->u.ent), adjust, dxpl_id))<0)
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count");
- } /* end else */
+ /*
+ * The shared message is stored in some other object header.
+ * The other object header must be in the same file as the
+ * new object header. Adjust the reference count on that
+ * object header.
+ */
+ if (shared->ent.file->shared != f->shared)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINK, FAIL, "interfile hard links are not allowed");
+ if ((ret_value = H5O_link (&(shared->ent), adjust, dxpl_id))<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count");
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -204,7 +175,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf, H5O_shared_t UNUSED *sh)
+H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
{
H5O_shared_t *mesg=NULL;
unsigned flags, version;
@@ -215,7 +186,6 @@ H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf, H5O_share
/* Check args */
assert (f);
assert (buf);
- assert (!sh);
/* Decode */
if (NULL==(mesg = H5MM_calloc (sizeof(H5O_shared_t))))
@@ -227,26 +197,19 @@ H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf, H5O_share
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message");
/* Get the shared information flags */
- flags = *buf++;
- mesg->in_gh = (flags & 0x01);
+ flags = *buf++; /* Unused currently */
/* Skip reserved bytes (for version 1) */
if(version==H5O_SHARED_VERSION_1)
buf += 6;
/* Body */
- if (mesg->in_gh) {
- H5F_addr_decode (f, &buf, &(mesg->u.gh.addr));
- INT32DECODE (buf, mesg->u.gh.idx);
- } /* end if */
+ if(version==H5O_SHARED_VERSION_1)
+ H5G_ent_decode (f, &buf, &(mesg->ent));
else {
- if(version==H5O_SHARED_VERSION_1)
- H5G_ent_decode (f, &buf, &(mesg->u.ent));
- else {
- assert(version==H5O_SHARED_VERSION);
- H5F_addr_decode (f, &buf, &(mesg->u.ent.header));
- mesg->u.ent.file=f;
- } /* end else */
+ assert(version==H5O_SHARED_VERSION);
+ H5F_addr_decode (f, &buf, &(mesg->ent.header));
+ mesg->ent.file=f;
} /* end else */
/* Set return value */
@@ -282,7 +245,6 @@ static herr_t
H5O_shared_encode (H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
{
const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
- unsigned flags;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode);
@@ -293,30 +255,8 @@ H5O_shared_encode (H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
/* Encode */
*buf++ = H5O_SHARED_VERSION;
- flags = mesg->in_gh ? 0x01 : 0x00;
- *buf++ = flags;
-#ifdef OLD_WAY
- *buf++ = 0; /*reserved 1*/
- *buf++ = 0; /*reserved 2*/
- *buf++ = 0; /*reserved 3*/
- *buf++ = 0; /*reserved 4*/
- *buf++ = 0; /*reserved 5*/
- *buf++ = 0; /*reserved 6*/
-
- if (mesg->in_gh) {
- H5F_addr_encode (f, &buf, mesg->u.gh.addr);
- INT32ENCODE (buf, mesg->u.gh.idx);
- } /* end if */
- else
- H5G_ent_encode (f, &buf, &(mesg->u.ent));
-#else /* OLD_WAY */
- if (mesg->in_gh) {
- H5F_addr_encode (f, &buf, mesg->u.gh.addr);
- INT32ENCODE (buf, mesg->u.gh.idx);
- } /* end if */
- else
- H5F_addr_encode (f, &buf, mesg->u.ent.header);
-#endif /* OLD_WAY */
+ *buf++ = 0; /* Flags unused currently */
+ H5F_addr_encode (f, &buf, mesg->ent.header);
FUNC_LEAVE_NOAPI(SUCCEED);
}
@@ -391,9 +331,7 @@ H5O_shared_size (const H5F_t *f, const void *_mesg)
ret_value = 1 + /*version */
1 + /*the flags field */
- (shared->in_gh ?
- (H5F_SIZEOF_ADDR(f)+4) : /*sharing via global heap */
- H5F_SIZEOF_ADDR(f)); /*sharing by another obj hdr */
+ H5F_SIZEOF_ADDR(f); /*sharing by another obj hdr */
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -500,23 +438,11 @@ H5O_shared_debug (H5F_t UNUSED *f, hid_t dxpl_id, const void *_mesg,
assert (indent>=0);
assert (fwidth>=0);
- if (mesg->in_gh) {
- HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Sharing method",
- "Global heap");
- HDfprintf (stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Collection address:",
- mesg->u.gh.addr);
- HDfprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Object ID within collection:",
- mesg->u.gh.idx);
- } else {
- HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Sharing method",
- "Obj Hdr");
- H5G_ent_debug (f, dxpl_id, &(mesg->u.ent), stream, indent, fwidth,
- HADDR_UNDEF);
- }
+ HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Sharing method",
+ "Obj Hdr");
+ H5G_ent_debug (f, dxpl_id, &(mesg->ent), stream, indent, fwidth,
+ HADDR_UNDEF);
FUNC_LEAVE_NOAPI(SUCCEED);
}
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index b8617f4..f6df318 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -36,7 +36,7 @@
/* PRIVATE PROTOTYPES */
-static void *H5O_stab_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t *sh);
+static void *H5O_stab_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
static herr_t H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg);
static void *H5O_stab_copy(const void *_mesg, void *_dest, unsigned update_flags);
static size_t H5O_stab_size(const H5F_t *f, const void *_mesg);
@@ -86,7 +86,7 @@ H5FL_DEFINE_STATIC(H5O_stab_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O_stab_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh)
+H5O_stab_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
{
H5O_stab_t *stab=NULL;
void *ret_value; /* Return value */
@@ -96,7 +96,6 @@ H5O_stab_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p, H5O_shared_t U
/* check args */
assert(f);
assert(p);
- assert(!sh);
/* decode */
if (NULL==(stab = H5FL_CALLOC(H5O_stab_t)))
diff --git a/src/H5T.c b/src/H5T.c
index 88e624d..c7cc3e5 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -252,7 +252,6 @@ H5FL_DEFINE(H5T_shared_t);
H5FL_DEFINE(H5T_path_t);
/* Static local functions */
-static H5T_t *H5T_open_oid(H5G_entry_t *ent, hid_t dxpl_id);
static herr_t H5T_print_stats(H5T_path_t *path, int *nprint/*in,out*/);
static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func, hid_t dxpl_id);
@@ -1370,75 +1369,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Topen
- *
- * Purpose: Opens a named data type.
- *
- * Return: Success: Object ID of the named data type.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Monday, June 1, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5Topen(hid_t loc_id, const char *name)
-{
- H5T_t *type = NULL;
- H5G_entry_t *loc = NULL;
- H5G_entry_t ent;
- hbool_t ent_found = FALSE; /* Entry at 'name' found */
- hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value =FAIL;
-
- FUNC_ENTER_API(H5Topen, FAIL);
- H5TRACE2("i","is",loc_id,name);
-
- /* Check args */
- if (NULL==(loc=H5G_loc (loc_id)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- if (!name || !*name)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
-
- /*
- * Find the named data type object header and read the data type message
- * from it.
- */
- if (H5G_find (loc, name, &ent/*out*/, dxpl_id)<0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found");
- ent_found = TRUE;
-
- /* Check that the object found is the correct type */
- if (H5G_get_type(&ent, dxpl_id) != H5G_TYPE)
- HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype")
-
- /* Open it */
- if ((type=H5T_open (&ent, dxpl_id)) ==NULL)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type");
-
- /* Register the type and return the ID */
- if ((ret_value=H5I_register (H5I_DATATYPE, type))<0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type");
-
-done:
- if(ret_value<0) {
- if(type!=NULL)
- H5T_close(type);
- else {
- if(ent_found && ent.header)
- H5G_free_ent_name(&ent);
- } /* end else */
- } /* end if */
-
- FUNC_LEAVE_API(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5Tcopy
*
* Purpose: Copies a data type. The resulting data type is not locked.
@@ -2720,148 +2650,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5T_open
- *
- * Purpose: Open a named data type.
- *
- * Return: Success: Ptr to a new data type.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
- * Monday, June 1, 1998
- *
- * Modifications:
- * Changed to use H5T_open_oid - QAK - 3/17/99
- *
- *-------------------------------------------------------------------------
- */
-H5T_t*
-H5T_open (H5G_entry_t *ent, hid_t dxpl_id)
-{
- H5T_shared_t *shared_fo=NULL;
- H5T_t *dt=NULL;
- H5T_t *ret_value;
-
- FUNC_ENTER_NOAPI(H5T_open, NULL);
-
- assert (ent);
-
- /* Check if datatype was already open */
- if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) {
- /* Clear any errors from H5FO_opened() */
- H5E_clear();
-
- /* Open the datatype object */
- if ((dt=H5T_open_oid(ent, dxpl_id)) ==NULL)
- HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
-
- /* Add the datatype to the list of opened objects in the file */
- if(H5FO_insert(dt->ent.file, dt->ent.header, dt->shared)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects")
-
- /* Increment object count for the object in the top file */
- if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
-
- /* Mark any datatypes as being in memory now */
- if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
-
- dt->shared->fo_count=1;
- }
- else
- {
- if(NULL == (dt = H5FL_MALLOC(H5T_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
-
- /* Shallow copy (take ownership) of the group entry object */
- if(H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW)<0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy group entry")
-
- dt->shared=shared_fo;
-
- shared_fo->fo_count++;
-
- /* Check if the object has been opened through the top file yet */
- if(H5FO_top_count(dt->ent.file, dt->ent.header) == 0) {
- /* Open the object through this top file */
- if(H5O_open(&(dt->ent)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header")
- } /* end if */
-
- /* Increment object count for the object in the top file */
- if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
- }
-
- ret_value = dt;
-
-done:
- if(ret_value==NULL) {
- if(dt) {
- if(shared_fo==NULL) /* Need to free shared fo */
- H5FL_FREE(H5T_shared_t, dt->shared);
- H5FL_FREE(H5T_t, dt);
- }
- if(shared_fo)
- shared_fo->fo_count--;
- }
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5T_open_oid
- *
- * Purpose: Open a named data type.
- *
- * Return: Success: Ptr to a new data type.
- *
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Wednesday, March 17, 1999
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-H5T_t *
-H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id)
-{
- H5T_t *dt=NULL;
- H5T_t *ret_value;
-
- FUNC_ENTER_NOAPI(H5T_open_oid, NULL);
-
- assert (ent);
-
- if (H5O_open (ent)<0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type");
- if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, NULL, dxpl_id)))
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header");
-
- /* Mark the type as named and open */
- dt->shared->state = H5T_STATE_OPEN;
-
- /* Shallow copy (take ownership) of the group entry object */
- H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW);
-
- /* Set return value */
- ret_value=dt;
-
-done:
- if(ret_value==NULL) {
- if(dt==NULL)
- H5O_close(ent);
- } /* end if */
-
- FUNC_LEAVE_NOAPI(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5T_copy
*
* Purpose: Copies datatype OLD_DT. The resulting data type is not
diff --git a/src/H5Tarray.c b/src/H5Tarray.c
index 5a63011..71c80b8 100644
--- a/src/H5Tarray.c
+++ b/src/H5Tarray.c
@@ -25,14 +25,9 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
#include "H5Iprivate.h" /* IDs */
#include "H5Tpkg.h" /* Datatypes */
-/* Declare extern the free list for H5T_t's */
-H5FL_EXTERN(H5T_t);
-H5FL_EXTERN(H5T_shared_t);
-
/*--------------------------------------------------------------------------
NAME
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index abe9a88..b9d6a28 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -32,6 +32,7 @@
/* Static local functions */
static herr_t H5T_commit(H5G_entry_t *loc, const char *name, H5T_t *type, hid_t dxpl_id);
+static H5T_t *H5T_open_oid(H5G_entry_t *ent, hid_t dxpl_id);
/*--------------------------------------------------------------------------
@@ -290,3 +291,214 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_link() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5Topen
+ *
+ * Purpose: Opens a named data type.
+ *
+ * Return: Success: Object ID of the named data type.
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 1, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Topen(hid_t loc_id, const char *name)
+{
+ H5T_t *type = NULL;
+ H5G_entry_t *loc = NULL;
+ H5G_entry_t ent;
+ hbool_t ent_found = FALSE; /* Entry at 'name' found */
+ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
+ hid_t ret_value =FAIL;
+
+ FUNC_ENTER_API(H5Topen, FAIL);
+ H5TRACE2("i","is",loc_id,name);
+
+ /* Check args */
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+
+ /*
+ * Find the named data type object header and read the data type message
+ * from it.
+ */
+ if (H5G_find (loc, name, &ent/*out*/, dxpl_id)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found");
+ ent_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if (H5G_get_type(&ent, dxpl_id) != H5G_TYPE)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a named datatype")
+
+ /* Open it */
+ if ((type=H5T_open (&ent, dxpl_id)) ==NULL)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type");
+
+ /* Register the type and return the ID */
+ if ((ret_value=H5I_register (H5I_DATATYPE, type))<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type");
+
+done:
+ if(ret_value<0) {
+ if(type!=NULL)
+ H5T_close(type);
+ else {
+ if(ent_found && ent.header)
+ H5G_free_ent_name(&ent);
+ } /* end else */
+ } /* end if */
+
+ FUNC_LEAVE_API(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_open
+ *
+ * Purpose: Open a named data type.
+ *
+ * Return: Success: Ptr to a new data type.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Monday, June 1, 1998
+ *
+ * Modifications:
+ * Changed to use H5T_open_oid - QAK - 3/17/99
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t*
+H5T_open (H5G_entry_t *ent, hid_t dxpl_id)
+{
+ H5T_shared_t *shared_fo=NULL;
+ H5T_t *dt=NULL;
+ H5T_t *ret_value;
+
+ FUNC_ENTER_NOAPI(H5T_open, NULL);
+
+ assert (ent);
+
+ /* Check if datatype was already open */
+ if((shared_fo=H5FO_opened(ent->file,ent->header))==NULL) {
+ /* Clear any errors from H5FO_opened() */
+ H5E_clear();
+
+ /* Open the datatype object */
+ if ((dt=H5T_open_oid(ent, dxpl_id)) ==NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
+
+ /* Add the datatype to the list of opened objects in the file */
+ if(H5FO_insert(dt->ent.file, dt->ent.header, dt->shared)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, NULL, "can't insert datatype into list of open objects")
+
+ /* Increment object count for the object in the top file */
+ if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
+
+ /* Mark any datatypes as being in memory now */
+ if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
+
+ dt->shared->fo_count=1;
+ }
+ else
+ {
+ if(NULL == (dt = H5FL_MALLOC(H5T_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype")
+
+ /* Shallow copy (take ownership) of the group entry object */
+ if(H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy group entry")
+
+ dt->shared=shared_fo;
+
+ shared_fo->fo_count++;
+
+ /* Check if the object has been opened through the top file yet */
+ if(H5FO_top_count(dt->ent.file, dt->ent.header) == 0) {
+ /* Open the object through this top file */
+ if(H5O_open(&(dt->ent)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open object header")
+ } /* end if */
+
+ /* Increment object count for the object in the top file */
+ if(H5FO_top_incr(dt->ent.file, dt->ent.header) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, NULL, "can't increment object count")
+ }
+
+ ret_value = dt;
+
+done:
+ if(ret_value==NULL) {
+ if(dt) {
+ if(shared_fo==NULL) /* Need to free shared fo */
+ H5FL_FREE(H5T_shared_t, dt->shared);
+ H5FL_FREE(H5T_t, dt);
+ }
+ if(shared_fo)
+ shared_fo->fo_count--;
+ }
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_open_oid
+ *
+ * Purpose: Open a named data type.
+ *
+ * Return: Success: Ptr to a new data type.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, March 17, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_open_oid (H5G_entry_t *ent, hid_t dxpl_id)
+{
+ H5T_t *dt=NULL;
+ H5T_t *ret_value;
+
+ FUNC_ENTER_NOAPI(H5T_open_oid, NULL);
+
+ assert (ent);
+
+ if (H5O_open (ent)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type");
+ if (NULL==(dt=H5O_read (ent, H5O_DTYPE_ID, 0, NULL, dxpl_id)))
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header");
+
+ /* Mark the type as named and open */
+ dt->shared->state = H5T_STATE_OPEN;
+
+ /* Shallow copy (take ownership) of the group entry object */
+ H5G_ent_copy(&(dt->ent),ent,H5G_COPY_SHALLOW);
+
+ /* Set return value */
+ ret_value=dt;
+
+done:
+ if(ret_value==NULL) {
+ if(dt==NULL)
+ H5O_close(ent);
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 907ea03..76c4929 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -22,6 +22,7 @@
#include "H5private.h" /*generic functions */
#include "H5Eprivate.h" /*error handling */
#include "H5FLprivate.h" /*Free Lists */
+#include "H5HGprivate.h" /* Global Heaps */
#include "H5Iprivate.h" /*ID functions */
#include "H5MMprivate.h" /*memory management */
#include "H5Pprivate.h" /* Property Lists */
diff --git a/src/H5Tenum.c b/src/H5Tenum.c
index be80563..6d45e57 100644
--- a/src/H5Tenum.c
+++ b/src/H5Tenum.c
@@ -25,15 +25,10 @@
#include "H5private.h" /*generic functions */
#include "H5Eprivate.h" /*error handling */
-#include "H5FLprivate.h" /*Free Lists */
#include "H5Iprivate.h" /*ID functions */
#include "H5MMprivate.h" /*memory management */
#include "H5Tpkg.h" /*data-type functions */
-/* Declare extern the free lists for H5T_t's and H5T_shared_t's */
-H5FL_EXTERN(H5T_t);
-H5FL_EXTERN(H5T_shared_t);
-
/* Static local functions */
static char *H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/,
size_t size);
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 5f213e3..ff36da1 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -39,6 +39,7 @@
/* Other private headers needed by this file */
#include "H5Fprivate.h" /* Files */
+#include "H5FLprivate.h" /* Free Lists */
/* Other public headers needed by this file */
#include "H5Spublic.h" /* Dataspace functions */
@@ -323,6 +324,10 @@ H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g;
H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g;
H5_DLLVAR double H5T_NATIVE_DOUBLE_NEG_INF_g;
+/* Declare extern the free list for H5T_t's and H5T_shared_t's */
+H5FL_EXTERN(H5T_t);
+H5FL_EXTERN(H5T_shared_t);
+
/* Common functions */
H5_DLL H5T_t *H5T_create(H5T_class_t type, size_t size);
H5_DLL H5T_t *H5T_alloc(void);
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index f39c396..40d94b7 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -61,7 +61,6 @@ typedef struct {
H5_DLL herr_t H5TN_init_interface(void);
H5_DLL herr_t H5T_init(void);
H5_DLL htri_t H5T_isa(H5G_entry_t *ent, hid_t dxpl_id);
-H5_DLL H5T_t *H5T_open(H5G_entry_t *ent, hid_t dxpl_id);
H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method);
H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable);
H5_DLL herr_t H5T_close(H5T_t *dt);
@@ -85,10 +84,13 @@ H5_DLL herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned ndim, const h
H5_DLL herr_t H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info);
H5_DLL htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc);
H5_DLL htri_t H5T_is_sensible(const H5T_t *dt);
-H5_DLL htri_t H5T_committed(const H5T_t *type);
-H5_DLL int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id);
/* Reference specific functions */
H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt);
+/* Operations on named datatypes */
+H5_DLL H5T_t *H5T_open(H5G_entry_t *ent, hid_t dxpl_id);
+H5_DLL htri_t H5T_committed(const H5T_t *type);
+H5_DLL int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id);
+
#endif
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index 423a004..837adf7 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -26,7 +26,6 @@
#include "H5private.h" /* Generic Functions */
#include "H5Dprivate.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
#include "H5HGprivate.h" /* Global Heaps */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
@@ -65,10 +64,6 @@ static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={
H5D_XFER_VLEN_FREE_INFO_DEF
};
-/* Declare extern the free lists for H5T_t's and H5T_shared_t's */
-H5FL_EXTERN(H5T_t);
-H5FL_EXTERN(H5T_shared_t);
-
/*--------------------------------------------------------------------------
NAME
diff --git a/src/Makefile.in b/src/Makefile.in
index 1747657..3da5c1b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -38,7 +38,7 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5Bcache.c H5C.c H5D.c H5Dcontig.c \
H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDsrb.c H5FDstdio.c \
H5FDstream.c H5FL.c H5FO.c H5FS.c H5G.c H5Gent.c H5Gnode.c H5Gstab.c \
H5HG.c H5HGdbg.c H5HL.c H5HLdbg.c H5HP.c H5I.c H5MF.c H5MM.c H5O.c \
- H5Oattr.c H5Obogus.c \
+ H5Oattr.c H5Obogus.c H5Ocache.c \
H5Ocont.c H5Odtype.c H5Oefl.c H5Ofill.c H5Olayout.c H5Omtime.c \
H5Oname.c H5Onull.c H5Opline.c H5Osdspace.c H5Oshared.c H5Ostab.c \
H5P.c H5Pdcpl.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Ptest.c H5R.c H5RC.c \
diff --git a/test/group_new.h5 b/test/group_new.h5
new file mode 100644
index 0000000..1e17ed6
--- /dev/null
+++ b/test/group_new.h5
Binary files differ
diff --git a/test/links.c b/test/links.c
index df6fa1f..d819a5d 100644
--- a/test/links.c
+++ b/test/links.c
@@ -32,6 +32,12 @@ const char *FILENAME[] = {
#define NAME_BUF_SIZE 1024
#define MAX_NAME_LEN ((64*1024)+1024)
+/* The group_new.h5 is generated from gen_new_fill.c in HDF5 'test' directory
+ * for version 1.7 (after "compact group" checkin). To get this data file,
+ * simply compile gen_new_group.c with HDF5 library (after compact group
+ * checkin) and run it. */
+#define FILE_NEW_GROUPS "group_new.h5"
+
/*-------------------------------------------------------------------------
* Function: mklinks
diff --git a/test/stab.c b/test/stab.c
index 947825c..df22bf7 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -30,6 +30,12 @@ const char *FILENAME[] = {
NULL
};
+/* The group_new.h5 is generated from gen_new_fill.c in HDF5 'test' directory
+ * for version 1.7 (after "compact group" checkin). To get this data file,
+ * simply compile gen_new_group.c with HDF5 library (after compact group
+ * checkin) and run it. */
+#define FILE_NEW_GROUPS "group_new.h5"
+
/*-------------------------------------------------------------------------
* Function: test_misc
@@ -214,6 +220,71 @@ test_large(hid_t file)
/*-------------------------------------------------------------------------
+ * Function: read_new
+ *
+ * Purpose: Test reading a file with "new style" (compact) groups
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Quincey Koziol
+ * Monday, October 24, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+read_new(hid_t fapl)
+{
+ hid_t fid = (-1); /* File ID */
+ hid_t gid = (-1); /* Group ID */
+ char *srcdir = HDgetenv("srcdir"); /*where the src code is located*/
+ char filename[512]=""; /* test file name */
+
+ TESTING("reading new groups");
+
+ /* Generate correct name for test file by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_NEW_GROUPS) + 1) < sizeof(filename))) {
+ HDstrcpy(filename, srcdir);
+ HDstrcat(filename, "/");
+ }
+ HDstrcat(filename, FILE_NEW_GROUPS);
+
+ /* Open file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* Attempt to open root group */
+ if((gid = H5Gopen(fid, "/")) < 0) TEST_ERROR;
+
+ /* Attempt to open new "empty" group (should fail) */
+ H5E_BEGIN_TRY {
+ if(H5Gopen(gid, "empty") >= 0) TEST_ERROR;
+ } H5E_END_TRY;
+
+ /* Attempt to open new group with link messages (should fail) */
+ H5E_BEGIN_TRY {
+ if(H5Gopen(gid, "links") >= 0) TEST_ERROR;
+ } H5E_END_TRY;
+
+ /* Close root group */
+ if(H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* Close first file */
+ if(H5Fclose(fid)<0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* end read_new() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test groups
@@ -258,6 +329,7 @@ main(void)
nerrors += test_misc(file);
nerrors += test_long(file);
nerrors += test_large(file);
+ nerrors += read_new(fapl);
if (nerrors) goto error;
/* Cleanup */