summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-12-04 02:29:06 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-12-04 02:29:06 (GMT)
commitfcd8d9b878071ea0e1d834e1e2a192cfec90586f (patch)
tree8ddb35ce78c1046839bc38e58c728397e2c5a781 /src
parent4dd379f637a411eb1ae564dc9f993b556d9a65e3 (diff)
downloadhdf5-fcd8d9b878071ea0e1d834e1e2a192cfec90586f.zip
hdf5-fcd8d9b878071ea0e1d834e1e2a192cfec90586f.tar.gz
hdf5-fcd8d9b878071ea0e1d834e1e2a192cfec90586f.tar.bz2
[svn-r11759] Purpose:
New feature Description: Add in a combination of Peter's & my code to support copying variable-length data from one file to another, although currently only supported with contiguous data storage. Platforms tested: FreeBSD 4.11 (sleipnir) h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5.c1
-rw-r--r--src/H5D.c346
-rw-r--r--src/H5Dcontig.c52
-rw-r--r--src/H5Dpkg.h6
-rw-r--r--src/H5Dprivate.h15
-rw-r--r--src/H5G.c662
-rw-r--r--src/H5Gprivate.h5
-rw-r--r--src/H5Gpublic.h1
-rw-r--r--src/H5O.c1308
-rw-r--r--src/H5Oattr.c28
-rw-r--r--src/H5Obogus.c4
-rw-r--r--src/H5Ocache.c321
-rw-r--r--src/H5Ocont.c50
-rw-r--r--src/H5Odtype.c40
-rw-r--r--src/H5Oefl.c5
-rw-r--r--src/H5Ofill.c8
-rw-r--r--src/H5Olayout.c7
-rw-r--r--src/H5Omtime.c8
-rw-r--r--src/H5Oname.c4
-rw-r--r--src/H5Onull.c5
-rw-r--r--src/H5Opkg.h131
-rw-r--r--src/H5Opline.c4
-rw-r--r--src/H5Oprivate.h6
-rw-r--r--src/H5Osdspace.c16
-rw-r--r--src/H5Oshared.c107
-rw-r--r--src/H5Ostab.c14
-rw-r--r--src/H5T.c77
-rw-r--r--src/H5Tprivate.h2
-rw-r--r--src/H5private.h2
29 files changed, 1560 insertions, 1675 deletions
diff --git a/src/H5.c b/src/H5.c
index 076f50a..d381e0c 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -14,6 +14,7 @@
#define H5I_PACKAGE /*suppress error about including H5Ipkg */
+
#include "H5private.h" /* Generic Functions */
#include "H5Bprivate.h" /* B-link trees */
#include "H5Dprivate.h" /* Datasets */
diff --git a/src/H5D.c b/src/H5D.c
index afc66ff..13d3256 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -64,10 +64,12 @@ 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 herr_t H5D_open_oid(H5D_t *dset, hid_t dxpl_id);
+static herr_t H5D_open_oid(H5D_t *dataset, 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);
+static herr_t H5D_iterate(void *buf, hid_t type_id, H5S_t *space,
+ H5D_operator_t op, void *operator_data);
static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type);
@@ -1089,7 +1091,7 @@ H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
/* Register the new dataset to get an ID for it */
- if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0)
+ if((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
done:
@@ -1136,7 +1138,7 @@ H5Dopen(hid_t loc_id, const char *name)
/* Check args */
if (NULL == (loc = H5G_loc(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if (!name || !*name)
+ if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
/* Find the dataset object */
@@ -1168,7 +1170,7 @@ done:
} /* end else */
} /* end if */
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Dopen() */
/*-------------------------------------------------------------------------
@@ -1189,13 +1191,13 @@ herr_t
H5Dclose(hid_t dset_id)
{
H5D_t *dset = NULL; /* Dataset object to release */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Dclose, FAIL)
H5TRACE1("e","i",dset_id);
/* Check args */
- if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET)))
+ if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if (NULL == dset->ent.file)
HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
@@ -1204,12 +1206,12 @@ H5Dclose(hid_t dset_id)
* Decrement the counter on the dataset. It will be freed if the count
* reaches zero.
*/
- if (H5I_dec_ref(dset_id) < 0)
+ if(H5I_dec_ref(dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free")
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Dclose() */
/*-------------------------------------------------------------------------
@@ -1365,9 +1367,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Dget_type
*
- * Purpose: Returns a copy of the file data type for a dataset.
+ * Purpose: Returns a copy of the file datatype for a dataset.
*
- * Return: Success: ID for a copy of the data type. The data
+ * Return: Success: ID for a copy of the datatype. The data
* type should be released by calling
* H5Tclose().
*
@@ -1393,21 +1395,21 @@ H5Dget_type(hid_t dset_id)
if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- /* Copy the data type and mark it read-only */
+ /* Copy the datatype and mark it read-only */
if (NULL==(copied_type=H5T_copy (dset->shared->type, H5T_COPY_REOPEN)))
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type")
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the datatype")
/* Mark any VL datatypes as being in memory now */
if (H5T_vlen_mark(copied_type, NULL, H5T_VLEN_MEMORY)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location")
/* Unlock copied type */
if (H5T_lock (copied_type, FALSE)<0)
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type")
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype")
/* Create an atom */
if ((ret_value=H5I_register (H5I_DATATYPE, copied_type))<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type")
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
done:
if(ret_value<0) {
@@ -1469,7 +1471,7 @@ H5Dget_create_plist(hid_t dset_id)
/* Copy the dataset type into the fill value message */
if(copied_fill.type==NULL)
if(NULL==(copied_fill.type=H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset datatype for fill value")
/* Set back the fill value property to property list */
if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0)
@@ -1697,19 +1699,19 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p
FUNC_ENTER_NOAPI(H5D_update_entry_info, FAIL)
/* Sanity checking */
- assert(file);
- assert(dset);
+ HDassert(file);
+ HDassert(dset);
/* Pick up former parameters */
ent=&dset->ent;
- layout=&dset->shared->layout;
- type=dset->shared->type;
- space=dset->shared->space;
- alloc_time=dset->shared->alloc_time;
- efl=&dset->shared->efl;
+ layout = &dset->shared->layout;
+ type = dset->shared->type;
+ space = dset->shared->space;
+ alloc_time = dset->shared->alloc_time;
+ efl = &dset->shared->efl;
/* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */
- if (layout->type == H5D_COMPACT)
+ if(layout->type == H5D_COMPACT)
ohdr_size += layout->u.compact.size;
/* Create (open for write access) an object header */
@@ -1721,21 +1723,21 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header")
/* Point at dataset's copy, to cache it for later */
- fill_prop=&dset->shared->fill;
- fill_time=dset->shared->fill_time;
+ fill_prop = &dset->shared->fill;
+ fill_time = dset->shared->fill_time;
/* Check if dataset has non-default creation property list */
- if(dset->shared->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) {
+ if(dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) {
/*
* Retrieve properties of fill value and others. Copy them into new fill
* value struct.
*/
- if (H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
+ if(H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time")
dset->shared->fill_time=fill_time; /* Cache this for later */
/* Get the fill value information from the property list */
- if (H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0)
+ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value")
} /* end if */
@@ -1864,9 +1866,9 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p
#ifdef H5O_ENABLE_BOGUS
/*
- * Add a "bogus" message.
+ * Add a "bogus" message (for error testing).
*/
- if (H5O_bogus_oh(file, dxpl_id, oh))<0)
+ if(H5O_bogus_oh(file, dxpl_id, oh)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update 'bogus' message")
#endif /* H5O_ENABLE_BOGUS */
@@ -1926,12 +1928,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
FUNC_ENTER_NOAPI(H5D_create, NULL)
/* check args */
- assert (loc);
- assert (name && *name);
- assert (H5I_DATATYPE==H5I_get_type(type_id));
- assert (space);
- assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id));
- assert (H5I_GENPROP_LST==H5I_get_type(dxpl_id));
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(H5I_DATATYPE==H5I_get_type(type_id));
+ HDassert(space);
+ HDassert(H5I_GENPROP_LST==H5I_get_type(dcpl_id));
+ HDassert(H5I_GENPROP_LST==H5I_get_type(dxpl_id));
/* Get the dataset's datatype */
if (NULL == (type = H5I_object(type_id)))
@@ -1960,7 +1962,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* What file is the dataset being added to? */
- if(NULL==(file=H5G_insertion_file(loc, name, dxpl_id)))
+ if(NULL == (file = H5G_insertion_file(loc, name, dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point")
/* Copy datatype for dataset */
@@ -2093,7 +2095,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
H5_ASSIGN_OVERFLOW(new_dset->shared->layout.u.contig.size,tmp_size,hssize_t,hsize_t);
/* Get the sieve buffer size for this dataset */
- new_dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(loc->file);
+ new_dset->shared->cache.contig.sieve_buf_size = H5F_SIEVE_BUF_SIZE(file);
} /* end case */
break;
@@ -2200,24 +2202,24 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
if(H5FO_insert(new_dset->ent.file,new_dset->ent.header,new_dset->shared)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, NULL, "can't insert dataset into list of open objects")
- new_dset->shared->fo_count=1;
+ new_dset->shared->fo_count = 1;
/* Success */
ret_value = new_dset;
done:
- if (!ret_value && new_dset && new_dset->shared) {
- if( new_dset->shared) {
- if(new_dset->shared->layout.type==H5D_CHUNKED && chunk_init) {
- if(H5D_istore_dest(new_dset,H5AC_dxpl_id)<0)
+ if(!ret_value && new_dset && new_dset->shared) {
+ if(new_dset->shared) {
+ if(new_dset->shared->layout.type == H5D_CHUNKED && chunk_init) {
+ if(H5D_istore_dest(new_dset,H5AC_dxpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy chunk cache")
} /* end if */
- if (new_dset->shared->space) {
- if(H5S_close(new_dset->shared->space)<0)
+ if(new_dset->shared->space) {
+ if(H5S_close(new_dset->shared->space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
} /* end if */
- if (new_dset->shared->type) {
- if(H5I_dec_ref(new_dset->shared->type_id)<0)
+ if(new_dset->shared->type) {
+ if(H5I_dec_ref(new_dset->shared->type_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
if (H5F_addr_defined(new_dset->ent.header)) {
@@ -2228,11 +2230,11 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header")
} /* end if */
} /* end if */
- if(new_dset->shared->dcpl_id!=0) {
- if(H5I_dec_ref(new_dset->shared->dcpl_id)<0)
+ if(new_dset->shared->dcpl_id != 0) {
+ if(H5I_dec_ref(new_dset->shared->dcpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list")
} /* end if */
- H5FL_FREE(H5D_shared_t,new_dset->shared);
+ H5FL_FREE(H5D_shared_t, new_dset->shared);
} /* end if */
new_dset->ent.file = NULL;
H5FL_FREE(H5D_t, new_dset);
@@ -2307,14 +2309,14 @@ done:
H5D_t*
H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
{
- H5D_shared_t *shared_fo=NULL;
- H5D_t *dataset=NULL;
+ H5D_shared_t *shared_fo = NULL;
+ H5D_t *dataset = NULL;
H5D_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5D_open, NULL)
/* check args */
- assert (ent);
+ HDassert(ent);
/* Allocate the dataset structure */
if(NULL == (dataset = H5FL_CALLOC(H5D_t)))
@@ -2330,7 +2332,7 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
H5E_clear();
/* Open the dataset object */
- if (H5D_open_oid(dataset, dxpl_id) < 0)
+ 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 */
@@ -2346,7 +2348,7 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
} /* end if */
else {
/* Point to shared info */
- dataset->shared=shared_fo;
+ dataset->shared = shared_fo;
/* Increment # of datasets using shared information */
shared_fo->fo_count++;
@@ -2366,9 +2368,9 @@ H5D_open(const H5G_entry_t *ent, hid_t dxpl_id)
ret_value = dataset;
done:
- if(ret_value==NULL) {
+ if(ret_value == NULL) {
if(dataset) {
- if(shared_fo==NULL) /* Need to free shared fo */
+ if(shared_fo == NULL) /* Need to free shared fo */
H5FL_FREE(H5D_shared_t, dataset->shared);
H5FL_FREE(H5D_t, dataset);
}
@@ -2377,7 +2379,7 @@ done:
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5D_open() */
/*-------------------------------------------------------------------------
@@ -2400,19 +2402,19 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
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 */
- herr_t ret_value = SUCCEED; /*return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_open_oid, FAIL)
/* check args */
- assert (dataset);
+ HDassert(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, FAIL, "memory allocation failed")
- /* Find the dataset object */
- if (H5O_open(&(dataset->ent)) < 0)
+ /* Open the dataset object */
+ if(H5O_open(&(dataset->ent)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open")
/* Get the type and space */
@@ -2426,14 +2428,14 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
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)))
+ if(NULL == (plist = H5I_object(dataset->shared->dcpl_id)))
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)) {
H5E_clear();
HDmemset(&pline, 0, sizeof(pline));
- }
+ } /* end if */
if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set pipeline")
@@ -2473,7 +2475,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
/*
* Chunked storage. The creation plist's dimension is one less than
* the chunk dimension because the chunk includes a dimension for the
- * individual bytes of the data type.
+ * individual bytes of the datatype.
*/
{
unsigned chunk_ndims; /* Dimensionality of chunk */
@@ -2487,7 +2489,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
/* Initialize the chunk cache for the dataset */
if(H5D_istore_init(dataset->ent.file,dataset)<0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "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 */
@@ -2549,11 +2551,11 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
if(NULL == H5O_read(&(dataset->ent), H5O_FILL_ID, 0, fill_prop, dxpl_id)) {
H5E_clear();
HDmemset(fill_prop, 0, sizeof(H5O_fill_t));
- }
+ } /* end if */
if(fill_prop->size == 0) {
fill_prop->type = fill_prop->buf = NULL;
fill_prop->size = (size_t)-1;
- }
+ } /* end if */
} /* end else */
alloc_time_state=0;
if( (dataset->shared->layout.type==H5D_COMPACT && fill.alloc_time==H5D_ALLOC_TIME_EARLY)
@@ -2599,28 +2601,28 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id)
&& 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, FAIL, "unable to initialize file storage")
- }
+ } /* end if */
/* Get the dataset's DCPL cache info */
- if (H5D_get_dcpl_cache(dataset->shared->dcpl_id,&dataset->shared->dcpl_cache)<0)
+ if(H5D_get_dcpl_cache(dataset->shared->dcpl_id,&dataset->shared->dcpl_cache)<0)
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)
+ if(H5O_reset(H5O_FILL_ID, &fill) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release fill-value info")
- if (ret_value < 0 && dataset) {
- if (H5F_addr_defined(dataset->ent.header)) {
+ if(ret_value < 0 && dataset) {
+ if(H5F_addr_defined(dataset->ent.header)) {
if(H5O_close(&(dataset->ent))<0)
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)
+ if(dataset->shared->space) {
+ if(H5S_close(dataset->shared->space) < 0)
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)
+ if(dataset->shared->type) {
+ if(H5I_dec_ref(dataset->shared->type_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
dataset->ent.file = NULL;
@@ -2727,7 +2729,7 @@ H5D_close(H5D_t *dataset)
/* Close the dataset object */
/* (This closes the file, if this is the last object open) */
if(H5O_close(&(dataset->ent))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header");
+ HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
/*
* Free memory. Before freeing the memory set the file pointer to NULL.
@@ -2798,12 +2800,12 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
if(! dataset->shared->checked_filters)
{
if(H5P_is_fill_value_defined(&(dataset->shared->fill), &fill_status) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.")
if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED)
{
if( H5Pget_fill_time(dataset->shared->dcpl_id, &fill_time) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset.");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset.")
if(fill_time == H5D_FILL_TIME_ALLOC ||
(fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) )
@@ -2830,8 +2832,8 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
if (changed>0){
/* Save the new dataspace in the file if necessary */
- if (H5S_modify (&(dataset->ent), space, TRUE, dxpl_id)<0)
- HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
+ if(H5S_modify (&(dataset->ent), space, TRUE, dxpl_id)<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
/* Update the index values for the cached chunks for this dataset */
if(H5D_CHUNKED == dataset->shared->layout.type)
@@ -2876,10 +2878,10 @@ H5D_entof (H5D_t *dataset)
/*-------------------------------------------------------------------------
* Function: H5D_typeof
*
- * Purpose: Returns a pointer to the dataset's data type. The data type
+ * Purpose: Returns a pointer to the dataset's datatype. The datatype
* is not copied.
*
- * Return: Success: Ptr to the dataset's data type, uncopied.
+ * Return: Success: Ptr to the dataset's datatype, uncopied.
*
* Failure: NULL
*
@@ -2921,11 +2923,11 @@ H5D_get_file (const H5D_t *dset)
/* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_get_file)
- assert (dset);
- assert (dset->ent.file);
+ HDassert(dset);
+ HDassert(dset->ent.file);
FUNC_LEAVE_NOAPI(dset->ent.file)
-}
+} /* end H5D_get_file() */
/*-------------------------------------------------------------------------
@@ -3061,9 +3063,9 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo
/* Also update header message for layout with new address, if we
* set the address. (this is improves forward compatibility).
*/
- if(time_alloc!=H5D_ALLOC_CREATE && addr_set)
- if (H5O_modify (&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0)
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message")
+ if(time_alloc != H5D_ALLOC_CREATE && addr_set)
+ if(H5O_modify(&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->shared->layout), dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message")
} /* end if */
done:
@@ -3399,18 +3401,18 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op,
H5TRACE5("e","xiixx",buf,type_id,space_id,op,operator_data);
/* Check args */
- if (NULL==op)
+ if(NULL==op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator")
- if (buf==NULL)
+ if(buf==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer")
- if (H5I_DATATYPE != H5I_get_type(type_id))
+ if(H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype")
- if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
+ if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
- if( !(H5S_has_extent(space)) )
+ if(!(H5S_has_extent(space)) )
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
- ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data);
+ ret_value = H5D_iterate(buf, type_id, space, op, operator_data);
done:
FUNC_LEAVE_API(ret_value)
@@ -3418,6 +3420,41 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D_iterate
+ *
+ * Purpose: Internal version of H5Diterate()
+ *
+ * Return: Returns the return value of the last operator if it was non-zero,
+ * or zero if all elements were processed. Otherwise returns a
+ * negative value.
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 22, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5D_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op,
+ void *operator_data)
+{
+ herr_t ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_iterate)
+
+ /* Check args */
+ HDassert(buf);
+ HDassert(H5I_DATATYPE == H5I_get_type(type_id));
+ HDassert(space);
+ HDassert(H5S_has_extent(space));
+ HDassert(op);
+
+ ret_value = H5S_select_iterate(buf, type_id, space, op, operator_data);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_iterate() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Dvlen_reclaim
*
* Purpose: Frees the buffers allocated for storing variable-length data
@@ -3435,35 +3472,75 @@ done:
herr_t
H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf)
{
- H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */
- H5T_vlen_alloc_info_t *vl_alloc_info=&_vl_alloc_info; /* VL allocation info */
+ H5S_t *space = NULL;
herr_t ret_value;
FUNC_ENTER_API(H5Dvlen_reclaim, FAIL)
H5TRACE4("e","iiix",type_id,space_id,plist_id,buf);
/* Check args */
- if (H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) ||
- buf==NULL)
+ if (H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
+ if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
+ if(!(H5S_has_extent(space)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
/* Get the default dataset transfer property list if the user didn't provide one */
- if (H5P_DEFAULT == plist_id)
- plist_id= H5P_DATASET_XFER_DEFAULT;
+ if(H5P_DEFAULT == plist_id)
+ plist_id = H5P_DATASET_XFER_DEFAULT;
else
- if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER))
+ if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+ /* Call internal routine */
+ ret_value = H5D_vlen_reclaim(type_id, space, plist_id, buf);
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Dvlen_reclaim() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_vlen_reclaim
+ *
+ * Purpose: Frees the buffers allocated for storing variable-length data
+ * in memory. Only frees the VL data in the selection defined in the
+ * dataspace. The dataset transfer property list is required to find the
+ * correct allocation/free methods for the VL data in the buffer.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 22, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, void *buf)
+{
+ H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */
+ H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */
+ herr_t ret_value;
+
+ FUNC_ENTER_NOAPI(H5D_vlen_reclaim, FAIL)
+
+ /* Check args */
+ HDassert(H5I_DATATYPE == H5I_get_type(type_id));
+ HDassert(space);
+ HDassert(H5P_isa_class(plist_id, H5P_DATASET_XFER));
+ HDassert(buf);
+
/* Get the allocation info */
if(H5T_vlen_get_alloc_info(plist_id,&vl_alloc_info)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info")
- /* Call H5Diterate with args, etc. */
- ret_value=H5Diterate(buf,type_id,space_id,H5T_vlen_reclaim,vl_alloc_info);
+ /* Call H5D_iterate with args, etc. */
+ ret_value = H5D_iterate(buf, type_id, space ,H5T_vlen_reclaim, vl_alloc_info);
done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Dvlen_reclaim() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_vlen_reclaim() */
/*-------------------------------------------------------------------------
@@ -3530,29 +3607,29 @@ done:
static herr_t
H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t *point, void *op_data)
{
- H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)op_data;
+ H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)op_data;
H5T_t *dt = NULL;
- herr_t ret_value=0; /* The correct return value, if this function succeeds */
+ herr_t ret_value = 0; /* The correct return value, if this function succeeds */
FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size, FAIL)
- assert(op_data);
- assert(H5I_DATATYPE == H5I_get_type(type_id));
+ HDassert(op_data);
+ HDassert(H5I_DATATYPE == H5I_get_type(type_id));
/* Check args */
- if (NULL==(dt=H5I_object(type_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
+ if(NULL == (dt = H5I_object(type_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Make certain there is enough fixed-length buffer available */
- if ((vlen_bufsize->fl_tbuf=H5FL_BLK_REALLOC(vlen_fl_buf,vlen_bufsize->fl_tbuf,H5T_get_size(dt)))==NULL)
+ if((vlen_bufsize->fl_tbuf=H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->fl_tbuf, H5T_get_size(dt))) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf")
/* Select point to read in */
- if (H5Sselect_elements(vlen_bufsize->fspace_id,H5S_SELECT_SET,1,(const hsize_t **)point)<0)
+ if(H5Sselect_elements(vlen_bufsize->fspace_id, H5S_SELECT_SET, 1, (const hsize_t **)point)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point")
/* Read in the point (with the custom VL memory allocator) */
- if(H5Dread(vlen_bufsize->dataset_id,type_id,vlen_bufsize->mspace_id,vlen_bufsize->fspace_id,vlen_bufsize->xfer_pid,vlen_bufsize->fl_tbuf)<0)
+ if(H5Dread(vlen_bufsize->dataset_id, type_id, vlen_bufsize->mspace_id, vlen_bufsize->fspace_id, vlen_bufsize->xfer_pid, vlen_bufsize->fl_tbuf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point")
done:
@@ -3590,6 +3667,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
{
H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0};
char bogus; /* bogus value to pass to H5Diterate() */
+ H5S_t *space = NULL;
H5P_genclass_t *pclass; /* Property class */
H5P_genplist_t *plist; /* Property list */
herr_t ret_value=FAIL;
@@ -3598,10 +3676,13 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
H5TRACE4("e","iii*h",dataset_id,type_id,space_id,size);
/* Check args */
- if (H5I_DATASET!=H5I_get_type(dataset_id) ||
- H5I_DATATYPE!=H5I_get_type(type_id) ||
- H5I_DATASPACE!=H5I_get_type(space_id) || size==NULL)
+ if(H5I_DATASET!=H5I_get_type(dataset_id) ||
+ H5I_DATATYPE!=H5I_get_type(type_id) || size==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument")
+ if(NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
+ if(!(H5S_has_extent(space)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set")
/* Save the dataset ID */
vlen_bufsize.dataset_id=dataset_id;
@@ -3639,8 +3720,8 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
/* Set the initial number of bytes required */
vlen_bufsize.size=0;
- /* Call H5Diterate with args, etc. */
- ret_value=H5Diterate(&bogus,type_id,space_id,H5D_vlen_get_buf_size,&vlen_bufsize);
+ /* Call H5D_iterate with args, etc. */
+ ret_value = H5D_iterate(&bogus, type_id, space, H5D_vlen_get_buf_size, &vlen_bufsize);
/* Get the size if we succeeded */
if(ret_value>=0)
@@ -3677,12 +3758,9 @@ done:
* Return: Success: SUCCEED, Failure: FAIL
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- * Robb Matzke
*
* Date: April 9, 2002
*
- * Comments: Public function, calls private H5D_set_extent
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -3722,8 +3800,6 @@ done:
*
* Date: April 9, 2002
*
- * Comments: Private function
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -3934,23 +4010,23 @@ done:
herr_t
H5Ddebug(hid_t dset_id)
{
- H5D_t *dset=NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ H5D_t *dset = NULL;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Ddebug, FAIL)
H5TRACE1("e","i",dset_id);
/* Check args */
- if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET)))
+ if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
/* Print B-tree information */
- if (H5D_CHUNKED==dset->shared->layout.type) {
+ if(H5D_CHUNKED == dset->shared->layout.type)
(void)H5D_istore_dump_btree(dset->ent.file, H5AC_dxpl_id, stdout, dset->shared->layout.u.chunk.ndims, dset->shared->layout.u.chunk.addr);
- } else if (H5D_CONTIGUOUS==dset->shared->layout.type) {
+ else if(H5D_CONTIGUOUS == dset->shared->layout.type)
HDfprintf(stdout, " %-10s %a\n", "Address:", dset->shared->layout.u.contig.addr);
- }
done:
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Ddebug() */
+
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 2c2539f..b492548 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -22,8 +22,16 @@
* with the data sieve buffer from H5F_seq_read/write.
*/
+/****************/
+/* Module Setup */
+/****************/
+
#define H5D_PACKAGE /*suppress error about including H5Dpkg */
+
+/***********/
+/* Headers */
+/***********/
#include "H5private.h" /* Generic Functions */
#include "H5Dpkg.h" /* Dataset functions */
#include "H5Eprivate.h" /* Error handling */
@@ -36,10 +44,28 @@
#include "H5Sprivate.h" /* Dataspace functions */
#include "H5Vprivate.h" /* Vector and array functions */
-/* Private prototypes */
+/****************/
+/* Local Macros */
+/****************/
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/********************/
+/* Local Prototypes */
+/********************/
static herr_t H5D_contig_write(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache,
hid_t dxpl_id, const H5D_storage_t *store, hsize_t offset, size_t size, const void *buf);
+/*********************/
+/* Package Variables */
+/*********************/
+
+/*******************/
+/* Local Variables */
+/*******************/
+
/* Declare a PQ free list to manage the sieve buffer information */
H5FL_BLK_DEFINE(sieve_buf);
@@ -60,8 +86,6 @@ H5FL_BLK_DEFINE_STATIC(zero_fill);
* Programmer: Quincey Koziol
* April 19, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -94,11 +118,6 @@ done:
* Programmer: Quincey Koziol
* August 22, 2002
*
- * Modifications:
- * Bill Wendling, February 20, 2003
- * Added support for getting the barrier COMM if you're using
- * Flexible PHDF5.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -111,7 +130,7 @@ H5D_contig_fill(H5D_t *dset, hid_t dxpl_id)
size_t npoints; /* Number of points in space */
size_t ptsperbuf; /* Maximum # of points which fit in the buffer */
size_t elmt_size; /* Size of each element */
- size_t bufsize=64*1024; /* Size of buffer to write */
+ size_t bufsize=H5D_XFER_MAX_TEMP_BUF_DEF; /* Size of buffer to write */
size_t size; /* Current # of points to write */
hsize_t offset; /* Offset of dataset */
void *buf = NULL; /* Buffer for fill value writing */
@@ -286,8 +305,6 @@ done:
* Programmer: Quincey Koziol
* March 20, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -320,8 +337,6 @@ done:
* Programmer: Quincey Koziol
* June 2, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
haddr_t
@@ -349,9 +364,6 @@ H5D_contig_get_addr(const H5D_t *dset)
* Programmer: Quincey Koziol
* Thursday, September 28, 2000
*
- * Modifications:
- * Re-written in terms of the new writevv call, QAK, 5/7/03
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -401,8 +413,6 @@ done:
* Notes:
* Offsets in the sequences must be monotonically increasing
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
ssize_t
@@ -668,8 +678,6 @@ done:
* Notes:
* Offsets in the sequences must be monotonically increasing
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
ssize_t
@@ -742,6 +750,10 @@ H5D_contig_writevv(const H5D_io_info_t *io_info,
/* Allocate room for the data sieve buffer */
if (NULL==(dset_contig->sieve_buf=H5FL_BLK_MALLOC(sieve_buf,dset_contig->sieve_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+#ifdef H5_USING_PURIFY
+if(dset_contig->sieve_size > size)
+ HDmemset(dset_contig->sieve_buf + size, 0, (dset_contig->sieve_size - size));
+#endif /* H5_USING_PURIFY */
/* Determine the new sieve buffer size & location */
dset_contig->sieve_loc=addr;
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index e98c2ae..b662cfc 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -197,6 +197,8 @@ extern H5D_dxpl_cache_t H5D_def_dxpl_cache;
H5_DLL herr_t H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset, H5D_time_alloc_t time_alloc,
hbool_t update_time, hbool_t full_overwrite);
+H5_DLL herr_t H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id,
+ void *buf);
/* Functions that perform serial I/O operations */
H5_DLL herr_t H5D_select_fscat (H5D_io_info_t *io_info,
@@ -283,7 +285,8 @@ H5_DLL ssize_t H5D_efl_writevv(const H5D_io_info_t *io_info,
const void *buf);
#ifdef H5_HAVE_PARALLEL
-/* MPI-IO function to read directly from app buffer to file rky980813 */
+
+/* MPI-IO function to read , it will select either regular or irregular read */
H5_DLL herr_t H5D_mpio_select_read(H5D_io_info_t *io_info,
size_t nelmts, size_t elmt_size,
const struct H5S_t *file_space, const struct H5S_t *mem_space,
@@ -332,3 +335,4 @@ H5_DLL herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size);
#endif /* H5D_TESTING */
#endif /*_H5Dpkg_H*/
+
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 0e92641..e35b515 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -25,6 +25,10 @@
#include "H5FDprivate.h" /* File drivers */
#include "H5Oprivate.h" /* Object headers */
+/**************************/
+/* Library Private Macros */
+/**************************/
+
/*
* Feature: Define H5D_DEBUG on the compiler command line if you want to
* debug dataset I/O. NDEBUG must not be defined in order for this
@@ -210,7 +214,13 @@ typedef struct H5D_dcpl_cache_t {
H5D_fill_time_t fill_time; /* Fill time (H5D_CRT_FILL_TIME_NAME) */
} H5D_dcpl_cache_t;
-/* Library-private functions defined in H5D package */
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+/******************************/
+/* Library Private Prototypes */
+/******************************/
H5_DLL herr_t H5D_init(void);
H5_DLL H5D_t *H5D_open(const H5G_entry_t *ent, hid_t dxpl_id);
H5_DLL herr_t H5D_close(H5D_t *dataset);
@@ -238,4 +248,5 @@ H5_DLL herr_t H5D_istore_delete(H5F_t *f, hid_t dxpl_id,
H5_DLL herr_t H5D_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
int indent, int fwidth, unsigned ndims);
-#endif
+#endif /* _H5Dprivate_H */
+
diff --git a/src/H5G.c b/src/H5G.c
index 3727704..1b2b434 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -71,22 +71,11 @@
* +--------------+------------+--------------------------------+
*
*
- * Modifications:
- *
- * Robb Matzke, 5 Aug 1997
- * Added calls to H5E.
- *
- * Robb Matzke, 30 Aug 1997
- * Added `Errors:' field to function prologues.
- *
- * Pedro Vicente, 22 Aug 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
-#define H5G_PACKAGE /*suppress error about including H5Gpkg */
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5G_PACKAGE /*suppress error about including H5Gpkg */
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5G_init_interface
@@ -236,32 +225,32 @@ hid_t
H5Gcreate(hid_t loc_id, const char *name, size_t size_hint)
{
H5G_entry_t *loc = NULL;
- H5G_t *grp = NULL;
- hid_t ret_value;
+ H5G_t *grp = NULL;
+ hid_t ret_value;
- FUNC_ENTER_API(H5Gcreate, FAIL);
+ FUNC_ENTER_API(H5Gcreate, FAIL)
H5TRACE3("i","isz",loc_id,name,size_hint);
/* Check arguments */
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 given");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given")
/* Create the group */
if (NULL == (grp = H5G_create(loc, name, size_hint, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group");
- if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ if((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
done:
- if(ret_value<0) {
+ if(ret_value < 0) {
if(grp!=NULL)
H5G_close(grp);
} /* end if */
FUNC_LEAVE_API(ret_value)
-}
+} /* end H5Gcreate() */
/*-------------------------------------------------------------------------
@@ -313,13 +302,13 @@ H5Gopen(hid_t loc_id, const char *name)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group");
done:
- if(ret_value<0) {
+ if(ret_value < 0) {
if(grp!=NULL)
H5G_close(grp);
} /* end if */
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* H5Gopen() */
/*-------------------------------------------------------------------------
@@ -384,8 +373,6 @@ done:
* Programmer: Robb Matzke
* Monday, March 23, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -398,19 +385,19 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p,
H5G_t *grp = NULL;
herr_t ret_value;
- FUNC_ENTER_API(H5Giterate, FAIL);
+ FUNC_ENTER_API(H5Giterate, FAIL)
H5TRACE5("e","is*Isxx",loc_id,name,idx_p,op,op_data);
/* Check args */
- if (!name || !*name)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
idx = (idx_p == NULL ? 0 : *idx_p);
if (!idx_p)
idx_p = &idx;
- if (idx<0)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified");
- if (!op)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");
+ if(idx < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified")
+ if(!op)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
/*
* Open the group on which to operate. We also create a group ID which
@@ -452,8 +439,8 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p,
*idx_p=udata.final_ent;
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Giterate() */
/*-------------------------------------------------------------------------
@@ -469,8 +456,6 @@ done:
* Programmer: Raymond Lu
* Nov 20, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -479,23 +464,23 @@ H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */
herr_t ret_value;
- FUNC_ENTER_API(H5Gget_num_objs, FAIL);
+ FUNC_ENTER_API(H5Gget_num_objs, FAIL)
H5TRACE2("e","i*h",loc_id,num_objs);
/* Check args */
if (NULL==(loc=H5G_loc (loc_id)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP)
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
- if (!num_objs)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ if(!num_objs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nil pointer")
/* Call private function. */
ret_value = H5G_get_num_objs(loc, num_objs, H5AC_ind_dxpl_id);
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_num_objs() */
/*-------------------------------------------------------------------------
@@ -526,23 +511,23 @@ ssize_t
H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size)
{
H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */
- ssize_t ret_value = FAIL;
+ ssize_t ret_value;
- FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL);
+ FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL)
H5TRACE4("Zs","ihsz",loc_id,idx,name,size);
/* Check args */
if (NULL==(loc=H5G_loc (loc_id)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP)
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
/*call private function*/
ret_value = H5G_get_objname_by_idx(loc, idx, name, size, H5AC_ind_dxpl_id);
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_objname_by_idx() */
/*-------------------------------------------------------------------------
@@ -641,17 +626,17 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
H5G_entry_t *dst_loc=NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gmove2, FAIL);
+ FUNC_ENTER_API(H5Gmove2, FAIL)
H5TRACE4("e","isis",src_loc_id,src_name,dst_loc_id,dst_name);
if (src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if (dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- if (!src_name || !*src_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified");
- if (!dst_name || !*dst_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!src_name || !*src_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
+ if(!dst_name || !*dst_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified")
if(src_loc_id == H5G_SAME_LOC && dst_loc_id == H5G_SAME_LOC) {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC");
@@ -664,12 +649,12 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
else if(src_loc->file != dst_loc->file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.");
- if (H5G_move(src_loc, src_name, dst_loc, dst_name, H5AC_dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to change object name");
+ if(H5G_move(src_loc, src_name, dst_loc, dst_name, H5AC_dxpl_id)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to change object name")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gmove2() */
/*-------------------------------------------------------------------------
@@ -707,23 +692,23 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
H5G_entry_t *new_loc = NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Glink2, FAIL);
+ FUNC_ENTER_API(H5Glink2, FAIL)
H5TRACE5("e","isGlis",cur_loc_id,cur_name,type,new_loc_id,new_name);
/* Check arguments */
if (cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if (new_loc_id != H5G_SAME_LOC && NULL==(new_loc=H5G_loc(new_loc_id)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- if (type!=H5G_LINK_HARD && type!=H5G_LINK_SOFT)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type");
- if (!cur_name || !*cur_name)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified");
- if (!new_name || !*new_name)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(type != H5G_LINK_HARD && type != H5G_LINK_SOFT)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type")
+ if(!cur_name || !*cur_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
+ if(!new_name || !*new_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified")
if(cur_loc_id == H5G_SAME_LOC && new_loc_id == H5G_SAME_LOC) {
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC")
}
else if(cur_loc_id == H5G_SAME_LOC) {
cur_loc = new_loc;
@@ -732,14 +717,14 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
new_loc = cur_loc;
}
else if(cur_loc->file != new_loc->file)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.")
- if (H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL, H5AC_dxpl_id) <0)
- HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "unable to create link");
+ if(H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL, H5AC_dxpl_id) <0)
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to create link")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Glink2() */
/*-------------------------------------------------------------------------
@@ -767,22 +752,22 @@ H5Gunlink(hid_t loc_id, const char *name)
H5G_entry_t *loc = NULL;
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gunlink, FAIL);
+ FUNC_ENTER_API(H5Gunlink, FAIL)
H5TRACE2("e","is",loc_id,name);
/* Check arguments */
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");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
/* Unlink */
if (H5G_unlink(loc, name, H5AC_dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gunlink() */
/*-------------------------------------------------------------------------
@@ -807,24 +792,24 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link,
H5G_stat_t *statbuf/*out*/)
{
H5G_entry_t *loc = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gget_objinfo, FAIL);
+ FUNC_ENTER_API(H5Gget_objinfo, FAIL)
H5TRACE4("e","isbx",loc_id,name,follow_link,statbuf);
/* Check arguments */
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 specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
/* Get info */
- if (H5G_get_objinfo (loc, name, follow_link, statbuf, H5AC_ind_dxpl_id)<0)
- HGOTO_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object");
+ if (H5G_get_objinfo (loc, name, follow_link, statbuf, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_objinfo() */
/*-------------------------------------------------------------------------
@@ -849,24 +834,24 @@ herr_t
H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/)
{
H5G_entry_t *loc = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gget_linkval, FAIL);
+ FUNC_ENTER_API(H5Gget_linkval, FAIL)
H5TRACE4("e","iszx",loc_id,name,size,buf);
/* Check arguments */
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 specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
/* Get the link value */
if (H5G_linkval (loc, name, size, buf, H5AC_ind_dxpl_id)<0)
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_linkval() */
/*-------------------------------------------------------------------------
@@ -882,30 +867,28 @@ done:
* Programmer: Robb Matzke
* Monday, July 20, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
{
H5G_entry_t *loc = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(H5Gset_comment, FAIL);
+ FUNC_ENTER_API(H5Gset_comment, FAIL)
H5TRACE3("e","iss",loc_id,name,comment);
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 specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if (H5G_set_comment(loc, name, comment, H5AC_dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gset_comment() */
/*-------------------------------------------------------------------------
@@ -927,8 +910,6 @@ done:
* Programmer: Robb Matzke
* Monday, July 20, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
@@ -937,22 +918,22 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
H5G_entry_t *loc = NULL;
int ret_value;
- FUNC_ENTER_API(H5Gget_comment, FAIL);
+ FUNC_ENTER_API(H5Gget_comment, FAIL)
H5TRACE4("Is","iszs",loc_id,name,bufsize,buf);
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 specified");
- if (bufsize>0 && !buf)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ if(bufsize > 0 && !buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified")
if ((ret_value=H5G_get_comment(loc, name, bufsize, buf, H5AC_ind_dxpl_id))<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_comment() */
/*
*-------------------------------------------------------------------------
@@ -972,14 +953,13 @@ done:
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5G_init_interface(void)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_init_interface);
@@ -1016,21 +996,18 @@ done:
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
- * Robb Matzke, 2002-03-28
- * Free the global component buffer.
*-------------------------------------------------------------------------
*/
int
H5G_term_interface(void)
{
size_t i;
- int n=0;
+ int n = 0;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_term_interface);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_term_interface)
if (H5_interface_initialize_g) {
- if ((n=H5I_nmembers(H5I_GROUP))) {
+ if ((n = H5I_nmembers(H5I_GROUP))) {
H5I_clear_group(H5I_GROUP, FALSE);
} else {
/* Empty the object type table */
@@ -1049,11 +1026,11 @@ H5G_term_interface(void)
/* Mark closed */
H5_interface_initialize_g = 0;
n = 1; /*H5I*/
- }
- }
+ } /* end else */
+ } /* end if */
- FUNC_LEAVE_NOAPI(n);
-}
+ FUNC_LEAVE_NOAPI(n)
+} /* end H5G_term_interface() */
/*-------------------------------------------------------------------------
@@ -1138,8 +1115,6 @@ done:
* the size in characters of the component through SIZE_P not
* counting leading slashes or the null terminator.
*
- * Errors:
- *
* Return: Success: Ptr into NAME.
*
* Failure: Ptr to the null terminator of NAME.
@@ -1148,15 +1123,13 @@ done:
* matzke@llnl.gov
* Aug 11 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static const char *
H5G_component(const char *name, size_t *size_p)
{
/* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_component);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_component)
assert(name);
@@ -1165,8 +1138,8 @@ H5G_component(const char *name, size_t *size_p)
if (size_p)
*size_p = HDstrcspn(name, "/");
- FUNC_LEAVE_NOAPI(name);
-}
+ FUNC_LEAVE_NOAPI(name)
+} /* end H5G_component() */
/*-------------------------------------------------------------------------
@@ -1677,28 +1650,23 @@ done:
* matzke@llnl.gov
* Aug 11 1997
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent)
{
H5G_entry_t new_root; /*new root object */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_mkroot, FAIL);
+ FUNC_ENTER_NOAPI(H5G_mkroot, FAIL)
/* check args */
- assert(f);
- if (f->shared->root_grp)
- HGOTO_DONE(SUCCEED);
+ HDassert(f);
+ if(f->shared->root_grp)
+ HGOTO_DONE(SUCCEED)
/* Create information needed for group nodes */
- if(H5G_node_init(f)<0)
+ if(H5G_node_init(f) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group node info")
/*
@@ -1709,16 +1677,16 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent)
ent = &new_root;
H5G_ent_reset(ent);
if (H5G_stab_create (f, dxpl_id, (size_t)H5G_SIZE_HINT, ent/*out*/)<0)
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create root group");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create root group")
if (1 != H5O_link (ent, 1, dxpl_id))
- HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "internal error (wrong link count)");
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "internal error (wrong link count)")
} else {
/*
* Open the root object as a group.
*/
if (H5O_open (ent)<0)
- HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group");
- }
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group")
+ } /* end else */
/* Create the path names for the root group's entry */
ent->user_path_r=H5RS_create("/");
@@ -1732,23 +1700,24 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent)
* don't count the root group as an open object. The root group will
* never be closed.
*/
- if (NULL==(f->shared->root_grp = H5FL_CALLOC (H5G_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- if (NULL==(f->shared->root_grp->shared = H5FL_CALLOC (H5G_shared_t))) {
+ if(NULL == (f->shared->root_grp = H5FL_CALLOC(H5G_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(NULL == (f->shared->root_grp->shared = H5FL_CALLOC(H5G_shared_t))) {
H5FL_FREE(H5G_t, f->shared->root_grp);
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- }
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ } /* end if */
+
/* Shallow copy (take ownership) of the group entry object */
if(H5G_ent_copy(&(f->shared->root_grp->ent), ent, H5G_COPY_SHALLOW)<0)
HGOTO_ERROR (H5E_SYM, H5E_CANTCOPY, FAIL, "can't copy group entry")
f->shared->root_grp->shared->fo_count = 1;
- assert (1==f->nopen_objs);
+ HDassert(1 == f->nopen_objs);
f->nopen_objs = 0;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_mkroot() */
/*-------------------------------------------------------------------------
@@ -1757,8 +1726,6 @@ done:
* Purpose: Creates a new empty group with the specified name. The name
* is either an absolute name or is relative to LOC.
*
- * Errors:
- *
* Return: Success: A handle for the group. The group is opened
* and should eventually be close by calling
* H5G_close().
@@ -1769,11 +1736,6 @@ done:
* matzke@llnl.gov
* Aug 11 1997
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static H5G_t *
@@ -1784,21 +1746,21 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id)
unsigned stab_init=0; /* Flag to indicate that the symbol table was created successfully */
H5G_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_create);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_create)
/* check args */
- assert(loc);
- assert(name && *name);
+ HDassert(loc);
+ HDassert(name && *name);
/* create an open 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_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ 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")
/* What file is the group being added to? */
- if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to locate insertion point");
+ if(NULL == (file = H5G_insertion_file(loc, name, dxpl_id)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to locate insertion point")
/* Create the group entry */
if (H5G_stab_create(file, dxpl_id, size_hint, &(grp->ent)/*out*/) < 0)
@@ -1818,26 +1780,26 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint, hid_t dxpl_id)
grp->shared->fo_count = 1;
/* Set return value */
- ret_value=grp;
+ ret_value = grp;
done:
- if(ret_value==NULL) {
+ if(ret_value == NULL) {
/* Check if we need to release the file-oriented symbol table info */
if(stab_init) {
if(H5O_close(&(grp->ent))<0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header");
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header")
if(H5O_delete(file, dxpl_id,grp->ent.header)<0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header");
+ HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header")
} /* end if */
- if(grp!=NULL) {
+ if(grp != NULL) {
if(grp->shared != NULL)
H5FL_FREE(H5G_shared_t, grp->shared);
H5FL_FREE(H5G_t,grp);
- }
+ } /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_create() */
/*-------------------------------------------------------------------------
@@ -1925,25 +1887,19 @@ H5G_link_isa(H5G_entry_t *ent, hid_t UNUSED dxpl_id)
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
- * Modified to call H5G_open_oid - QAK - 3/17/99
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
H5G_t *
H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
{
H5G_t *grp = NULL;
- H5G_shared_t *shared_fo=NULL;
- H5G_t *ret_value=NULL;
+ H5G_shared_t *shared_fo = NULL;
+ H5G_t *ret_value = NULL;
- FUNC_ENTER_NOAPI(H5G_open, NULL);
+ FUNC_ENTER_NOAPI(H5G_open, NULL)
/* Check args */
- assert(ent);
+ HDassert(ent);
/* Allocate the group structure */
if(NULL == (grp = H5FL_CALLOC(H5G_t)))
@@ -1960,14 +1916,14 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
H5E_clear();
/* Open the group object */
- if (H5G_open_oid(grp, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found");
+ 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) {
H5FL_FREE(H5G_shared_t, grp->shared);
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, NULL, "can't insert group into list of open objects")
- }
+ } /* end if */
/* Increment object count for the object in the top file */
if(H5FO_top_incr(grp->ent.file, grp->ent.header) < 0)
@@ -1975,7 +1931,7 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
/* Set open object count */
grp->shared->fo_count = 1;
- }
+ } /* end if */
else {
/* Point to shared group info */
grp->shared = shared_fo;
@@ -1993,7 +1949,7 @@ H5G_open(H5G_entry_t *ent, hid_t dxpl_id)
/* Increment object count for the object in the top file */
if(H5FO_top_incr(grp->ent.file, grp->ent.header) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINC, NULL, "can't increment object count")
- }
+ } /* end else */
/* Set return value */
ret_value = grp;
@@ -2002,8 +1958,8 @@ done:
if (!ret_value && grp)
H5FL_FREE(H5G_t,grp);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_open() */
/*-------------------------------------------------------------------------
@@ -2019,11 +1975,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, March 17, 1999
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added a deep copy of the symbol table entry
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2032,14 +1983,14 @@ H5G_open_oid(H5G_t *grp, hid_t dxpl_id)
hbool_t ent_opened = FALSE;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT(H5G_open_oid);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_open_oid)
/* Check args */
- assert(grp);
+ HDassert(grp);
- /* Open the object, making sure it's a group */
- if (NULL==(grp->shared = H5FL_CALLOC(H5G_shared_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ /* Allocate the shared information for the group */
+ if(NULL == (grp->shared = H5FL_CALLOC(H5G_shared_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Grab the object header */
if (H5O_open(&(grp->ent)) < 0)
@@ -2048,7 +1999,7 @@ H5G_open_oid(H5G_t *grp, hid_t dxpl_id)
/* 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, FAIL, "not a group")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "not a group")
done:
if(ret_value < 0) {
@@ -2060,8 +2011,8 @@ done:
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_open_oid() */
/*-------------------------------------------------------------------------
@@ -2074,25 +2025,23 @@ done:
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5G_close(H5G_t *grp)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_close, FAIL);
+ FUNC_ENTER_NOAPI(H5G_close, FAIL)
/* Check args */
- assert(grp && grp->shared);
- assert(grp->shared->fo_count > 0);
+ HDassert(grp && grp->shared);
+ HDassert(grp->shared->fo_count > 0);
--grp->shared->fo_count;
- if (0 == grp->shared->fo_count) {
- assert (grp!=H5G_rootof(H5G_fileof(grp)));
+ if(0 == grp->shared->fo_count) {
+ HDassert(grp != H5G_rootof(H5G_fileof(grp)));
/* Remove the group from the list of opened objects in the file */
if(H5FO_top_decr(grp->ent.file, grp->ent.header) < 0)
@@ -2101,7 +2050,7 @@ H5G_close(H5G_t *grp)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects")
if(H5O_close(&(grp->ent)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close")
- H5FL_FREE (H5G_shared_t, grp->shared);
+ H5FL_FREE(H5G_shared_t, grp->shared);
} else {
/* Decrement the ref. count for this object in the top file */
if(H5FO_top_decr(grp->ent.file, grp->ent.header) < 0)
@@ -2124,14 +2073,14 @@ H5G_close(H5G_t *grp)
if(H5G_free_ent_name(&(grp->ent))<0)
{
H5FL_FREE (H5G_t,grp);
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't free group entry name")
}
}
- H5FL_FREE (H5G_t,grp);
+ H5FL_FREE(H5G_t,grp);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_close() */
@@ -2155,18 +2104,18 @@ done:
herr_t
H5G_free(H5G_t *grp)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_free, FAIL);
+ FUNC_ENTER_NOAPI(H5G_free, FAIL)
- assert(grp && grp->shared);
+ HDassert(grp && grp->shared);
H5FL_FREE(H5G_shared_t, grp->shared);
H5FL_FREE(H5G_t, grp);
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_free() */
/*-------------------------------------------------------------------------
@@ -2192,13 +2141,13 @@ done:
static H5G_t *
H5G_rootof(H5F_t *f)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof)
- while (f->mtab.parent)
+ while(f->mtab.parent)
f = f->mtab.parent;
- FUNC_LEAVE_NOAPI(f->shared->root_grp);
-}
+ FUNC_LEAVE_NOAPI(f->shared->root_grp)
+} /* end H5G_rootof() */
/*-------------------------------------------------------------------------
@@ -2206,42 +2155,35 @@ H5G_rootof(H5F_t *f)
*
* Purpose: Inserts a symbol table entry into the group graph.
*
- * Errors:
- *
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Friday, September 19, 1997
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent, hid_t dxpl_id)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_insert, FAIL);
+ FUNC_ENTER_NOAPI(H5G_insert, FAIL)
/* Check args. */
- assert (loc);
- assert (name && *name);
- assert (ent);
+ HDassert(loc);
+ HDassert(name && *name);
+ HDassert(ent);
/*
* Lookup and insert the name -- it shouldn't exist yet.
*/
if (H5G_namei(loc, name, NULL, NULL, NULL, H5G_TARGET_NORMAL, NULL, H5G_NAMEI_INSERT, ent, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists");
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists")
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_insert() */
/*-------------------------------------------------------------------------
@@ -2471,23 +2413,23 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
char *norm_new_name = NULL; /* Pointer to normalized current name */
size_t nchars; /*characters in component */
size_t offset; /*offset to sym-link value */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_link);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_link)
/* Check args */
- assert (cur_loc);
- assert (new_loc);
- assert (cur_name && *cur_name);
- assert (new_name && *new_name);
+ HDassert(cur_loc);
+ HDassert(new_loc);
+ HDassert(cur_name && *cur_name);
+ HDassert(new_name && *new_name);
/* Get normalized copies of the current and new names */
- if((norm_cur_name=H5G_normalize(cur_name))==NULL)
- HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name");
- if((norm_new_name=H5G_normalize(new_name))==NULL)
- HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name");
+ if((norm_cur_name = H5G_normalize(cur_name)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name")
+ if((norm_new_name = H5G_normalize(new_name)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name")
- switch (type) {
+ switch(type) {
case H5G_LINK_SOFT:
/*
* Lookup the the new_name so we can get the group which will contain
@@ -2548,8 +2490,8 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
break;
default:
- HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type");
- }
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type")
+ } /* end switch */
done:
/* Free the group's ID to name buffer, if creating a soft link */
@@ -2566,8 +2508,8 @@ done:
if(norm_new_name)
H5MM_xfree(norm_new_name);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_link() */
/*-------------------------------------------------------------------------
@@ -2625,11 +2567,6 @@ done:
* Programmer: Robb Matzke
* Monday, April 13, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -2637,12 +2574,12 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
H5G_stat_t *statbuf/*out*/, hid_t dxpl_id)
{
H5G_entry_t grp_ent, obj_ent;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_get_objinfo, FAIL);
+ FUNC_ENTER_NOAPI(H5G_get_objinfo, FAIL)
- assert (loc);
- assert (name && *name);
+ HDassert(loc);
+ HDassert(name && *name);
if (statbuf) HDmemset (statbuf, 0, sizeof *statbuf);
/* Find the object's symbol table entry */
@@ -2720,8 +2657,8 @@ done:
H5G_free_ent_name(&grp_ent);
H5G_free_ent_name(&obj_ent);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_get_objinfo() */
/*-------------------------------------------------------------------------
@@ -2907,11 +2844,6 @@ done:
* Programmer: Robb Matzke
* Monday, April 13, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2921,9 +2853,9 @@ H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/,
H5G_entry_t grp_ent, obj_ent;
H5O_stab_t stab_mesg;
const H5HL_t *heap;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_linkval);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_linkval)
/*
* Get the symbol table entry for the link head and the symbol table
@@ -2959,8 +2891,8 @@ done:
H5G_free_ent_name(&grp_ent);
H5G_free_ent_name(&obj_ent);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5G_linkval() */
/*-------------------------------------------------------------------------
@@ -2973,11 +2905,6 @@ done:
* Programmer: Robb Matzke
* Monday, July 20, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2985,9 +2912,9 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf, hid_t dxpl_
{
H5G_entry_t obj_ent;
H5O_name_t comment;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_set_comment);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_set_comment)
/* Get the symbol table entry for the object */
if (H5G_find(loc, name, &obj_ent/*out*/, dxpl_id)<0)
@@ -2998,19 +2925,19 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf, hid_t dxpl_
H5E_clear();
/* Add the new message */
- if (buf && *buf) {
+ if(buf && *buf) {
comment.s = H5MM_xstrdup(buf);
if (H5O_modify(&obj_ent, H5O_NAME_ID, H5O_NEW_MESG, 0, H5O_UPDATE_TIME, &comment, dxpl_id)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message")
H5O_reset(H5O_NAME_ID, &comment);
- }
+ } /* end if */
done:
/* Free the ID to name buffer */
H5G_free_ent_name(&obj_ent);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_set_comment() */
/*-------------------------------------------------------------------------
@@ -3027,11 +2954,6 @@ done:
* Programmer: Robb Matzke
* Monday, July 20, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static int
@@ -3039,13 +2961,13 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, h
{
H5O_name_t comment;
H5G_entry_t obj_ent;
- int ret_value;
+ int ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_get_comment);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_get_comment)
/* Get the symbol table entry for the object */
- if (H5G_find(loc, name, &obj_ent/*out*/, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+ if(H5G_find(loc, name, &obj_ent/*out*/, dxpl_id)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
/* Get the message */
comment.s = NULL;
@@ -3058,14 +2980,14 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf, h
HDstrncpy(buf, comment.s, bufsize);
ret_value = (int)HDstrlen(comment.s);
H5O_reset(H5O_NAME_ID, &comment);
- }
+ } /* end else */
done:
/* Free the ID to name buffer */
H5G_free_ent_name(&obj_ent);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_get_comment() */
/*-------------------------------------------------------------------------
@@ -3078,11 +3000,6 @@ done:
* Programmer: Robb Matzke
* Thursday, September 17, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -3092,17 +3009,17 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
const char *base=NULL;
char *norm_name = NULL; /* Pointer to normalized name */
int obj_type; /* Object type */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_unlink);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_unlink)
/* Sanity check */
- assert(loc);
- assert(name && *name);
+ HDassert(loc);
+ HDassert(name && *name);
/* Get normalized copy of the name */
- if((norm_name=H5G_normalize(name))==NULL)
- HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name");
+ if((norm_name = H5G_normalize(name)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name")
/* Reset the group entries to known values in a portable way */
H5G_ent_reset(&grp_ent);
@@ -3115,19 +3032,19 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
if (!H5F_addr_defined(grp_ent.header))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no containing group specified");
if (NULL==(base=H5G_basename(norm_name, NULL)) || '/'==*base)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "problems obtaining object base name");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "problems obtaining object base name")
/* Get object type before unlink */
if((obj_type = H5G_get_type(&obj_ent, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't determine object type");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't determine object type")
/* Remove the name from the symbol table */
if (H5G_stab_remove(&grp_ent, base, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table")
/* Search the open IDs and replace names for unlinked object */
if (H5G_replace_name(obj_type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name")
done:
/* Free the ID to name buffers */
@@ -3138,8 +3055,8 @@ done:
if(norm_name)
H5MM_xfree(norm_name);
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_unlink() */
/*-------------------------------------------------------------------------
@@ -3152,14 +3069,6 @@ done:
* Programmer: Robb Matzke
* Friday, September 25, 1998
*
- * Modifications:
- *
- * Raymond Lu
- * Thursday, April 18, 2002
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -3172,43 +3081,42 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
H5G_entry_t obj_ent; /* Object entry for object being moved */
H5RS_str_t *src_name_r; /* Ref-counted version of src name */
H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_move);
+ FUNC_ENTER_NOAPI_NOINIT(H5G_move)
/* Sanity check */
- assert(src_loc);
- assert(dst_loc);
- assert(src_name && *src_name);
- assert(dst_name && *dst_name);
-
- if (H5G_get_objinfo(src_loc, src_name, FALSE, &sb, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- if (H5G_LINK==sb.type) {
+ HDassert(src_loc);
+ HDassert(dst_loc);
+ HDassert(src_name && *src_name);
+ HDassert(dst_name && *dst_name);
+
+ if(H5G_get_objinfo(src_loc, src_name, FALSE, &sb, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ if(H5G_LINK == sb.type) {
/*
* When renaming a symbolic link we rename the link but don't change
* the value of the link.
*/
do {
- if (NULL==(linkval=H5MM_realloc(linkval, 2*lv_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for symbolic link value");
+ if(NULL==(linkval=H5MM_realloc(linkval, 2*lv_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for symbolic link value")
linkval[lv_size-1] = '\0';
- if (H5G_linkval(src_loc, src_name, lv_size, linkval, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value");
+ if(H5G_linkval(src_loc, src_name, lv_size, linkval, dxpl_id)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value")
} while (linkval[lv_size-1]);
if (H5G_link(src_loc, linkval, dst_loc, dst_name, H5G_LINK_SOFT,
H5G_TARGET_NORMAL, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to rename symbolic link");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to rename symbolic link")
H5MM_xfree(linkval);
} else {
/*
* Rename the object.
*/
- if (H5G_link(src_loc, src_name, dst_loc, dst_name, H5G_LINK_HARD,
- H5G_TARGET_MOUNT, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to register new name for object");
- }
+ if(H5G_link(src_loc, src_name, dst_loc, dst_name, H5G_LINK_HARD, H5G_TARGET_MOUNT, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to register new name for object")
+ } /* end else */
/* Search the open ID list and replace names for the move operation
* This has to be done here because H5G_link and H5G_unlink have
@@ -3227,12 +3135,12 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
H5G_free_ent_name(&obj_ent);
/* Remove the old name */
- if (H5G_unlink(src_loc, src_name, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name");
+ if(H5G_unlink(src_loc, src_name, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name")
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_move() */
/*-------------------------------------------------------------------------
@@ -3249,11 +3157,6 @@ done:
* Programmer: Robb Matzke
* Wednesday, October 14, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 18 Sep 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
H5F_t *
@@ -3261,10 +3164,10 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
{
H5F_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5G_insertion_file, NULL);
+ FUNC_ENTER_NOAPI(H5G_insertion_file, NULL)
- assert(loc);
- assert(name && *name);
+ HDassert(loc);
+ HDassert(name && *name);
/* Check if the location the object will be inserted into is part of a
* file mounting chain (either a parent or a child) and perform a more
@@ -3306,8 +3209,8 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
ret_value=loc->file;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_insertion_file() */
/*-------------------------------------------------------------------------
@@ -3323,21 +3226,19 @@ done:
*
* Comments: Used now only on the root group close, in H5F_close()
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5G_free_grp_name(H5G_t *grp)
{
H5G_entry_t *ent; /* Group object's entry */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL);
+ FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL)
/* Check args */
- assert(grp && grp->shared);
- assert(grp->shared->fo_count > 0);
+ HDassert(grp && grp->shared);
+ HDassert(grp->shared->fo_count > 0);
/* Get the entry for the group */
if (NULL==( ent = H5G_entof(grp)))
@@ -3347,8 +3248,8 @@ H5G_free_grp_name(H5G_t *grp)
H5G_free_ent_name(ent);
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_free_grp_name() */
/*-------------------------------------------------------------------------
@@ -4033,3 +3934,4 @@ H5G_unmount(H5G_t *grp)
FUNC_LEAVE_NOAPI(SUCCEED);
} /* end H5G_unmount() */
+
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index e3d38e6..242d65b 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -20,11 +20,6 @@
*
* Purpose: Library-visible declarations.
*
- * Modifications: Aug 22, 2002
- * Pedro Vicente <pvn@ncsa.uiuc.edu>
- * Added 'names' field to H5G_entry_t
- * Added H5G_replace_name
- *
*-------------------------------------------------------------------------
*/
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index fdf9a96..0300664 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -134,3 +134,4 @@ H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
}
#endif
#endif
+
diff --git a/src/H5O.c b/src/H5O.c
index 30538b2..b2bdb33 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -20,8 +20,6 @@
*
* Purpose: Object header virtual functions.
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
@@ -47,6 +45,26 @@
#include <sys/time.h>
#endif /* H5_HAVE_GETTIMEOFDAY */
+/* Local macros */
+
+/* Load native information for a message, if it's not already present */
+/* (Only works for messages with decode callback) */
+#define LOAD_NATIVE(F, DXPL, MSG, ERR) \
+ if(NULL == (MSG)->native) { \
+ const H5O_msg_class_t *decode_type; \
+ \
+ /* Check for shared message */ \
+ if ((MSG)->flags & H5O_FLAG_SHARED) \
+ decode_type = H5O_MSG_SHARED; \
+ else \
+ decode_type = (MSG)->type; \
+ \
+ /* Decode the message */ \
+ HDassert(decode_type->decode); \
+ if(NULL == ((MSG)->native = (decode_type->decode)((F), (DXPL), (MSG)->raw))) \
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, ERR, "unable to decode message") \
+ } /* end if */
+
/* Private typedefs */
/* User data for iteration while removing a message */
@@ -64,82 +82,35 @@ typedef struct {
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_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 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,
- hid_t dxpl_id);
-static htri_t H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type,
- int sequence, hid_t dxpl_id);
-#ifdef NOT_YET
-static herr_t H5O_share(H5F_t *f, hid_t dxpl_id, const H5O_class_t *type, const void *mesg,
- H5HG_t *hobj/*out*/);
-#endif /* NOT_YET */
-static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
- const H5O_class_t **type_p, int sequence);
-static int H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type,
- int overwrite, unsigned flags, unsigned update_flags, const void *mesg,
- hid_t dxpl_id);
-static int H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
- const H5O_class_t *type, unsigned flags, const void *mesg);
-static herr_t H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type,
- int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
-static unsigned H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type,
- size_t size);
-static unsigned H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size);
-static unsigned H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size);
-static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh);
-static herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg,
- hbool_t adj_link);
-static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags,
- const H5O_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg,
- const H5O_class_t **new_type, const void **new_mesg, hid_t dxpl_id);
-static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_class_t *type,
- const void *mesg, unsigned flags, unsigned update_flags);
-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);
+/* Package variables */
-/* ID to type mapping */
-const H5O_class_t *const message_type_g[] = {
- H5O_NULL, /*0x0000 Null */
- H5O_SDSPACE, /*0x0001 Simple Dimensionality */
+/* Header message ID to class mapping */
+const H5O_msg_class_t *const H5O_msg_class_g[] = {
+ H5O_MSG_NULL, /*0x0000 Null */
+ H5O_MSG_SDSPACE, /*0x0001 Simple Dimensionality */
NULL, /*0x0002 Data space (fiber bundle?) */
- H5O_DTYPE, /*0x0003 Data Type */
- H5O_FILL, /*0x0004 Old data storage -- fill value */
- H5O_FILL_NEW, /*0x0005 New Data storage -- fill value */
+ H5O_MSG_DTYPE, /*0x0003 Data Type */
+ H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */
+ H5O_MSG_FILL_NEW, /*0x0005 New Data storage -- fill value */
NULL, /*0x0006 Data storage -- compact object */
- H5O_EFL, /*0x0007 Data storage -- external data files */
- H5O_LAYOUT, /*0x0008 Data Layout */
+ H5O_MSG_EFL, /*0x0007 Data storage -- external data files */
+ H5O_MSG_LAYOUT, /*0x0008 Data Layout */
#ifdef H5O_ENABLE_BOGUS
- H5O_BOGUS, /*0x0009 "Bogus" */
+ H5O_MSG_BOGUS, /*0x0009 "Bogus" */
#else /* H5O_ENABLE_BOGUS */
- NULL, /*0x0009 "Bogus" */
+ NULL, /*0x0009 "Bogus" */
#endif /* H5O_ENABLE_BOGUS */
NULL, /*0x000A Not assigned */
- H5O_PLINE, /*0x000B Data storage -- filter pipeline */
- H5O_ATTR, /*0x000C Attribute list */
- H5O_NAME, /*0x000D Object name */
- H5O_MTIME, /*0x000E Object modification date and time */
- H5O_SHARED, /*0x000F Shared header message */
- H5O_CONT, /*0x0010 Object header continuation */
- H5O_STAB, /*0x0011 Symbol table */
- H5O_MTIME_NEW, /*0x0012 New Object modification date and time */
+ H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */
+ H5O_MSG_ATTR, /*0x000C Attribute list */
+ H5O_MSG_NAME, /*0x000D Object name */
+ H5O_MSG_MTIME, /*0x000E Object modification date and time */
+ H5O_MSG_SHARED, /*0x000F Shared header message */
+ H5O_MSG_CONT, /*0x0010 Object header continuation */
+ H5O_MSG_STAB, /*0x0011 Symbol table */
+ H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */
};
-/* Library private variables */
-
-/*
- * An array of functions indexed by symbol table entry cache type
- * (H5G_type_t) that are called to retrieve constant messages cached in the
- * symbol table entry.
- */
-static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *,
- const H5O_class_t *,
- void *);
-
/* Declare a free list to manage the H5O_t struct */
H5FL_DEFINE(H5O_t);
@@ -152,12 +123,64 @@ H5FL_SEQ_DEFINE(H5O_chunk_t);
/* Declare a free list to manage the chunk image information */
H5FL_BLK_DEFINE(chunk_image);
+/* Library private variables */
+
+/* Local variables */
+
+/*
+ * An array of functions indexed by symbol table entry cache type
+ * (H5G_type_t) that are called to retrieve constant messages cached in the
+ * symbol table entry.
+ */
+static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *,
+ const H5O_msg_class_t *,
+ void *);
+
/* Declare external the free list for time_t's */
H5FL_EXTERN(time_t);
/* Declare extern the free list for H5O_cont_t's */
H5FL_EXTERN(H5O_cont_t);
+
+/* PRIVATE PROTOTYPES */
+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_msg_class_t *type, void *native);
+static void * H5O_copy_real(const H5O_msg_class_t *type, const void *mesg,
+ void *dst);
+static int H5O_count_real (H5G_entry_t *ent, const H5O_msg_class_t *type,
+ hid_t dxpl_id);
+static htri_t H5O_exists_real(H5G_entry_t *ent, const H5O_msg_class_t *type,
+ int sequence, hid_t dxpl_id);
+#ifdef NOT_YET
+static herr_t H5O_share(H5F_t *f, hid_t dxpl_id, const H5O_msg_class_t *type, const void *mesg,
+ H5HG_t *hobj/*out*/);
+#endif /* NOT_YET */
+static unsigned H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
+ const H5O_msg_class_t **type_p, int sequence);
+static int H5O_modify_real(H5G_entry_t *ent, const H5O_msg_class_t *type,
+ int overwrite, unsigned flags, unsigned update_flags, const void *mesg,
+ hid_t dxpl_id);
+static int H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
+ const H5O_msg_class_t *type, unsigned flags, const void *mesg);
+static herr_t H5O_remove_real(H5G_entry_t *ent, const H5O_msg_class_t *type,
+ int sequence, H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id);
+static unsigned H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type,
+ size_t size);
+static unsigned H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size);
+static unsigned H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size);
+static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh);
+static herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg,
+ hbool_t adj_link);
+static unsigned H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags,
+ const H5O_msg_class_t *orig_type, const void *orig_mesg, H5O_shared_t *sh_mesg,
+ const H5O_msg_class_t **new_type, const void **new_mesg, hid_t dxpl_id);
+static herr_t H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type,
+ const void *mesg, unsigned flags, unsigned update_flags);
+static herr_t H5O_iterate_real(const H5G_entry_t *ent, const H5O_msg_class_t *type,
+ H5AC_protect_t prot, hbool_t internal, void *op, void *op_data, hid_t dxpl_id);
+
/*-------------------------------------------------------------------------
* Function: H5O_init
@@ -232,14 +255,6 @@ H5O_init_interface(void)
* matzke@llnl.gov
* Aug 5 1997
*
- * Modifications:
- *
- * Bill Wendling, 1. November 2002
- * Separated the create function into two different functions. One
- * which allocates space and an initialization function which
- * does the rest of the work (initializes, caches, and opens the
- * object header).
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -248,27 +263,26 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/)
haddr_t header;
herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_NOAPI(H5O_create, FAIL);
+ FUNC_ENTER_NOAPI(H5O_create, FAIL)
/* check args */
- assert(f);
- assert(ent);
+ HDassert(f);
+ HDassert(ent);
- size_hint = H5O_ALIGN (MAX (H5O_MIN_SIZE, size_hint));
+ size_hint = H5O_ALIGN(MAX(H5O_MIN_SIZE, size_hint));
/* allocate disk space for header and first chunk */
- if (HADDR_UNDEF == (header = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id,
- (hsize_t)H5O_SIZEOF_HDR(f) + size_hint)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "file allocation failed for object header header");
+ if(HADDR_UNDEF == (header = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id,
+ (hsize_t)H5O_SIZEOF_HDR(f) + size_hint)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header header")
/* initialize the object header */
- if (H5O_new(f, dxpl_id, size_hint, ent, header) != SUCCEED)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to initialize object header");
+ if(H5O_new(f, dxpl_id, size_hint, ent, header) != SUCCEED)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to initialize object header")
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_create() */
/*-------------------------------------------------------------------------
@@ -287,8 +301,6 @@ done:
* Programmer: Bill Wendling
* 1, November 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -298,19 +310,19 @@ H5O_new(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, hadd
haddr_t tmp_addr;
herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_new);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_new)
/* check args */
- assert(f);
- assert(ent);
+ HDassert(f);
+ HDassert(ent);
size_hint = H5O_ALIGN(MAX(H5O_MIN_SIZE, size_hint));
ent->file = f;
ent->header = header;
/* allocate the object header and fill in header fields */
- if (NULL == (oh = H5FL_MALLOC(H5O_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if(NULL == (oh = H5FL_MALLOC(H5O_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
oh->cache_info.is_dirty = TRUE;
oh->version = H5O_VERSION;
@@ -320,25 +332,25 @@ H5O_new(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, hadd
oh->nchunks = 1;
oh->alloc_nchunks = H5O_NCHUNKS;
- if (NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
tmp_addr = ent->header + (hsize_t)H5O_SIZEOF_HDR(f);
oh->chunk[0].dirty = TRUE;
oh->chunk[0].addr = tmp_addr;
oh->chunk[0].size = size_hint;
- if (NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, size_hint)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, size_hint)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* create the message list and initialize the first message */
oh->nmesgs = 1;
oh->alloc_nmesgs = H5O_NMESGS;
- if (NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, (size_t)oh->alloc_nmesgs)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, (size_t)oh->alloc_nmesgs)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- oh->mesg[0].type = H5O_NULL;
+ oh->mesg[0].type = H5O_MSG_NULL;
oh->mesg[0].dirty = TRUE;
oh->mesg[0].native = NULL;
oh->mesg[0].raw = oh->chunk[0].image + H5O_SIZEOF_MSGHDR(f);
@@ -347,20 +359,20 @@ H5O_new(H5F_t *f, hid_t dxpl_id, size_t size_hint, H5G_entry_t *ent/*out*/, hadd
/* cache it */
if (H5AC_set(f, dxpl_id, H5AC_OHDR, ent->header, oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header")
/* open it */
if (H5O_open(ent) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header")
done:
- if(ret_value<0 && oh) {
- if(H5O_dest(f,oh)<0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data");
+ if(ret_value < 0 && oh) {
+ if(H5O_dest(f, oh) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data")
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_new() */
/*-------------------------------------------------------------------------
@@ -374,20 +386,18 @@ done:
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_open(const H5G_entry_t *obj_ent)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5O_open, FAIL);
+ FUNC_ENTER_NOAPI(H5O_open, FAIL)
/* Check args */
- assert(obj_ent);
- assert(obj_ent->file);
+ HDassert(obj_ent);
+ HDassert(obj_ent->file);
#ifdef H5O_DEBUG
if (H5DEBUG(O))
@@ -398,8 +408,8 @@ H5O_open(const H5G_entry_t *obj_ent)
obj_ent->file->nopen_objs++;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_open() */
/*-------------------------------------------------------------------------
@@ -412,24 +422,19 @@ done:
* Programmer: Robb Matzke
* Monday, January 5, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_close(H5G_entry_t *obj_ent)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_close, FAIL);
+ FUNC_ENTER_NOAPI(H5O_close, FAIL)
/* Check args */
- assert(obj_ent);
- assert(obj_ent->file);
- assert(obj_ent->file->nopen_objs > 0);
+ HDassert(obj_ent);
+ HDassert(obj_ent->file);
+ HDassert(obj_ent->file->nopen_objs > 0);
/* Decrement open-lock counters */
--obj_ent->file->nopen_objs;
@@ -453,14 +458,14 @@ H5O_close(H5G_entry_t *obj_ent)
if(obj_ent->file->nopen_objs == obj_ent->file->mtab.nmounts) {
/* Attempt to close down the file hierarchy */
if(H5F_try_close(obj_ent->file) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
} /* end if */
/* Free the ID to name buffers */
H5G_free_ent_name(obj_ent);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_close() */
@@ -488,18 +493,18 @@ done:
herr_t
H5O_reset(unsigned type_id, void *native)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_reset,FAIL);
/* check args */
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
assert(type);
/* Call the "real" reset routine */
- if((ret_value=H5O_reset_real(type, native))<0)
+ if((ret_value=H5O_reset_real(type, native)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to reset object header");
done:
@@ -520,12 +525,10 @@ done:
* matzke@llnl.gov
* Aug 12 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_reset_real(const H5O_class_t *type, void *native)
+H5O_reset_real(const H5O_msg_class_t *type, void *native)
{
herr_t ret_value=SUCCEED; /* Return value */
@@ -568,21 +571,21 @@ done:
void *
H5O_free (unsigned type_id, void *mesg)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
- void * ret_value; /* Return value */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
+ void * ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI(H5O_free, NULL);
+ FUNC_ENTER_NOAPI(H5O_free, NULL)
/* check args */
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert(type);
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
/* Call the "real" free routine */
- ret_value=H5O_free_real(type, mesg);
+ ret_value = H5O_free_real(type, mesg);
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_free() */
@@ -608,7 +611,7 @@ H5O_free_mesg(H5O_mesg_t *mesg)
/* Free any native information */
if(mesg->flags & H5O_FLAG_SHARED)
- mesg->native = H5O_free_real(H5O_SHARED, mesg->native);
+ mesg->native = H5O_free_real(H5O_MSG_SHARED, mesg->native);
else
mesg->native = H5O_free_real(mesg->type, mesg->native);
@@ -629,25 +632,23 @@ H5O_free_mesg(H5O_mesg_t *mesg)
* Programmer: Robb Matzke
* Thursday, May 21, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
-H5O_free_real(const H5O_class_t *type, void *msg_native)
+H5O_free_real(const H5O_msg_class_t *type, void *msg_native)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_free_real)
/* check args */
- assert(type);
+ HDassert(type);
- if (msg_native) {
+ if(msg_native) {
H5O_reset_real(type, msg_native);
if (NULL!=(type->free))
(type->free)(msg_native);
else
H5MM_xfree (msg_native);
- }
+ } /* end if */
FUNC_LEAVE_NOAPI(NULL)
} /* end H5O_free_real() */
@@ -677,14 +678,14 @@ H5O_free_real(const H5O_class_t *type, void *msg_native)
void *
H5O_copy (unsigned type_id, const void *mesg, void *dst)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_copy, NULL);
/* check args */
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
assert(type);
/* Call the "real" copy routine */
@@ -714,7 +715,7 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_copy_real (const H5O_class_t *type, const void *mesg, void *dst)
+H5O_copy_real (const H5O_msg_class_t *type, const void *mesg, void *dst)
{
void *ret_value = NULL;
@@ -749,13 +750,6 @@ done:
* matzke@llnl.gov
* Aug 5 1997
*
- * Modifications:
- *
- * Robb Matzke, 1998-08-27
- * This function can also be used to obtain the current number of links
- * if zero is passed for ADJUST. If that's the case then we don't check
- * for write access on the file.
- *
*-------------------------------------------------------------------------
*/
int
@@ -765,68 +759,68 @@ H5O_link(const H5G_entry_t *ent, int adjust, hid_t dxpl_id)
hbool_t deleted=FALSE; /* Whether the object was deleted as a result of this action */
int ret_value = FAIL;
- FUNC_ENTER_NOAPI(H5O_link, FAIL);
+ FUNC_ENTER_NOAPI(H5O_link, FAIL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- if (adjust!=0 && 0==(ent->file->intent & H5F_ACC_RDWR))
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ if(adjust!=0 && 0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
/* get header */
if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header,
NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* adjust link count */
- if (adjust<0) {
- if (oh->nlink + adjust < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative");
+ if(adjust < 0) {
+ if(oh->nlink + adjust < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative")
oh->nlink += adjust;
oh->cache_info.is_dirty = TRUE;
/* Check if the object should be deleted */
- if(oh->nlink==0) {
+ if(oh->nlink == 0) {
/* Check if the object is still open by the user */
if(H5FO_opened(ent->file,ent->header)!=NULL) {
/* Flag the object to be deleted when it's closed */
if(H5FO_mark(ent->file,ent->header,TRUE)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
} /* end if */
else {
/* Delete object right now */
if(H5O_delete_oh(ent->file,dxpl_id,oh)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
/* Mark the object header as deleted */
deleted=TRUE;
} /* end else */
} /* end if */
- } else if (adjust>0) {
+ } else if (adjust > 0) {
/* A new object, or one that will be deleted */
- if(oh->nlink==0) {
+ if(oh->nlink == 0) {
/* Check if the object is current open, but marked for deletion */
if(H5FO_marked(ent->file,ent->header)>0) {
/* Remove "delete me" flag on the object */
if(H5FO_mark(ent->file,ent->header,FALSE)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
} /* end if */
} /* end if */
oh->nlink += adjust;
oh->cache_info.is_dirty = TRUE;
- }
+ } /* end if */
/* Set return value */
ret_value = oh->nlink;
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, deleted) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_link() */
/*-------------------------------------------------------------------------
@@ -842,36 +836,30 @@ done:
* Programmer: Robb Matzke
* Tuesday, April 21, 1998
*
- * Modifications:
- * Changed to use IDs for types, instead of type objects, then
- * call "real" routine.
- * Quincey Koziol
- * Feb 14 2003
- *
*-------------------------------------------------------------------------
*/
int
-H5O_count (H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id)
+H5O_count(H5G_entry_t *ent, unsigned type_id, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_count, FAIL);
+ FUNC_ENTER_NOAPI(H5O_count, FAIL)
/* Check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined(ent->header));
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert (type);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
/* Call the "real" count routine */
- if((ret_value=H5O_count_real(ent, type, dxpl_id))<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to count object header messages");
+ if((ret_value = H5O_count_real(ent, type, dxpl_id))<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to count object header messages")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_count() */
@@ -888,43 +876,41 @@ done:
* Programmer: Robb Matzke
* Tuesday, April 21, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type, hid_t dxpl_id)
+H5O_count_real(H5G_entry_t *ent, const H5O_msg_class_t *type, hid_t dxpl_id)
{
H5O_t *oh = NULL;
int acc;
unsigned u;
int ret_value;
- FUNC_ENTER_NOAPI(H5O_count_real, FAIL);
+ FUNC_ENTER_NOAPI(H5O_count_real, FAIL)
/* Check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined(ent->header));
- assert (type);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type);
/* Load the object header */
- if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ if(NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Loop over all messages, counting the ones of the type looked for */
- for (u=acc=0; u<oh->nmesgs; u++)
- if (oh->mesg[u].type==type)
+ for(u = acc = 0; u < oh->nmesgs; u++)
+ if(oh->mesg[u].type == type)
acc++;
/* Set return value */
- ret_value=acc;
+ ret_value = acc;
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_count_real() */
@@ -944,35 +930,29 @@ done:
* Programmer: Robb Matzke
* Monday, November 2, 1998
*
- * Modifications:
- * Changed to use IDs for types, instead of type objects, then
- * call "real" routine.
- * Quincey Koziol
- * Feb 14 2003
- *
*-------------------------------------------------------------------------
*/
htri_t
H5O_exists(H5G_entry_t *ent, unsigned type_id, int sequence, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
htri_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_exists, FAIL);
+ FUNC_ENTER_NOAPI(H5O_exists, FAIL)
- assert(ent);
- assert(ent->file);
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert(type);
- assert(sequence>=0);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
+ HDassert(sequence>=0);
/* Call the "real" exists routine */
if((ret_value=H5O_exists_real(ent, type, sequence, dxpl_id))<0)
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to verify object header message");
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_exists() */
@@ -997,13 +977,13 @@ done:
*-------------------------------------------------------------------------
*/
static htri_t
-H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t dxpl_id)
+H5O_exists_real(H5G_entry_t *ent, const H5O_msg_class_t *type, int sequence, hid_t dxpl_id)
{
H5O_t *oh=NULL;
unsigned u;
htri_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_exists_real);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_exists_real)
assert(ent);
assert(ent->file);
@@ -1015,21 +995,21 @@ H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* Scan through the messages looking for the right one */
- for (u=0; u<oh->nmesgs; u++) {
- if (type->id!=oh->mesg[u].type->id)
+ for(u = 0; u < oh->nmesgs; u++) {
+ if(type->id != oh->mesg[u].type->id)
continue;
- if (--sequence<0)
+ if(--sequence < 0)
break;
- }
+ } /* end for */
/* Set return value */
- ret_value=(sequence<0);
+ ret_value = (sequence < 0);
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_exists_real() */
@@ -1054,37 +1034,31 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- * Changed to use IDs for types, instead of type objects, then
- * call "real" routine.
- * Quincey Koziol
- * Feb 14 2003
- *
*-------------------------------------------------------------------------
*/
void *
H5O_read(const H5G_entry_t *ent, unsigned type_id, int sequence, void *mesg, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_read, NULL);
+ FUNC_ENTER_NOAPI(H5O_read, NULL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert(type);
- assert(sequence >= 0);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
+ HDassert(sequence >= 0);
/* Call the "real" read routine */
- if((ret_value=H5O_read_real(ent, type, sequence, mesg, dxpl_id))==NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to load object header");
+ if((ret_value = H5O_read_real(ent, type, sequence, mesg, dxpl_id))==NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to load object header")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_read() */
@@ -1109,18 +1083,10 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
- * Bill Wendling, 2003-09-30
- * Protect the object header and pass it into the H5O_find_in_ohdr
- * function. This is done because the H5O_find_in_ohdr used to
- * protect the ohdr, find the message, and then unprotect it. This
- * saves time and also helps the FPHDF5 stuff, where unprotecting
- * actually destroys the object in the cache.
*-------------------------------------------------------------------------
*/
void *
-H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg, hid_t dxpl_id)
+H5O_read_real(const H5G_entry_t *ent, const H5O_msg_class_t *type, int sequence, void *mesg, hid_t dxpl_id)
{
H5O_t *oh = NULL;
int idx;
@@ -1128,14 +1094,14 @@ H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, voi
H5G_type_t cache_type;
void *ret_value = NULL;
- FUNC_ENTER_NOAPI_NOINIT(H5O_read_real);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_read_real)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- assert(type);
- assert(sequence >= 0);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type);
+ HDassert(sequence >= 0);
/* can we get it from the symbol table entry? */
cache = H5G_ent_cache(ent, &cache_type);
@@ -1149,16 +1115,16 @@ H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, voi
/* copy the message to the user-supplied buffer */
if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header")
/* can we get it from the object header? */
if ((idx = H5O_find_in_ohdr(ent->file, dxpl_id, oh, &type, sequence)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find message in object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find message in object header")
- if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
+ if(oh->mesg[idx].flags & H5O_FLAG_SHARED) {
/*
* If the message is shared then then the native pointer points to an
- * H5O_SHARED message. We use that information to look up the real
+ * H5O_MSG_SHARED message. We use that information to look up the real
* message in the global heap or some other object header.
*/
H5O_shared_t *shared;
@@ -1172,15 +1138,15 @@ H5O_read_real(const H5G_entry_t *ent, const H5O_class_t *type, int sequence, voi
* the raw message) so we must copy the native message before
* returning.
*/
- if (NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg, 0)))
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space");
- }
+ if(NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg, 0)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space")
+ } /* end else */
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_read_real() */
@@ -1207,10 +1173,9 @@ done:
*-------------------------------------------------------------------------
*/
static unsigned
-H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t **type_p, int sequence)
+H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t **type_p, int sequence)
{
unsigned u;
- const H5O_class_t *type = NULL;
unsigned ret_value;
FUNC_ENTER_NOAPI_NOINIT(H5O_find_in_ohdr);
@@ -1235,17 +1200,7 @@ H5O_find_in_ohdr(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t **type_p,
* Decode the message if necessary. If the message is shared then decode
* a shared message, ignoring the message type.
*/
- if (oh->mesg[u].flags & H5O_FLAG_SHARED)
- type = H5O_SHARED;
- else
- type = oh->mesg[u].type;
-
- if (NULL == oh->mesg[u].native) {
- assert(type->decode);
- 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");
- }
+ LOAD_NATIVE(f, dxpl_id, &(oh->mesg[u]), UFAIL)
/*
* Return the message type. If this is a shared message then return the
@@ -1293,45 +1248,33 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
- * Robb Matzke, 7 Jan 1998
- * Handles constant vs non-constant messages. Once a message is made
- * constant it can never become non-constant. Constant messages cannot
- * be modified.
- *
- * Changed to use IDs for types, instead of type objects, then
- * call "real" routine.
- * Quincey Koziol
- * Feb 14 2003
- *
*-------------------------------------------------------------------------
*/
int
H5O_modify(H5G_entry_t *ent, unsigned type_id, int overwrite,
unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_modify, FAIL);
+ FUNC_ENTER_NOAPI(H5O_modify, FAIL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert(type);
- assert(mesg);
- assert (0==(flags & ~H5O_FLAG_BITS));
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
+ HDassert(mesg);
+ HDassert(0 == (flags & ~H5O_FLAG_BITS));
/* Call the "real" modify routine */
if((ret_value= H5O_modify_real(ent, type, overwrite, flags, update_flags, mesg, dxpl_id))<0)
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header message")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_modify() */
@@ -1367,20 +1310,13 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
- * Robb Matzke, 7 Jan 1998
- * Handles constant vs non-constant messages. Once a message is made
- * constant it can never become non-constant. Constant messages cannot
- * be modified.
- *
*-------------------------------------------------------------------------
*/
static int
-H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
+H5O_modify_real(H5G_entry_t *ent, const H5O_msg_class_t *type, int overwrite,
unsigned flags, unsigned update_flags, const void *mesg, hid_t dxpl_id)
{
- H5O_t *oh=NULL;
+ H5O_t *oh = NULL;
int sequence;
unsigned idx; /* Index of message to modify */
H5O_mesg_t *idx_msg; /* Pointer to message to modify */
@@ -1390,57 +1326,57 @@ H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
FUNC_ENTER_NOAPI_NOINIT(H5O_modify_real)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- assert(type);
- assert(mesg);
- assert (0==(flags & ~H5O_FLAG_BITS));
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(type);
+ HDassert(mesg);
+ HDassert(0 == (flags & ~H5O_FLAG_BITS));
if (0==(ent->file->intent & H5F_ACC_RDWR))
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Count similar messages */
- for (idx = 0, sequence = -1, idx_msg=&oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) {
- if (type->id != idx_msg->type->id)
+ for(idx = 0, sequence = -1, idx_msg=&oh->mesg[0]; idx < oh->nmesgs; idx++, idx_msg++) {
+ if(type->id != idx_msg->type->id)
continue;
- if (++sequence == overwrite)
+ if(++sequence == overwrite)
break;
} /* end for */
/* Was the right message found? */
- if (overwrite >= 0 && (idx >= oh->nmesgs || sequence != overwrite)) {
+ if(overwrite >= 0 && (idx >= oh->nmesgs || sequence != overwrite)) {
/* But can we insert a new one with this sequence number? */
- if (overwrite == sequence + 1)
+ if(overwrite == sequence + 1)
overwrite = -1;
else
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found");
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found")
} /* end if */
/* Check for creating new message */
- if (overwrite < 0) {
+ if(overwrite < 0) {
/* Create a new message */
if((idx=H5O_new_mesg(ent->file,oh,&flags,type,mesg,&sh_mesg,&type,&mesg,dxpl_id))==UFAIL)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create new message")
/* Set the correct sequence number for the message created */
sequence++;
- } else if (oh->mesg[idx].flags & H5O_FLAG_CONSTANT) {
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message");
- } else if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify shared (constant) message");
+ } else if(oh->mesg[idx].flags & H5O_FLAG_CONSTANT) {
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message")
+ } else if(oh->mesg[idx].flags & H5O_FLAG_SHARED) {
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify shared (constant) message")
}
/* Write the information to the message */
if(H5O_write_mesg(oh,idx,type,mesg,flags,update_flags)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to write message")
/* Update the modification time message if any */
- if(update_flags&H5O_UPDATE_TIME)
+ if(update_flags & H5O_UPDATE_TIME)
H5O_touch_oh(ent->file, oh, FALSE);
/* Set return value */
@@ -1448,9 +1384,9 @@ H5O_modify_real(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_modify_real() */
@@ -1470,8 +1406,6 @@ done:
* koziol@ncsa.uiuc.edu
* Dec 31 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
H5O_t *
@@ -1479,21 +1413,21 @@ H5O_protect(H5G_entry_t *ent, hid_t dxpl_id)
{
H5O_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_protect, NULL);
+ FUNC_ENTER_NOAPI(H5O_protect, NULL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
- if (0==(ent->file->intent & H5F_ACC_RDWR))
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, NULL, "no write intent on file");
+ if(0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, NULL, "no write intent on file")
if (NULL == (ret_value = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_protect() */
@@ -1512,28 +1446,26 @@ done:
* koziol@ncsa.uiuc.edu
* Dec 31 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_unprotect(H5G_entry_t *ent, H5O_t *oh, hid_t dxpl_id)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_unprotect, FAIL);
+ FUNC_ENTER_NOAPI(H5O_unprotect, FAIL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- assert(oh);
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ HDassert(oh);
- if (H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ if(H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_unprotect() */
@@ -1552,19 +1484,13 @@ done:
* koziol@ncsa.uiuc.edu
* Dec 31 2002
*
- * Modifications:
- * Changed to use IDs for types, instead of type objects, then
- * call "real" routine.
- * Quincey Koziol
- * Feb 14 2003
- *
*-------------------------------------------------------------------------
*/
int
H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned flags,
const void *mesg)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_append,FAIL);
@@ -1572,8 +1498,8 @@ H5O_append(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned type_id, unsigned flags,
/* check args */
assert(f);
assert(oh);
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(0==(flags & ~H5O_FLAG_BITS));
assert(mesg);
@@ -1602,12 +1528,10 @@ done:
* koziol@ncsa.uiuc.edu
* Dec 31 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static int
-H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_class_t *type,
+H5O_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type,
unsigned flags, const void *mesg)
{
unsigned idx; /* Index of message to modify */
@@ -1655,8 +1579,8 @@ done:
*-------------------------------------------------------------------------
*/
static unsigned
-H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_class_t *orig_type,
- const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_class_t **new_type,
+H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_msg_class_t *orig_type,
+ const void *orig_mesg, H5O_shared_t *sh_mesg, const H5O_msg_class_t **new_type,
const void **new_mesg, hid_t dxpl_id)
{
size_t size; /* Size of space allocated for object header */
@@ -1680,7 +1604,7 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_class_t *orig_type,
if (NULL==orig_type->get_share)
HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, UFAIL, "message class is not sharable");
- if ((orig_type->get_share)(f, orig_mesg, sh_mesg/*out*/)<0) {
+ if ((orig_type->get_share)(f, orig_mesg, sh_mesg/*out*/) < 0) {
/*
* If the message isn't shared then turn off the shared bit
* and treat it as an unshared message.
@@ -1689,7 +1613,7 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_class_t *orig_type,
*flags &= ~H5O_FLAG_SHARED;
} else {
/* Change type & message to use shared information */
- *new_type=H5O_SHARED;
+ *new_type=H5O_MSG_SHARED;
*new_mesg=sh_mesg;
} /* end else */
} /* end if */
@@ -1700,14 +1624,14 @@ H5O_new_mesg(H5F_t *f, H5O_t *oh, unsigned *flags, const H5O_class_t *orig_type,
/* Compute the size needed to store the message on disk */
if ((size = ((*new_type)->raw_size) (f, *new_mesg)) >=H5O_MAX_SIZE)
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, UFAIL, "object header message is too large (16k max)");
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, UFAIL, "object header message is too large");
/* Allocate space in the object headed for the message */
if ((ret_value = H5O_alloc(f, oh, orig_type, size)) == UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, UFAIL, "unable to allocate space for message");
/* Increment any links in message */
- if((*new_type)->link && ((*new_type)->link)(f,dxpl_id,(*new_mesg))<0)
+ if((*new_type)->link && ((*new_type)->link)(f,dxpl_id,(*new_mesg)) < 0)
HGOTO_ERROR (H5E_OHDR, H5E_LINK, UFAIL, "unable to adjust shared object link count");
done:
@@ -1725,12 +1649,10 @@ done:
* Programmer: Quincey Koziol
* Friday, September 3, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_class_t *type,
+H5O_write_mesg(H5O_t *oh, unsigned idx, const H5O_msg_class_t *type,
const void *mesg, unsigned flags, unsigned update_flags)
{
H5O_mesg_t *idx_msg; /* Pointer to message to modify */
@@ -1775,17 +1697,12 @@ done:
* Programmer: Robb Matzke
* Monday, July 27, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force)
{
unsigned idx;
-#ifdef H5_HAVE_GETTIMEOFDAY
- struct timeval now_tv;
-#endif /* H5_HAVE_GETTIMEOFDAY */
time_t now;
size_t size;
herr_t ret_value=SUCCEED; /* Return value */
@@ -1795,14 +1712,18 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force)
assert(oh);
/* Look for existing message */
- for (idx=0; idx<oh->nmesgs; idx++) {
- if (H5O_MTIME==oh->mesg[idx].type || H5O_MTIME_NEW==oh->mesg[idx].type)
+ for (idx=0; idx < oh->nmesgs; idx++) {
+ if (H5O_MSG_MTIME==oh->mesg[idx].type || H5O_MSG_MTIME_NEW==oh->mesg[idx].type)
break;
}
#ifdef H5_HAVE_GETTIMEOFDAY
- HDgettimeofday(&now_tv,NULL);
- now=now_tv.tv_sec;
+ {
+ struct timeval now_tv;
+
+ HDgettimeofday(&now_tv, NULL);
+ now = now_tv.tv_sec;
+ }
#else /* H5_HAVE_GETTIMEOFDAY */
now = HDtime(NULL);
#endif /* H5_HAVE_GETTIMEOFDAY */
@@ -1811,8 +1732,9 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force)
if (idx==oh->nmesgs) {
if (!force)
HGOTO_DONE(SUCCEED); /*nothing to do*/
- size = (H5O_MTIME_NEW->raw_size)(f, &now);
- if ((idx=H5O_alloc(f, oh, H5O_MTIME_NEW, size))==UFAIL)
+ size = (H5O_MSG_MTIME_NEW->raw_size)(f, &now);
+
+ if ((idx=H5O_alloc(f, oh, H5O_MSG_MTIME_NEW, size))==UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message");
}
@@ -1843,39 +1765,37 @@ done:
* Programmer: Robb Matzke
* Monday, July 27, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_touch(H5G_entry_t *ent, hbool_t force, hid_t dxpl_id)
{
H5O_t *oh = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_touch, FAIL);
+ FUNC_ENTER_NOAPI(H5O_touch, FAIL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
- if (0==(ent->file->intent & H5F_ACC_RDWR))
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
+ if(0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Get the object header */
if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Create/Update the modification time message */
if (H5O_touch_oh(ent->file, oh, force)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object modificaton time");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object modificaton time")
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_touch() */
#ifdef H5O_ENABLE_BOGUS
@@ -1890,36 +1810,34 @@ done:
* <koziol@ncsa.uiuc.edu>
* Tuesday, January 21, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_bogus_oh(H5F_t *f, H5O_t *oh)
{
int idx;
- size_t size;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER(H5O_bogus_oh, FAIL);
+ FUNC_ENTER(H5O_bogus_oh, FAIL)
- assert(f);
- assert(oh);
+ HDassert(f);
+ HDassert(oh);
/* Look for existing message */
- for (idx=0; idx<oh->nmesgs; idx++)
- if (H5O_BOGUS==oh->mesg[idx].type)
+ for(idx = 0; idx < oh->nmesgs; idx++)
+ if(H5O_MSG_BOGUS == oh->mesg[idx].type)
break;
/* Create a new message */
- if (idx==oh->nmesgs) {
- size = (H5O_BOGUS->raw_size)(f, NULL);
- if ((idx=H5O_alloc(f, oh, H5O_BOGUS, size))<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message");
+ if(idx == oh->nmesgs) {
+ size_t size = (H5O_MSG_BOGUS->raw_size)(f, NULL);
+
+ if((idx = H5O_alloc(f, oh, H5O_MSG_BOGUS, size))<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message")
/* Allocate the native message in memory */
- if (NULL==(oh->mesg[idx].native = H5MM_malloc(sizeof(H5O_bogus_t))))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message");
+ if(NULL == (oh->mesg[idx].native = H5MM_malloc(sizeof(H5O_bogus_t))))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message")
/* Update the native part */
((H5O_bogus_t *)(oh->mesg[idx].native))->u = H5O_BOGUS_VALUE;
@@ -1930,7 +1848,7 @@ H5O_bogus_oh(H5F_t *f, H5O_t *oh)
} /* end if */
done:
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(ret_value)
} /* end H5O_bogus_oh() */
@@ -1945,8 +1863,6 @@ done:
* <koziol@ncsa.uiuc.edu>
* Tuesday, January 21, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1955,30 +1871,30 @@ H5O_bogus(H5G_entry_t *ent, hid_t dxpl_id)
H5O_t *oh = NULL;
herr_t ret_value = SUCCEED;
- FUNC_ENTER(H5O_bogus, FAIL);
+ FUNC_ENTER(H5O_bogus, FAIL)
/* check args */
- assert(ent);
- assert(ent->file);
- assert(H5F_addr_defined(ent->header));
+ HDassert(ent);
+ HDassert(ent->file);
+ HDassert(H5F_addr_defined(ent->header));
/* Verify write access to the file */
if (0==(ent->file->intent & H5F_ACC_RDWR))
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Get the object header */
if (NULL==(oh=H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Create the "bogus" message */
if (H5O_bogus_oh(ent->file, oh)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object 'bogus' message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object 'bogus' message")
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(ret_value)
} /* end H5O_bogus() */
#endif /* H5O_ENABLE_BOGUS */
@@ -2016,7 +1932,7 @@ done:
herr_t
H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence, hbool_t adj_link, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_remove, FAIL)
@@ -2025,8 +1941,8 @@ H5O_remove(H5G_entry_t *ent, unsigned type_id, int sequence, hbool_t adj_link, h
HDassert(ent);
HDassert(ent->file);
HDassert(H5F_addr_defined(ent->header));
- HDassert(type_id < NELMTS(message_type_g));
- type = message_type_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
/* Call the "real" remove routine */
@@ -2059,7 +1975,7 @@ herr_t
H5O_remove_op(H5G_entry_t *ent, unsigned type_id,
H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_remove_op, FAIL)
@@ -2068,8 +1984,8 @@ H5O_remove_op(H5G_entry_t *ent, unsigned type_id,
HDassert(ent);
HDassert(ent->file);
HDassert(H5F_addr_defined(ent->header));
- HDassert(type_id < NELMTS(message_type_g));
- type = message_type_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
/* Call the "real" remove routine */
@@ -2094,8 +2010,6 @@ done:
* koziol@ncsa.uiuc.edu
* Sep 6 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2129,19 +2043,19 @@ H5O_remove_cb(H5O_mesg_t *mesg/*in,out*/, unsigned idx, unsigned * oh_flags_ptr,
* Keep track of how many times we failed trying to remove constant
* messages.
*/
- if (mesg->flags & H5O_FLAG_CONSTANT) {
+ if(mesg->flags & H5O_FLAG_CONSTANT) {
udata->nfailed++;
} /* end if */
else {
/* Free any space referred to in the file from this message */
- if(H5O_delete_mesg(udata->f, udata->dxpl_id, mesg, udata->adj_link)<0)
+ if(H5O_delete_mesg(udata->f, udata->dxpl_id, mesg, udata->adj_link) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, H5O_ITER_ERROR, "unable to delete file space for object header message")
/* Free any native information */
H5O_free_mesg(mesg);
/* Change message type to nil and zero it */
- mesg->type = H5O_NULL;
+ mesg->type = H5O_MSG_NULL;
HDmemset(mesg->raw, 0, mesg->raw_size);
/* Indicate that the message was modified */
@@ -2179,15 +2093,10 @@ done:
* matzke@llnl.gov
* Aug 28 1997
*
- * Modifications:
- *
- * Robb Matzke, 7 Jan 1998
- * Does not remove constant messages.
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence,
+H5O_remove_real(H5G_entry_t *ent, const H5O_msg_class_t *type, int sequence,
H5O_operator_t op, void *op_data, hbool_t adj_link, hid_t dxpl_id)
{
H5O_iter_ud1_t udata; /* User data for iterator */
@@ -2217,7 +2126,7 @@ H5O_remove_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence,
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "error iterating over messages")
/* Fail if we tried to remove any constant messages */
- if (udata.nfailed)
+ if(udata.nfailed)
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)")
done:
@@ -2225,6 +2134,53 @@ done:
} /* end H5O_remove_real() */
+/*-------------------------------------------------------------------------
+ *
+ * Function: H5O_alloc_msgs
+ *
+ * Purpose: Allocate more messages for a header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Nov 21 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_alloc_msgs(H5O_t *oh, size_t min_alloc)
+{
+ size_t old_alloc; /* Old number of messages allocated */
+ size_t na; /* New number of messages allocated */
+ H5O_mesg_t *new_mesg; /* Pointer to new message array */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_msgs)
+
+ /* check args */
+ HDassert(oh);
+
+ /* Initialize number of messages information */
+ old_alloc = oh->alloc_nmesgs;
+ na = oh->alloc_nmesgs + MAX (H5O_NMESGS, min_alloc);
+
+ /* Attempt to allocate more memory */
+ if(NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Update ohdr information */
+ oh->alloc_nmesgs = na;
+ oh->mesg = new_mesg;
+
+ /* Set new object header info to zeros */
+ HDmemset(&oh->mesg[old_alloc], 0, (oh->alloc_nmesgs - old_alloc) * sizeof(H5O_mesg_t));
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5O_alloc_msgs() */
+
+
/*-------------------------------------------------------------------------
* Function: H5O_alloc_extend_chunk
*
@@ -2249,12 +2205,6 @@ done:
* matzke@llnl.gov
* Aug 7 1997
*
- * Modifications:
- * Robb Matzke, 1999-08-26
- * If new memory is allocated as a multiple of some alignment
- * then we're careful to initialize the part of the new memory
- * from the end of the expected message to the end of the new
- * memory.
*-------------------------------------------------------------------------
*/
static unsigned
@@ -2267,15 +2217,15 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
uint8_t *old_addr;
unsigned ret_value;
- FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_extend_chunk);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_extend_chunk)
/* check args */
- assert(oh);
- assert(chunkno < oh->nchunks);
- assert(size > 0);
+ HDassert(oh);
+ HDassert(chunkno < oh->nchunks);
+ HDassert(size > 0);
- if (H5F_addr_defined(oh->chunk[chunkno].addr))
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "chunk is on disk");
+ if(H5F_addr_defined(oh->chunk[chunkno].addr))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "chunk is on disk")
/* try to extend a null message */
for (idx=0; idx<oh->nmesgs; idx++) {
@@ -2323,20 +2273,16 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
delta = H5O_ALIGN(delta);
if( H5MF_reserve(f, (hsize_t)delta) < 0 )
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to reserve space in file")
/* create a new null message */
- if (oh->nmesgs >= oh->alloc_nmesgs) {
- unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
- H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, (size_t)na);
-
- if (NULL==x)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
- oh->alloc_nmesgs = na;
- oh->mesg = x;
- }
+ if(oh->nmesgs >= oh->alloc_nmesgs) {
+ if(H5O_alloc_msgs(oh, (size_t)0) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't allocate more space for messages")
+ } /* end if */
+
idx = oh->nmesgs++;
- oh->mesg[idx].type = H5O_NULL;
+ oh->mesg[idx].type = H5O_MSG_NULL;
oh->mesg[idx].dirty = TRUE;
oh->mesg[idx].native = NULL;
oh->mesg[idx].raw = oh->chunk[chunkno].image +
@@ -2345,15 +2291,17 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
oh->mesg[idx].raw_size = delta - H5O_SIZEOF_MSGHDR(f);
oh->mesg[idx].chunkno = chunkno;
+ /* Allocate more memory space for chunk's image */
old_addr = oh->chunk[chunkno].image;
old_size = oh->chunk[chunkno].size;
oh->chunk[chunkno].size += delta;
oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr,
oh->chunk[chunkno].size);
- if (NULL==oh->chunk[chunkno].image)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
- HDmemset(oh->chunk[chunkno].image+old_size, 0,
- oh->chunk[chunkno].size - old_size);
+ if(NULL == oh->chunk[chunkno].image)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed")
+
+ /* Wipe new space for chunk */
+ HDmemset(oh->chunk[chunkno].image + old_size, 0, oh->chunk[chunkno].size - old_size);
/* adjust raw addresses for messages of this chunk */
if (old_addr != oh->chunk[chunkno].image) {
@@ -2361,8 +2309,8 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size)
if (oh->mesg[u].chunkno == chunkno)
oh->mesg[u].raw = oh->chunk[chunkno].image +
(oh->mesg[u].raw - old_addr);
- }
- }
+ } /* end if */
+ } /* end for */
/* Set return value */
ret_value=idx;
@@ -2395,8 +2343,6 @@ done:
* matzke@llnl.gov
* Aug 7 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static unsigned
@@ -2412,11 +2358,11 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
unsigned u;
unsigned ret_value; /*return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_new_chunk);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc_new_chunk)
/* check args */
- HDassert (oh);
- HDassert (size > 0);
+ HDassert(oh);
+ HDassert(size > 0);
size = H5O_ALIGN(size);
/*
@@ -2426,7 +2372,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* Don't ever move continuation message from one chunk to another.
*/
cont_size = H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
- for (u=0; u<oh->nmesgs; u++) {
+ for(u = 0; u < oh->nmesgs; u++) {
if (H5O_NULL_ID == oh->mesg[u].type->id) {
if (cont_size == oh->mesg[u].raw_size) {
found_null = u;
@@ -2443,16 +2389,16 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
(found_other < 0 ||
oh->mesg[u].raw_size < oh->mesg[found_other].raw_size)) {
found_other = u;
- }
- }
- assert(found_null >= 0 || found_other >= 0);
+ } /* end else */
+ } /* end for */
+ HDassert(found_null >= 0 || found_other >= 0);
/*
* If we must move some other message to make room for the null
* message, then make sure the new chunk has enough room for that
* other message.
*/
- if (found_null < 0)
+ if(found_null < 0)
size += H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size;
/*
@@ -2461,7 +2407,7 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* multiple of the alignment size.
*/
size = MAX(H5O_MIN_SIZE, size + H5O_SIZEOF_MSGHDR(f));
- assert (size == H5O_ALIGN (size));
+ HDassert(size == H5O_ALIGN (size));
/* Reserve space in the file to hold the new chunk */
if( H5MF_reserve(f, (hsize_t)size) < 0 )
@@ -2470,48 +2416,38 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
/*
* Create the new chunk without giving it a file address.
*/
- 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)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
+ if(!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed")
oh->alloc_nchunks = na;
oh->chunk = x;
- }
+ } /* end if */
+
chunkno = oh->nchunks++;
oh->chunk[chunkno].dirty = TRUE;
oh->chunk[chunkno].addr = HADDR_UNDEF;
oh->chunk[chunkno].size = size;
if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_CALLOC(chunk_image,size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed")
/*
* Make sure we have enough space for all possible new messages
* that could be generated below.
*/
- if (oh->nmesgs + 3 > oh->alloc_nmesgs) {
- int old_alloc=oh->alloc_nmesgs;
- unsigned na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3);
- H5O_mesg_t *x = H5FL_SEQ_REALLOC (H5O_mesg_t, oh->mesg, (size_t)na);
-
- if (!x)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
- oh->alloc_nmesgs = na;
- oh->mesg = x;
-
- /* Set new object header info to zeros */
- HDmemset(&oh->mesg[old_alloc], 0,
- (oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
- }
+ if(oh->nmesgs + 3 > oh->alloc_nmesgs) {
+ if(H5O_alloc_msgs(oh, (size_t)3) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't allocate more space for messages")
+ } /* end if */
/*
* Describe the messages of the new chunk.
*/
- if (found_null < 0) {
+ if(found_null < 0) {
found_null = u = oh->nmesgs++;
- oh->mesg[u].type = H5O_NULL;
+ oh->mesg[u].type = H5O_MSG_NULL;
oh->mesg[u].dirty = TRUE;
oh->mesg[u].native = NULL;
oh->mesg[u].raw = oh->mesg[found_other].raw;
@@ -2527,9 +2463,9 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
oh->mesg[found_other].chunkno = chunkno;
p += H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size;
size -= H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size;
- }
+ } /* end if */
idx = oh->nmesgs++;
- oh->mesg[idx].type = H5O_NULL;
+ oh->mesg[idx].type = H5O_MSG_NULL;
oh->mesg[idx].dirty = TRUE;
oh->mesg[idx].native = NULL;
oh->mesg[idx].raw = p + H5O_SIZEOF_MSGHDR(f);
@@ -2541,9 +2477,9 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* is larger than the continuation message, then split it into
* two null messages.
*/
- if (oh->mesg[found_null].raw_size > cont_size) {
+ if(oh->mesg[found_null].raw_size > cont_size) {
u = oh->nmesgs++;
- oh->mesg[u].type = H5O_NULL;
+ oh->mesg[u].type = H5O_MSG_NULL;
oh->mesg[u].dirty = TRUE;
oh->mesg[u].native = NULL;
oh->mesg[u].raw = oh->mesg[found_null].raw +
@@ -2555,12 +2491,12 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
oh->mesg[found_null].dirty = TRUE;
oh->mesg[found_null].raw_size = cont_size;
- }
+ } /* end if */
/*
* Initialize the continuation message.
*/
- oh->mesg[found_null].type = H5O_CONT;
+ oh->mesg[found_null].type = H5O_MSG_CONT;
oh->mesg[found_null].dirty = TRUE;
if (NULL==(cont = H5FL_MALLOC(H5O_cont_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed")
@@ -2570,10 +2506,10 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
oh->mesg[found_null].native = cont;
/* Set return value */
- ret_value=idx;
+ ret_value = idx;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5O_alloc_new_chunk() */
@@ -2590,30 +2526,28 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static unsigned
-H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
+H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, size_t size)
{
- unsigned idx;
H5O_mesg_t *msg; /* Pointer to newly allocated message */
size_t aligned_size = H5O_ALIGN(size);
+ unsigned idx; /* Index of message which fits allocation */
unsigned ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_alloc);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_alloc)
/* check args */
- HDassert (oh);
- HDassert (type);
+ HDassert(oh);
+ HDassert(type);
/* look for a null message which is large enough */
- for (idx = 0; idx < oh->nmesgs; idx++) {
- if (H5O_NULL_ID == oh->mesg[idx].type->id &&
+ for(idx = 0; idx < oh->nmesgs; idx++) {
+ if(H5O_NULL_ID == oh->mesg[idx].type->id &&
oh->mesg[idx].raw_size >= aligned_size)
break;
- }
+ } /* end for */
#ifdef LATER
/*
@@ -2626,7 +2560,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
#endif
/* if we didn't find one, then allocate more header space */
- if (idx >= oh->nmesgs) {
+ if(idx >= oh->nmesgs) {
unsigned chunkno;
/*
@@ -2642,48 +2576,38 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
/* if idx is still UFAIL, we were not able to extend a chunk.
* Create a new one.
*/
- if(idx == UFAIL) {
+ if(idx == UFAIL)
if ((idx = H5O_alloc_new_chunk(f, oh, size)) == UFAIL)
HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "unable to create a new object header data chunk")
- }
- }
+ } /* end if */
/* Set pointer to newly allocated message */
msg = &(oh->mesg[idx]);
/* do we need to split the null message? */
- if (msg->raw_size > aligned_size) {
+ if(msg->raw_size > aligned_size) {
H5O_mesg_t *null_msg; /* Pointer to null message */
- size_t mesg_size = aligned_size+ H5O_SIZEOF_MSGHDR(f); /* Total size of newly allocated message */
+ size_t mesg_size = aligned_size + H5O_SIZEOF_MSGHDR(f); /* Total size of newly allocated message */
HDassert(msg->raw_size - aligned_size >= H5O_SIZEOF_MSGHDR(f));
- if (oh->nmesgs >= oh->alloc_nmesgs) {
- int old_alloc=oh->alloc_nmesgs;
- unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
- H5O_mesg_t *x = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, (size_t)na);
-
- if (!x)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
- oh->alloc_nmesgs = na;
- oh->mesg = x;
-
- /* Set new object header info to zeros */
- HDmemset(&oh->mesg[old_alloc],0,
- (oh->alloc_nmesgs-old_alloc)*sizeof(H5O_mesg_t));
+ /* Check if we need to extend message table */
+ if(oh->nmesgs >= oh->alloc_nmesgs) {
+ if(H5O_alloc_msgs(oh, (size_t)0) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't allocate more space for messages")
/* "Retarget" local 'msg' pointer into newly allocated array of messages */
- msg=&oh->mesg[idx];
- }
+ msg = &oh->mesg[idx];
+ } /* end if */
null_msg = &(oh->mesg[oh->nmesgs++]);
- null_msg->type = H5O_NULL;
+ null_msg->type = H5O_MSG_NULL;
null_msg->dirty = TRUE;
null_msg->native = NULL;
null_msg->raw = msg->raw + mesg_size;
null_msg->raw_size = msg->raw_size - mesg_size;
null_msg->chunkno = msg->chunkno;
msg->raw_size = aligned_size;
- }
+ } /* end if */
/* initialize the new message */
msg->type = type;
@@ -2696,7 +2620,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
ret_value = idx;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5O_alloc() */
#ifdef NOT_YET
@@ -2719,7 +2643,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_share (H5F_t *f, hid_t dxpl_id, const H5O_class_t *type, const void *mesg,
+H5O_share (H5F_t *f, hid_t dxpl_id, const H5O_msg_class_t *type, const void *mesg,
H5HG_t *hobj/*out*/)
{
size_t size;
@@ -2738,9 +2662,9 @@ H5O_share (H5F_t *f, hid_t dxpl_id, const H5O_class_t *type, const void *mesg,
if ((size = (type->raw_size)(f, mesg))>0) {
if (NULL==(buf = H5MM_malloc (size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- if ((type->encode)(f, buf, mesg)<0)
+ if ((type->encode)(f, buf, mesg) < 0)
HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
- if (H5HG_insert (f, dxpl_id, size, buf, hobj)<0)
+ if (H5HG_insert (f, dxpl_id, size, buf, hobj) < 0)
HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL, "unable to store message in global heap");
}
@@ -2765,21 +2689,19 @@ done:
* koziol@ncsa.uiuc.edu
* Feb 13 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
size_t
H5O_raw_size(unsigned type_id, const H5F_t *f, const void *mesg)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_raw_size,0)
/* Check args */
- HDassert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
HDassert(type->raw_size);
HDassert(f);
@@ -2811,14 +2733,14 @@ done:
size_t
H5O_mesg_size(unsigned type_id, const H5F_t *f, const void *mesg)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_mesg_size,0)
/* Check args */
- HDassert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
HDassert(type->raw_size);
HDassert(f);
@@ -2861,26 +2783,26 @@ done:
herr_t
H5O_get_share(unsigned type_id, H5F_t *f, const void *mesg, H5O_shared_t *share)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5O_get_share,FAIL);
+ FUNC_ENTER_NOAPI(H5O_get_share,FAIL)
/* Check args */
- assert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
- assert (type);
- assert (type->get_share);
- assert (f);
- assert (mesg);
- assert (share);
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type);
+ HDassert(type->get_share);
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(share);
/* Compute the raw data size for the mesg */
- if ((ret_value = (type->get_share)(f, mesg, share))<0)
- HGOTO_ERROR (H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve shared message information");
+ if((ret_value = (type->get_share)(f, mesg, share)) < 0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve shared message information")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_get_share() */
@@ -2898,35 +2820,33 @@ done:
* koziol@ncsa.uiuc.edu
* Mar 19 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
{
- H5O_t *oh=NULL; /* Object header information */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5O_t *oh = NULL; /* Object header information */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_delete,FAIL);
+ FUNC_ENTER_NOAPI(H5O_delete,FAIL)
/* Check args */
- assert (f);
- assert(H5F_addr_defined(addr));
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
/* Get the object header information */
- if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_WRITE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ if(NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_WRITE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Delete object */
- if(H5O_delete_oh(f,dxpl_id,oh)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file");
+ if(H5O_delete_oh(f, dxpl_id, oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
done:
if (oh && H5AC_unprotect(f, dxpl_id, H5AC_OHDR, addr, oh, TRUE)<0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_delete() */
@@ -2945,54 +2865,36 @@ done:
* koziol@ncsa.uiuc.edu
* Mar 19 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
{
H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
- H5O_chunk_t *curr_chk; /* Pointer to current chunk being operated on */
unsigned u;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_delete_oh);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_delete_oh)
/* Check args */
- assert (f);
- assert (oh);
+ HDassert(f);
+ HDassert(oh);
/* Walk through the list of object header messages, asking each one to
* delete any file space used
*/
- for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) {
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
/* Free any space referred to in the file from this message */
- if(H5O_delete_mesg(f, dxpl_id, curr_msg, TRUE)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message");
+ if(H5O_delete_mesg(f, dxpl_id, curr_msg, TRUE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message")
} /* end for */
- /* Free all the chunks for the object header */
- for (u = 0, curr_chk=&oh->chunk[0]; u < oh->nchunks; u++,curr_chk++) {
- haddr_t chk_addr; /* Actual address of chunk */
- hsize_t chk_size; /* Actual size of chunk */
-
- if(u==0) {
- chk_addr = curr_chk->addr - H5O_SIZEOF_HDR(f);
- chk_size = curr_chk->size + H5O_SIZEOF_HDR(f);
- } /* end if */
- else {
- chk_addr = curr_chk->addr;
- chk_size = curr_chk->size;
- } /* end else */
-
- /* Free the file space for the chunk */
- if (H5MF_xfree(f, H5FD_MEM_OHDR, dxpl_id, chk_addr, chk_size)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header");
- } /* end for */
+ /* Free main (first) object header "chunk" */
+ if(H5MF_xfree(f, H5FD_MEM_OHDR, dxpl_id, (oh->chunk[0].addr - H5O_SIZEOF_HDR(f)), (hsize_t)(oh->chunk[0].size + H5O_SIZEOF_HDR(f))) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_delete_oh() */
@@ -3009,25 +2911,23 @@ done:
* koziol@ncsa.uiuc.edu
* September 26 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link)
{
- const H5O_class_t *type; /* Type of object to free */
+ const H5O_msg_class_t *type; /* Type of object to free */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_delete_mesg);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_delete_mesg)
/* Check args */
- assert (f);
- assert (mesg);
+ HDassert(f);
+ HDassert(mesg);
/* Get the message to free's type */
if(mesg->flags & H5O_FLAG_SHARED)
- type=H5O_SHARED;
+ type = H5O_MSG_SHARED;
else
type = mesg->type;
@@ -3036,19 +2936,19 @@ H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_mesg_t *mesg, hbool_t adj_link)
/*
* Decode the message if necessary.
*/
- if (NULL == mesg->native) {
- assert(type->decode);
+ if(NULL == mesg->native) {
+ HDassert(type->decode);
mesg->native = (type->decode) (f, dxpl_id, mesg->raw);
- if (NULL == mesg->native)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message");
+ if(NULL == mesg->native)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode message")
} /* end if */
- if ((type->del)(f, dxpl_id, mesg->native, adj_link)<0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message");
+ if((type->del)(f, dxpl_id, mesg->native, adj_link) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message")
} /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_delete_msg() */
@@ -3063,53 +2963,51 @@ done:
* koziol@ncsa.uiuc.edu
* Oct 7 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id)
{
- H5O_t *oh=NULL; /* Object header information */
+ H5O_t *oh = NULL; /* Object header information */
H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
hsize_t total_size; /* Total amount of space used in file */
hsize_t free_space; /* Free space in object header */
unsigned u; /* Local index variable */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_get_info,FAIL);
+ FUNC_ENTER_NOAPI(H5O_get_info,FAIL)
/* Check args */
- assert (ent);
- assert (ostat);
+ HDassert(ent);
+ HDassert(ostat);
/* Get the object header information */
if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* Iterate over all the messages, accumulating the total size & free space */
- total_size=H5O_SIZEOF_HDR(ent->file);
- free_space=0;
- for (u = 0, curr_msg=&oh->mesg[0]; u < oh->nmesgs; u++,curr_msg++) {
+ total_size = H5O_SIZEOF_HDR(ent->file);
+ free_space = 0;
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
/* Accumulate the size for this message */
total_size+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size;
/* Check for this message being free space */
- if (H5O_NULL_ID == curr_msg->type->id)
+ if(H5O_NULL_ID == curr_msg->type->id)
free_space+= H5O_SIZEOF_MSGHDR(ent->file) + curr_msg->raw_size;
} /* end for */
/* Set the information for this object header */
- ostat->size=total_size;
- ostat->free=free_space;
- ostat->nmesgs=oh->nmesgs;
- ostat->nchunks=oh->nchunks;
+ ostat->size = total_size;
+ ostat->free = free_space;
+ ostat->nmesgs = oh->nmesgs;
+ ostat->nchunks = oh->nchunks;
done:
if (oh && H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE)<0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_get_info() */
@@ -3142,16 +3040,14 @@ done:
* C. Negative causes the iterator to immediately return that value,
* indicating failure.
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5O_iterate(const H5G_entry_t *ent, unsigned type_id, H5O_operator_t op,
void *op_data, hid_t dxpl_id)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
- herr_t ret_value=0; /* Return value */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
+ herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_iterate, FAIL)
@@ -3159,8 +3055,8 @@ H5O_iterate(const H5G_entry_t *ent, unsigned type_id, H5O_operator_t op,
HDassert(ent);
HDassert(ent->file);
HDassert(H5F_addr_defined(ent->header));
- HDassert(type_id<NELMTS(message_type_g));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ HDassert(type_id < NELMTS(H5O_msg_class_g));
+ type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
/* Call the "real" iterate routine */
@@ -3206,10 +3102,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_iterate_real(const H5G_entry_t *ent, const H5O_class_t *type, H5AC_protect_t prot,
+H5O_iterate_real(const H5G_entry_t *ent, const H5O_msg_class_t *type, H5AC_protect_t prot,
hbool_t internal, void *op, void *op_data, hid_t dxpl_id)
{
- H5O_t *oh=NULL; /* Pointer to actual object header */
+ H5O_t *oh = NULL; /* Pointer to actual object header */
unsigned oh_flags = FALSE; /* Start iteration with no flags set on object header */
unsigned idx; /* Absolute index of current message in all messages */
unsigned sequence; /* Relative index of current message for messages of type */
@@ -3236,19 +3132,7 @@ H5O_iterate_real(const H5G_entry_t *ent, const H5O_class_t *type, H5AC_protect_t
* Decode the message if necessary. If the message is shared then decode
* a shared message, ignoring the message type.
*/
- if (NULL == idx_msg->native) {
- const H5O_class_t *decode_type;
-
- if (idx_msg->flags & H5O_FLAG_SHARED)
- decode_type = H5O_SHARED;
- else
- decode_type = type;
-
- /* Decode the message if necessary */
- HDassert(decode_type->decode);
- 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 */
+ LOAD_NATIVE(ent->file, dxpl_id, idx_msg, FAIL)
/* Check for making an "internal" (i.e. within the H5O package) callback */
if(internal) {
@@ -3300,16 +3184,16 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth)
+H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth)
{
- const H5O_class_t *type; /* Actual H5O class type for the ID */
+ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_debug_id,FAIL);
/* Check args */
- assert(type_id>=0 && type_id<(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])));
- type=message_type_g[type_id]; /* map the type ID to the actual type object */
+ assert(type_id < NELMTS(H5O_msg_class_g));
+ type=H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
assert(type);
assert(type->debug);
assert(f);
@@ -3319,7 +3203,7 @@ H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *str
assert(fwidth >= 0);
/* Call the debug method in the class */
- if ((ret_value = (type->debug)(f, dxpl_id, mesg, stream, indent, fwidth))<0)
+ if ((ret_value = (type->debug)(f, dxpl_id, mesg, stream, indent, fwidth)) < 0)
HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, FAIL, "unable to debug message");
done:
@@ -3338,9 +3222,6 @@ done:
* matzke@llnl.gov
* Aug 6 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
@@ -3351,21 +3232,21 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
size_t mesg_total = 0, chunk_total = 0;
int *sequence;
haddr_t tmp_addr;
- herr_t ret_value = SUCCEED;
void *(*decode)(H5F_t*, hid_t, const uint8_t*);
herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL;
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5O_debug, FAIL);
+ FUNC_ENTER_NOAPI(H5O_debug, FAIL)
/* check args */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
if (NULL == (oh = H5AC_protect(f, dxpl_id, H5AC_OHDR, addr, NULL, NULL, H5AC_READ)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
/* debug */
HDfprintf(stream, "%*sObject Header...\n", indent, "");
@@ -3390,7 +3271,7 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
(unsigned) (oh->nchunks), (unsigned) (oh->alloc_nchunks));
/* debug each chunk */
- for (i=0, chunk_total=0; i<oh->nchunks; i++) {
+ for (i=0, chunk_total=0; i < oh->nchunks; i++) {
chunk_total += oh->chunk[i].size;
HDfprintf(stream, "%*sChunk %d...\n", indent, "", i);
@@ -3410,15 +3291,14 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
}
/* debug each message */
- if (NULL==(sequence = H5MM_calloc(NELMTS(message_type_g)*sizeof(int))))
+ if (NULL==(sequence = H5MM_calloc(NELMTS(H5O_msg_class_g)*sizeof(int))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- for (i=0, mesg_total=0; i<oh->nmesgs; i++) {
+ for (i=0, mesg_total=0; i < oh->nmesgs; i++) {
mesg_total += H5O_SIZEOF_MSGHDR(f) + oh->mesg[i].raw_size;
HDfprintf(stream, "%*sMessage %d...\n", indent, "", i);
/* check for bad message id */
- if (oh->mesg[i].type->id < 0 ||
- oh->mesg[i].type->id >= (int)NELMTS(message_type_g)) {
+ if (oh->mesg[i].type->id >= (int)NELMTS(H5O_msg_class_g)) {
HDfprintf(stream, "*** BAD MESSAGE ID 0x%04x\n",
oh->mesg[i].type->id);
continue;
@@ -3431,6 +3311,9 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
(unsigned) (oh->mesg[i].type->id),
oh->mesg[i].type->name,
sequence[oh->mesg[i].type->id]++);
+ HDfprintf (stream, "%*s%-*s %d\n", indent+3, "", MAX (0, fwidth-3),
+ "Dirty:",
+ (int)(oh->mesg[i].dirty));
HDfprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3),
"Shared:",
(oh->mesg[i].flags & H5O_FLAG_SHARED) ? "Yes" : "No");
@@ -3451,6 +3334,9 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
chunkno = oh->mesg[i].chunkno;
if (chunkno >= oh->nchunks)
HDfprintf(stream, "*** BAD CHUNK NUMBER\n");
+ HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Raw data offset in chunk:",
+ (unsigned) (oh->mesg[i].raw - oh->chunk[chunkno].image));
/* check the size */
if ((oh->mesg[i].raw + oh->mesg[i].raw_size >
@@ -3461,8 +3347,8 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
/* decode the message */
if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
- decode = H5O_SHARED->decode;
- debug = H5O_SHARED->debug;
+ decode = H5O_MSG_SHARED->decode;
+ debug = H5O_MSG_SHARED->debug;
} else {
decode = oh->mesg[i].type->decode;
debug = oh->mesg[i].type->debug;
@@ -3498,7 +3384,7 @@ H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
done:
if (oh && H5AC_unprotect(f, dxpl_id, H5AC_OHDR, addr, oh, FALSE) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 7d278db..013ebb5 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -38,8 +38,8 @@ static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_attr_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_ATTR[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_ATTR[1] = {{
H5O_ATTR_ID, /* message id number */
"attribute", /* message name for debugging */
sizeof(H5A_t), /* native message size */
@@ -151,18 +151,18 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p)
H5O_shared_t *shared; /* Shared information */
/* Get the shared information */
- if (NULL == (shared = (H5O_SHARED->decode) (f, dxpl_id, p)))
+ if (NULL == (shared = (H5O_MSG_SHARED->decode) (f, dxpl_id, p)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "unable to decode shared message");
/* Get the actual datatype information */
- if((attr->dt= H5O_shared_read(f, dxpl_id, shared, H5O_DTYPE, NULL))==NULL)
+ if((attr->dt= H5O_shared_read(f, dxpl_id, shared, H5O_MSG_DTYPE, NULL))==NULL)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype");
/* Free the shared information */
- H5O_free_real(H5O_SHARED, shared);
+ H5O_free_real(H5O_MSG_SHARED, shared);
} /* end if */
else {
- if((attr->dt=(H5O_DTYPE->decode)(f,dxpl_id,p))==NULL)
+ if((attr->dt=(H5O_MSG_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)
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)
+ if((extent=(H5O_MSG_SDSPACE->decode)(f,dxpl_id,p))==NULL)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace");
/* Copy the extent information */
@@ -307,16 +307,16 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
HDmemset(&sh_mesg,0,sizeof(H5O_shared_t));
/* Get shared message information from datatype */
- if ((H5O_DTYPE->get_share)(f, attr->dt, &sh_mesg/*out*/)<0)
+ if ((H5O_MSG_DTYPE->get_share)(f, attr->dt, &sh_mesg/*out*/)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype");
/* Encode shared message information for datatype */
- if((H5O_SHARED->encode)(f,p,&sh_mesg)<0)
+ if((H5O_MSG_SHARED->encode)(f,p,&sh_mesg)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode shared attribute datatype");
} /* end if */
else {
/* Encode datatype information */
- if((H5O_DTYPE->encode)(f,p,attr->dt)<0)
+ if((H5O_MSG_DTYPE->encode)(f,p,attr->dt)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype");
} /* end else */
if(version < H5O_ATTR_VERSION_NEW) {
@@ -327,7 +327,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->dt_size;
/* encode the attribute dataspace */
- if((H5O_SDSPACE->encode)(f,p,&(attr->ds->extent))<0)
+ if((H5O_MSG_SDSPACE->encode)(f,p,&(attr->ds->extent))<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace");
if(version < H5O_ATTR_VERSION_NEW) {
HDmemset(p+attr->ds_size, 0, H5O_ALIGN(attr->ds_size)-attr->ds_size);
@@ -651,14 +651,14 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
HDmemset(&sh_mesg,0,sizeof(H5O_shared_t));
/* Get shared message information from datatype */
- if ((H5O_DTYPE->get_share)(f, mesg->dt, &sh_mesg/*out*/)<0)
+ if ((H5O_MSG_DTYPE->get_share)(f, mesg->dt, &sh_mesg/*out*/)<0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't retrieve shared message information");
- debug=H5O_SHARED->debug;
+ debug=H5O_MSG_SHARED->debug;
dt_mesg=&sh_mesg;
} /* end if */
else {
- debug=H5O_DTYPE->debug;
+ debug=H5O_MSG_DTYPE->debug;
dt_mesg=mesg->dt;
} /* end else */
if(debug)
diff --git a/src/H5Obogus.c b/src/H5Obogus.c
index 13b6385..5572e66 100644
--- a/src/H5Obogus.c
+++ b/src/H5Obogus.c
@@ -45,8 +45,8 @@ 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,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_BOGUS[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{
H5O_BOGUS_ID, /*message id number */
"bogus", /*message name for debugging */
0, /*native message size */
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index 4289296..201ac89 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -80,6 +80,97 @@ H5O_cache_init_interface(void)
/*-------------------------------------------------------------------------
+ * Function: H5O_flush_msgs
+ *
+ * Purpose: Flushes messages for object header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Nov 21 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_flush_msgs(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
+{
+ uint8_t *p; /* Temporary pointer to encode with */
+ int id; /* ID of message to encode */
+ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_flush_msgs)
+
+ /* check args */
+ HDassert(f);
+ HDassert(oh);
+
+ /* Encode any dirty 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);
+ HDassert(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);
+
+ /* allocate file space for chunks that have none yet */
+ if(H5O_CONT_ID == id && !H5F_addr_defined(((H5O_cont_t *)(curr_msg->native))->addr)) {
+ H5O_cont_t *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;
+ } /* end if */
+
+ /*
+ * 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)
+ encode = H5O_MSG_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")
+ } /* end if */
+ 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)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_flush_msgs() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_load
*
* Purpose: Loads an object header from disk.
@@ -92,20 +183,6 @@ 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 *
@@ -127,13 +204,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 */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(!_udata1);
- assert(!_udata2);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(!_udata1);
+ HDassert(!_udata2);
/* allocate ohdr and init chunk list */
if (NULL==(oh = H5FL_CALLOC(H5O_t)))
@@ -170,51 +247,50 @@ 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);
- assert (mesg_size==H5O_ALIGN (mesg_size));
+ HDassert(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 */
- if(id >= NELMTS(message_type_g) || NULL == message_type_g[id]) {
+ if(id >= NELMTS(H5O_msg_class_g) || NULL == H5O_msg_class_g[id]) {
skipped_msgs++;
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;
@@ -224,31 +300,31 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1,
if (oh->nmesgs >= nmesgs)
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too many messages");
mesgno = oh->nmesgs++;
- oh->mesg[mesgno].type = message_type_g[id];
+ oh->mesg[mesgno].type = H5O_msg_class_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;
- }
- }
+ } /* end else */
+ } /* end for */
- assert(p == oh->chunk[chunkno].image + chunk_size);
+ HDassert(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);
+ cont = (H5O_MSG_CONT->decode) (f, dxpl_id, oh->mesg[curmesg].raw);
oh->mesg[curmesg].native = cont;
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)
@@ -258,13 +334,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");
- }
+ 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 */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_load() */
/*-------------------------------------------------------------------------
@@ -278,104 +354,28 @@ 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
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 */
+ hbool_t combine = FALSE; /* Whether to combine the object header prefix & the first chunk */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5O_flush, FAIL);
+ FUNC_ENTER_NOAPI(H5O_flush, FAIL)
/* check args */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(oh);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(oh);
/* flush */
if(oh->cache_info.is_dirty) {
/* Encode any dirty 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;
- }
- }
-
- /* Sanity check for the correct # of messages in object header */
- if(oh->nmesgs != u)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "corrupt object header - too few messages")
+ if(H5O_flush_msgs(f, dxpl_id, oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object header messages")
/* Encode header prefix */
p = buf;
@@ -402,58 +402,55 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
/* 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;
+ combine = TRUE;
} /* 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 */
-
/* 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) {
+ for(u = 0; u < oh->nchunks; u++) {
+ if(oh->chunk[u].dirty) {
+ HDassert(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");
- }
+ if(H5O_dest(f,oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data")
+ } /* end if */
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_flush() */
/*-------------------------------------------------------------------------
@@ -467,8 +464,6 @@ done:
* koziol@ncsa.uiuc.edu
* Jan 15 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -522,8 +517,6 @@ H5O_dest(H5F_t UNUSED *f, H5O_t *oh)
* koziol@ncsa.uiuc.edu
* Mar 20 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -575,8 +568,6 @@ done:
* Programmer: John Mainzer
* 5/13/04
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index a829c55..d55c650 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -23,18 +23,16 @@
* the H5O package. Therefore, do not change
* any definitions in this file!
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
#define H5O_PACKAGE /*suppress error about including H5Opkg */
-#include "H5private.h"
-#include "H5Eprivate.h"
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
-#include "H5MMprivate.h"
-#include "H5Opkg.h" /* Object header functions */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5Opkg.h" /* Object headers */
/* PRIVATE PROTOTYPES */
@@ -42,11 +40,12 @@ 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);
+static herr_t H5O_cont_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static herr_t H5O_cont_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_CONT[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_CONT[1] = {{
H5O_CONT_ID, /*message id number */
"hdr continuation", /*message name for debugging */
sizeof(H5O_cont_t), /*native message size */
@@ -56,7 +55,7 @@ const H5O_class_t H5O_CONT[1] = {{
H5O_cont_size, /*size of header continuation */
NULL, /*reset method */
H5O_cont_free, /* free method */
- NULL, /* file delete method */
+ H5O_cont_delete, /* file delete method */
NULL, /* link method */
NULL, /*get share method */
NULL, /*set share method */
@@ -208,6 +207,39 @@ H5O_cont_free (void *mesg)
/*-------------------------------------------------------------------------
+ * Function: H5O_cont_delete
+ *
+ * Purpose: Free file space referenced by message
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Monday, October 10, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_cont_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t UNUSED adj_link)
+{
+ const H5O_cont_t *mesg = (const H5O_cont_t *) _mesg;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_cont_delete)
+
+ /* check args */
+ HDassert(f);
+ HDassert(mesg);
+
+ /* Release space for chunk */
+ if(H5MF_xfree(f, H5FD_MEM_OHDR, dxpl_id, mesg->addr, (hsize_t)mesg->size) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free object header chunk")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_cont_delete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_cont_debug
*
* Purpose: Prints debugging info.
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index ccacdfd..a649970 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -38,10 +38,10 @@ static herr_t H5O_dtype_set_share (H5F_t *f, void *_mesg,
static herr_t H5O_dtype_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_DTYPE[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
H5O_DTYPE_ID, /* message id number */
- "data_type", /* message name for debugging */
+ "datatype", /* message name for debugging */
sizeof(H5T_t), /* native message size */
H5O_dtype_decode, /* decode message */
H5O_dtype_encode, /* encode message */
@@ -65,10 +65,6 @@ const H5O_class_t H5O_DTYPE[1] = {{
* class objects (array definitely, potentially compound & vlen sequences also) */
#define H5O_DTYPE_VERSION_UPDATED 2
-/* Declare external the free list for H5T_t's */
-H5FL_EXTERN(H5T_t);
-H5FL_EXTERN(H5T_shared_t);
-
/*-------------------------------------------------------------------------
* Function: H5O_dtype_decode_helper
@@ -1091,8 +1087,6 @@ H5O_dtype_free (void *mesg)
* Programmer: Robb Matzke
* Monday, June 1, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1100,12 +1094,12 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh/*out*/)
{
const H5T_t *dt = (const H5T_t *)_mesg;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_get_share);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_get_share)
- assert (dt);
- assert (sh);
+ HDassert(dt);
+ HDassert(sh);
if (H5F_addr_defined (dt->ent.header)) {
/* If the address is defined, this had better be a named datatype */
@@ -1113,7 +1107,7 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
H5G_ent_copy(&(sh->ent), &(dt->ent), H5G_COPY_NULL);
} else
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is not sharable");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is not sharable")
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -1130,23 +1124,18 @@ done:
* Programmer: Robb Matzke
* Thursday, June 4, 1998
*
- * Modifications:
- *
- * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
- * Added `id to name' support.
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/,
+H5O_dtype_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
const H5O_shared_t *sh)
{
H5T_t *dt = (H5T_t *)_mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_set_share);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_set_share)
- assert (dt);
- assert (sh);
+ HDassert(dt);
+ HDassert(sh);
/* NULL copy here, names not appropriate */
H5G_ent_copy(&(dt->ent), &(sh->ent), H5G_COPY_NULL);
@@ -1154,8 +1143,8 @@ H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/,
/* Note that the datatype is a named datatype */
dt->shared->state = H5T_STATE_NAMED;
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_dtype_set_share() */
/*--------------------------------------------------------------------------
@@ -1473,3 +1462,4 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream,
FUNC_LEAVE_NOAPI(SUCCEED);
}
+
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index d97a462..735edc4 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -36,8 +36,8 @@ static herr_t H5O_efl_reset(void *_mesg);
static herr_t H5O_efl_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_EFL[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_EFL[1] = {{
H5O_EFL_ID, /*message id number */
"external file list", /*message name for debugging */
sizeof(H5O_efl_t), /*native message size */
@@ -474,3 +474,4 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s
FUNC_LEAVE_NOAPI(SUCCEED);
}
+
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 646cff5..eb1a449 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -48,8 +48,8 @@ static herr_t H5O_fill_free(void *_mesg);
static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
-/* This message derives from H5O, for old fill value before version 1.5 */
-const H5O_class_t H5O_FILL[1] = {{
+/* This message derives from H5O message class, for old fill value before version 1.5 */
+const H5O_msg_class_t H5O_MSG_FILL[1] = {{
H5O_FILL_ID, /*message id number */
"fill", /*message name for debugging */
sizeof(H5O_fill_t), /*native message size */
@@ -66,8 +66,8 @@ const H5O_class_t H5O_FILL[1] = {{
H5O_fill_debug /*debug the message */
}};
-/* This message derives from H5O, for new fill value after version 1.4 */
-const H5O_class_t H5O_FILL_NEW[1] = {{
+/* This message derives from H5O message class, for new fill value after version 1.4 */
+const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
H5O_FILL_NEW_ID, /*message id number */
"fill_new", /*message name for debugging */
sizeof(H5O_fill_new_t), /*native message size */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index cb87764..c7a34a2 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -40,8 +40,8 @@ static herr_t H5O_layout_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hboo
static herr_t H5O_layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_LAYOUT[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
H5O_LAYOUT_ID, /*message id number */
"layout", /*message name for debugging */
sizeof(H5O_layout_t), /*native message size */
@@ -501,7 +501,7 @@ H5O_layout_meta_size(const H5F_t *f, const void *_mesg)
break;
default:
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class")
} /* end switch */
} /* end else */
@@ -727,3 +727,4 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE
FUNC_LEAVE_NOAPI(SUCCEED);
}
+
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 3f10b98..628c29c 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -45,8 +45,8 @@ static herr_t H5O_mtime_free(void *_mesg);
static herr_t H5O_mtime_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_MTIME[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_MTIME[1] = {{
H5O_MTIME_ID, /*message id number */
"mtime", /*message name for debugging */
sizeof(time_t), /*native message size */
@@ -63,9 +63,9 @@ const H5O_class_t H5O_MTIME[1] = {{
H5O_mtime_debug /*debug the message */
}};
-/* This message derives from H5O */
+/* This message derives from H5O message class */
/* (Only encode, decode & size routines are different from old mtime routines) */
-const H5O_class_t H5O_MTIME_NEW[1] = {{
+const H5O_msg_class_t H5O_MSG_MTIME_NEW[1] = {{
H5O_MTIME_NEW_ID, /*message id number */
"mtime_new", /*message name for debugging */
sizeof(time_t), /*native message size */
diff --git a/src/H5Oname.c b/src/H5Oname.c
index ffefc96..f1485d8 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -42,8 +42,8 @@ static herr_t H5O_name_reset(void *_mesg);
static herr_t H5O_name_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_NAME[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_NAME[1] = {{
H5O_NAME_ID, /*message id number */
"name", /*message name for debugging */
sizeof(H5O_name_t), /*native message size */
diff --git a/src/H5Onull.c b/src/H5Onull.c
index 5308645..a9dffa5 100644
--- a/src/H5Onull.c
+++ b/src/H5Onull.c
@@ -30,8 +30,9 @@
#include "H5private.h"
#include "H5Opkg.h" /* Object header functions */
-/* This message derives from H5O */
-const H5O_class_t H5O_NULL[1] = {{
+
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_NULL[1] = {{
H5O_NULL_ID, /*message id number */
"null", /*message name for debugging */
0, /*native message size */
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 80cccc3..d71983f 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -58,8 +58,8 @@
2 + /*sizeof message data */ \
4) /*reserved */
-typedef struct H5O_class_t {
- int id; /*message type ID on disk */
+struct H5O_msg_class_t {
+ unsigned 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*);
@@ -73,10 +73,10 @@ typedef struct H5O_class_t {
herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*); /* Get shared information */
herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); /* Set shared information */
herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int);
-} H5O_class_t;
+};
typedef struct H5O_mesg_t {
- const H5O_class_t *type; /*type of message */
+ const H5O_msg_class_t *type; /*type of message */
hbool_t dirty; /*raw out of date wrt native */
uint8_t flags; /*message flags */
unsigned chunkno; /*chunk number for this mesg */
@@ -92,24 +92,24 @@ typedef struct H5O_chunk_t {
uint8_t *image; /*image of file */
} H5O_chunk_t;
-typedef struct H5O_t {
+struct H5O_t {
H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
/* first field in structure */
- int version; /*version number */
+ unsigned version; /*version number */
int nlink; /*link count */
- unsigned nmesgs; /*number of messages */
- unsigned alloc_nmesgs; /*number of message slots */
+ size_t nmesgs; /*number of messages */
+ size_t alloc_nmesgs; /*number of message slots */
H5O_mesg_t *mesg; /*array of messages */
- unsigned nchunks; /*number of chunks */
- unsigned alloc_nchunks; /*chunks allocated */
+ size_t nchunks; /*number of chunks */
+ size_t alloc_nchunks; /*chunks allocated */
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];
+/* Header message ID to class mapping */
+H5_DLLVAR const H5O_msg_class_t *const H5O_msg_class_g[19];
/* Declare external the free list for H5O_t's */
H5FL_EXTERN(H5O_t);
@@ -124,113 +124,92 @@ H5FL_SEQ_EXTERN(H5O_chunk_t);
H5FL_BLK_EXTERN(chunk_image);
/*
- * Null Message. (0x0000)
+ * Object header messages
*/
-H5_DLLVAR const H5O_class_t H5O_NULL[1];
-/*
- * Simple Dataspace Message. (0x0001)
- */
-H5_DLLVAR const H5O_class_t H5O_SDSPACE[1];
+/* Null Message. (0x0000) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_NULL[1];
-/*
- * Datatype Message. (0x0003)
- */
-H5_DLLVAR const H5O_class_t H5O_DTYPE[1];
+/* Simple Dataspace Message. (0x0001) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_SDSPACE[1];
-/*
- * Old Fill Value Message. (0x0004)
- */
-H5_DLLVAR const H5O_class_t H5O_FILL[1];
+/* Datatype Message. (0x0003) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_DTYPE[1];
-/*
- * New Fill Value Message. (0x0005)
- *
+/* Old Fill Value Message. (0x0004) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL[1];
+
+/* New Fill Value Message. (0x0005) */
+/*
* The new fill value message is fill value plus
* space allocation time and fill value writing time and whether fill
* value is defined.
*/
-H5_DLLVAR const H5O_class_t H5O_FILL_NEW[1];
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_FILL_NEW[1];
-/*
- * External File List Message. (0x0007)
- */
-H5_DLLVAR const H5O_class_t H5O_EFL[1];
+/* External File List Message. (0x0007) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_EFL[1];
-/*
- * Data Layout Message. (0x0008)
- */
-H5_DLLVAR const H5O_class_t H5O_LAYOUT[1];
+/* Data Layout Message. (0x0008) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_LAYOUT[1];
#ifdef H5O_ENABLE_BOGUS
+/* "Bogus" Message. (0x0009) */
/*
- * "Bogus" Message. (0x0009)
+ * Used for debugging - should never be found in valid HDF5 file.
*/
-H5_DLLVAR const H5O_class_t H5O_BOGUS[1];
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS[1];
#endif /* H5O_ENABLE_BOGUS */
-/*
- * Filter pipeline message. (0x000b)
- */
-H5_DLLVAR const H5O_class_t H5O_PLINE[1];
+/* Filter pipeline message. (0x000b) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_PLINE[1];
-/*
- * Attribute Message. (0x000c)
- */
-H5_DLLVAR const H5O_class_t H5O_ATTR[1];
+/* Attribute Message. (0x000c) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_ATTR[1];
-/*
- * Object name message. (0x000d)
- */
-H5_DLLVAR const H5O_class_t H5O_NAME[1];
+/* Object name message. (0x000d) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_NAME[1];
+/* Modification Time Message. (0x000e) */
/*
- * Modification Time Message. (0x000e)
- *
* The message is just a `time_t'.
* (See also the "new" modification time message)
*/
-H5_DLLVAR const H5O_class_t H5O_MTIME[1];
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_MTIME[1];
-/*
- * Shared Object Message. (0x000f)
- *
+/* Shared Object Message. (0x000f) */
+/*
* This message ID never really appears in an object
* header. Instead, bit 2 of the `Flags' field will be set and the ID field
* will be the ID of the pointed-to message.
*/
-H5_DLLVAR const H5O_class_t H5O_SHARED[1];
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_SHARED[1];
-/*
- * Object Header Continuation Message. (0x0010)
- */
-H5_DLLVAR const H5O_class_t H5O_CONT[1];
+/* Object Header Continuation Message. (0x0010) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_CONT[1];
-/*
- * Symbol Table Message. (0x0011)
- */
-H5_DLLVAR const H5O_class_t H5O_STAB[1];
+/* Symbol Table Message. (0x0011) */
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_STAB[1];
-/*
- * New Modification Time Message. (0x0012)
- *
+/* New Modification Time Message. (0x0012) */
+/*
* The message is just a `time_t'.
*/
-H5_DLLVAR const H5O_class_t H5O_MTIME_NEW[1];
+H5_DLLVAR const H5O_msg_class_t H5O_MSG_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,
+H5_DLL void * H5O_read_real(const H5G_entry_t *ent, const H5O_msg_class_t *type,
int sequence, void *mesg, hid_t dxpl_id);
-H5_DLL void * H5O_free_real(const H5O_class_t *type, void *mesg);
+H5_DLL void * H5O_free_real(const H5O_msg_class_t *type, void *mesg);
/* Shared object operators */
H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared,
- const H5O_class_t *type, void *mesg);
+ const H5O_msg_class_t *type, void *mesg);
/* Symbol table operators */
-H5_DLL void *H5O_stab_fast(const H5G_cache_t *cache, const struct H5O_class_t *type,
+H5_DLL void *H5O_stab_fast(const H5G_cache_t *cache, const struct H5O_msg_class_t *type,
void *_mesg);
/* Useful metadata cache callbacks */
diff --git a/src/H5Opline.c b/src/H5Opline.c
index 981c2af..0287141 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -39,8 +39,8 @@ static herr_t H5O_pline_free (void *_mesg);
static herr_t H5O_pline_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_PLINE[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_PLINE[1] = {{
H5O_PLINE_ID, /* message id number */
"filter pipeline", /* message name for debugging */
sizeof(H5O_pline_t), /* native message size */
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index ba278d0..59b44cd 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -38,6 +38,10 @@
#include "H5Tprivate.h" /* Datatype functions */
#include "H5Zprivate.h" /* I/O pipeline filters */
+/* Forward references of package typedefs */
+typedef struct H5O_msg_class_t H5O_msg_class_t;
+typedef struct H5O_t H5O_t;
+
/* Object header macros */
#define H5O_MIN_SIZE H5O_ALIGN(32) /*min obj header data size */
#define H5O_MAX_SIZE 65536 /*max obj header data size */
@@ -274,7 +278,7 @@ H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
H5_DLL herr_t H5O_get_info(H5G_entry_t *ent, H5O_stat_t *ostat, hid_t dxpl_id);
H5_DLL herr_t H5O_iterate(const H5G_entry_t *ent, unsigned type_id, H5O_operator_t op,
void *op_data, hid_t dxpl_id);
-H5_DLL herr_t H5O_debug_id(hid_t type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
+H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth);
H5_DLL herr_t H5O_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
int fwidth);
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index e2cf63b..7836579 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -34,10 +34,10 @@ static herr_t H5O_sdspace_free (void *_mesg);
static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_SDSPACE[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_SDSPACE_ID, /* message id number */
- "simple_dspace", /* message name for debugging */
+ "dataspace", /* message name for debugging */
sizeof(H5S_extent_t), /* native message size */
H5O_sdspace_decode, /* decode message */
H5O_sdspace_encode, /* encode message */
@@ -127,8 +127,15 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
if (sdim->rank > 0) {
if (NULL==(sdim->size=H5FL_ARR_MALLOC(hsize_t,sdim->rank)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- for (i = 0; i < sdim->rank; i++)
+ for (i = 0; i < sdim->rank; i++) {
H5F_DECODE_LENGTH (f, p, sdim->size[i]);
+#ifndef H5_HAVE_LARGE_HSIZET
+ /* Rudimentary check for overflow of the dimension size */
+ if(sdim->size[i] == 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, NULL, "invalid size detected");
+#endif /* H5_HAVE_LARGE_HSIZET */
+ } /* end for */
+
if (flags & H5S_VALID_MAX) {
if (NULL==(sdim->max=H5FL_ARR_MALLOC(hsize_t,sdim->rank)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
@@ -427,3 +434,4 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
FUNC_LEAVE_NOAPI(SUCCEED);
}
+
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 9f39ed8..0bbf21e 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -44,8 +44,8 @@ static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hboo
static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_shared_debug (H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int);
-/* This message derives from H5O */
-const H5O_class_t H5O_SHARED[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_SHARED[1] = {{
H5O_SHARED_ID, /*message id number */
"shared", /*message name for debugging */
sizeof(H5O_shared_t), /*native message size */
@@ -91,24 +91,24 @@ const H5O_class_t H5O_SHARED[1] = {{
*-------------------------------------------------------------------------
*/
void *
-H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared, const H5O_class_t *type, void *mesg)
+H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared, const H5O_msg_class_t *type, void *mesg)
{
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_read);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_read)
/* check args */
- assert(f);
- assert(shared);
- assert(type);
+ HDassert(f);
+ HDassert(shared);
+ HDassert(type);
/* Get the shared message */
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");
+ 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);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_read() */
@@ -135,11 +135,11 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adj
{
int ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_link_adj)
/* check args */
- assert(f);
- assert(shared);
+ HDassert(f);
+ HDassert(shared);
/*
* The shared message is stored in some other object header.
@@ -147,13 +147,13 @@ H5O_shared_link_adj(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared, int adj
* 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");
+ 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);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_shared_link_adj() */
@@ -175,45 +175,45 @@ done:
*-------------------------------------------------------------------------
*/
static void *
-H5O_shared_decode (H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
+H5O_shared_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *buf)
{
- H5O_shared_t *mesg=NULL;
+ H5O_shared_t *mesg = NULL;
unsigned flags, version;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_decode)
/* Check args */
- assert (f);
- assert (buf);
+ HDassert(f);
+ HDassert(buf);
/* Decode */
- if (NULL==(mesg = H5MM_calloc (sizeof(H5O_shared_t))))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if(NULL == (mesg = H5MM_calloc (sizeof(H5O_shared_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Version */
version = *buf++;
- if (version!=H5O_SHARED_VERSION_1 && version!=H5O_SHARED_VERSION)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message");
+ if(version != H5O_SHARED_VERSION_1 && version != H5O_SHARED_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message")
/* Get the shared information flags */
flags = *buf++; /* Unused currently */
/* Skip reserved bytes (for version 1) */
- if(version==H5O_SHARED_VERSION_1)
+ if(version == H5O_SHARED_VERSION_1)
buf += 6;
/* Body */
- if(version==H5O_SHARED_VERSION_1)
- H5G_ent_decode (f, &buf, &(mesg->ent));
+ if(version == H5O_SHARED_VERSION_1)
+ H5G_ent_decode(f, &buf, &(mesg->ent));
else {
- assert(version==H5O_SHARED_VERSION);
- H5F_addr_decode (f, &buf, &(mesg->ent.header));
- mesg->ent.file=f;
+ HDassert(version == H5O_SHARED_VERSION);
+ H5F_addr_decode(f, &buf, &(mesg->ent.header));
+ mesg->ent.file = f;
} /* end else */
/* Set return value */
- ret_value=mesg;
+ ret_value = mesg;
done:
if(ret_value==NULL) {
@@ -221,8 +221,8 @@ done:
H5MM_xfree(mesg);
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_shared_decode() */
/*-------------------------------------------------------------------------
@@ -246,20 +246,20 @@ H5O_shared_encode (H5F_t *f, uint8_t *buf/*out*/, const void *_mesg)
{
const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_encode)
/* Check args */
- assert (f);
- assert (buf);
- assert (mesg);
+ HDassert(f);
+ HDassert(buf);
+ HDassert(mesg);
/* Encode */
*buf++ = H5O_SHARED_VERSION;
- *buf++ = 0; /* Flags unused currently */
- H5F_addr_encode (f, &buf, mesg->ent.header);
+ *buf++ = 0; /* No flags currently */
+ H5F_addr_encode(f, &buf, mesg->ent.header);
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_shared_encode() */
/*-------------------------------------------------------------------------
@@ -429,20 +429,21 @@ H5O_shared_debug (H5F_t UNUSED *f, hid_t dxpl_id, const void *_mesg,
{
const H5O_shared_t *mesg = (const H5O_shared_t *)_mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_debug);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_shared_debug)
/* Check args */
- assert (f);
- assert (mesg);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
- HDfprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
+ 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);
-}
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_shared_debug() */
+
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index f6df318..7361428 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -45,8 +45,8 @@ static herr_t H5O_stab_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_
static herr_t H5O_stab_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
-/* This message derives from H5O */
-const H5O_class_t H5O_STAB[1] = {{
+/* This message derives from H5O message class */
+const H5O_msg_class_t H5O_MSG_STAB[1] = {{
H5O_STAB_ID, /*message id number */
"stab", /*message name for debugging */
sizeof(H5O_stab_t), /*native message size */
@@ -171,21 +171,21 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg)
*-------------------------------------------------------------------------
*/
void *
-H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
+H5O_stab_fast(const H5G_cache_t *cache, const H5O_msg_class_t *type, void *_mesg)
{
H5O_stab_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_stab_fast);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_stab_fast)
/* check args */
assert(cache);
assert(type);
- if (H5O_STAB == type) {
+ if (H5O_MSG_STAB == type) {
if (_mesg) {
ret_value = (H5O_stab_t *) _mesg;
} else if (NULL==(ret_value = H5FL_MALLOC(H5O_stab_t))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
}
ret_value->btree_addr = cache->stab.btree_addr;
ret_value->heap_addr = cache->stab.heap_addr;
@@ -194,7 +194,7 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
ret_value=NULL;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
diff --git a/src/H5T.c b/src/H5T.c
index c7cc3e5..fbd0832 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -659,8 +659,8 @@ H5T_init_interface(void)
H5T_t *native_uint=NULL; /* Datatype structure for native unsigned int */
H5T_t *native_long=NULL; /* Datatype structure for native long */
H5T_t *native_ulong=NULL; /* Datatype structure for native unsigned long */
- H5T_t *native_llong=NULL; /* Datatype structure for native llong */
- H5T_t *native_ullong=NULL; /* Datatype structure for native unsigned llong */
+ H5T_t *native_llong=NULL; /* Datatype structure for native long long */
+ H5T_t *native_ullong=NULL; /* Datatype structure for native unsigned long long */
H5T_t *native_float=NULL; /* Datatype structure for native float */
H5T_t *native_double=NULL; /* Datatype structure for native double */
H5T_t *std_u8le=NULL; /* Datatype structure for unsigned 8-bit little-endian integer */
@@ -2890,11 +2890,11 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
} /* end switch */
/* Deep copy of the symbol table entry, if there was one */
- if ( new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
+ if(new_dt->shared->state == H5T_STATE_NAMED || new_dt->shared->state == H5T_STATE_OPEN) {
if (!H5F_addr_defined(old_dt->ent.header))
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "named dataype with invalid address");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "named dataype with invalid address")
if (H5G_ent_copy(&(new_dt->ent), &(old_dt->ent),H5G_COPY_DEEP)<0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry")
} /* end if */
else {
H5G_ent_reset(&(new_dt->ent));
@@ -2978,7 +2978,7 @@ done:
H5T_t *
H5T_alloc(void)
{
- H5T_t *dt; /* Pointer to datatype allocated */
+ H5T_t *dt = NULL; /* Pointer to datatype allocated */
H5T_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5T_alloc, NULL)
@@ -3018,54 +3018,52 @@ done:
* Programmer: Quincey Koziol
* Monday, January 6, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
H5T_free(H5T_t *dt)
{
unsigned i;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5T_free, FAIL);
+ FUNC_ENTER_NOAPI(H5T_free, FAIL)
- assert(dt && dt->shared);
+ HDassert(dt && dt->shared);
/*
* If a named type is being closed then close the object header and
* remove from the list of open objects in the file.
*/
- if (H5T_STATE_OPEN==dt->shared->state) {
- assert (H5F_addr_defined(dt->ent.header));
+ if(H5T_STATE_OPEN == dt->shared->state) {
+ HDassert(H5F_addr_defined(dt->ent.header));
/* Remove the datatype from the list of opened objects in the file */
if(H5FO_top_decr(dt->ent.file, dt->ent.header) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
if(H5FO_delete(dt->ent.file, H5AC_dxpl_id, dt->ent.header)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects")
if (H5O_close(&(dt->ent))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header")
dt->shared->state = H5T_STATE_NAMED;
- }
+ } /* end if */
/*
* Don't free locked datatypes.
*/
- if (H5T_STATE_IMMUTABLE==dt->shared->state)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype");
+ if(H5T_STATE_IMMUTABLE==dt->shared->state)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype")
/* Close the datatype */
- switch (dt->shared->type) {
+ switch(dt->shared->type) {
case H5T_COMPOUND:
- for (i=0; i<dt->shared->u.compnd.nmembs; i++) {
+ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
H5MM_xfree(dt->shared->u.compnd.memb[i].name);
H5T_close(dt->shared->u.compnd.memb[i].type);
- }
+ } /* end for */
H5MM_xfree(dt->shared->u.compnd.memb);
break;
case H5T_ENUM:
- for (i=0; i<dt->shared->u.enumer.nmembs; i++)
+ for(i = 0; i < dt->shared->u.enumer.nmembs; i++)
H5MM_xfree(dt->shared->u.enumer.name[i]);
H5MM_xfree(dt->shared->u.enumer.name);
H5MM_xfree(dt->shared->u.enumer.value);
@@ -3077,17 +3075,17 @@ H5T_free(H5T_t *dt)
default:
break;
- }
+ } /* end switch */
/* Free the ID to name info */
H5G_free_ent_name(&(dt->ent));
/* Close the parent */
- if (dt->shared->parent && H5T_close(dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type");
+ if(dt->shared->parent && H5T_close(dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close parent data type")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_free() */
@@ -3120,17 +3118,16 @@ done:
herr_t
H5T_close(H5T_t *dt)
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5T_close, FAIL);
+ FUNC_ENTER_NOAPI(H5T_close, FAIL)
- assert(dt && dt->shared);
+ HDassert(dt && dt->shared);
dt->shared->fo_count--;
- if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 0)
- {
- if(H5T_free(dt)<0)
+ if(dt->shared->state != H5T_STATE_OPEN || dt->shared->fo_count == 0) {
+ if(H5T_free(dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
H5FL_FREE(H5T_shared_t, dt->shared);
@@ -3139,7 +3136,7 @@ H5T_close(H5T_t *dt)
* If a named type is being closed then close the object header and
* remove from the list of open objects in the file.
*/
- if(H5T_STATE_OPEN==dt->shared->state) {
+ if(H5T_STATE_OPEN == dt->shared->state) {
/* Decrement the ref. count for this object in the top file */
if(H5FO_top_decr(dt->ent.file, dt->ent.header) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
@@ -3152,14 +3149,14 @@ H5T_close(H5T_t *dt)
/* Free the ID to name info since we're not calling H5T_free*/
H5G_free_ent_name(&(dt->ent));
- }
+ } /* end else */
/* Free the datatype struct */
H5FL_FREE(H5T_t,dt);
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_close() */
/*-------------------------------------------------------------------------
@@ -4668,16 +4665,6 @@ H5T_debug(const H5T_t *dt, FILE *stream)
fprintf(stream, "\n\"%s\" @%lu",
dt->shared->u.compnd.memb[i].name,
(unsigned long) (dt->shared->u.compnd.memb[i].offset));
-#ifdef OLD_WAY
- if (dt->shared->u.compnd.memb[i].ndims) {
- fprintf(stream, "[");
- for (j = 0; j < dt->shared->u.compnd.memb[i].ndims; j++) {
- fprintf(stream, "%s%lu", j ? ", " : "",
- (unsigned long)(dt->shared->u.compnd.memb[i].dim[j]));
- }
- fprintf(stream, "]");
- }
-#endif /* OLD_WAY */
fprintf(stream, " ");
H5T_debug(dt->shared->u.compnd.memb[i].type, stream);
}
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 40d94b7..a95c4bc 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -65,7 +65,7 @@ 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);
H5_DLL H5T_class_t H5T_get_class(const H5T_t *dt, htri_t internal);
-H5_DLL htri_t H5T_detect_class (const H5T_t *dt, H5T_class_t cls);
+H5_DLL htri_t H5T_detect_class(const H5T_t *dt, H5T_class_t cls);
H5_DLL size_t H5T_get_size(const H5T_t *dt);
H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset);
H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream);
diff --git a/src/H5private.h b/src/H5private.h
index 056082a..18363a1 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -427,6 +427,8 @@
# define LLONG_MAX ((long_long)(((unsigned long_long)1 \
<<(8*sizeof(long_long)-1))-1))
# define LLONG_MIN ((long_long)(-LLONG_MAX)-1)
+#endif
+#ifndef ULLONG_MAX
# define ULLONG_MAX ((unsigned long_long)((long_long)(-1)))
#endif
#ifndef SIZET_MAX