summaryrefslogtreecommitdiffstats
path: root/src/H5Pint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pint.c')
-rw-r--r--src/H5Pint.c355
1 files changed, 183 insertions, 172 deletions
diff --git a/src/H5Pint.c b/src/H5Pint.c
index 233e187..7111cba 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -42,8 +42,6 @@
/* Local Macros */
/****************/
-#define H5P_DEFAULT_SKIPLIST_HEIGHT 8
-
/******************/
/* Local Typedefs */
@@ -142,22 +140,6 @@ const H5P_libclass_t H5P_CLS_GACC[1] = {{
NULL /* Class close callback info */
}};
-/* Dataset access property list class library initialization object */
-/* (move to proper source code file when used for real) */
-const H5P_libclass_t H5P_CLS_DACC[1] = {{
- "dataset access", /* Class name for debugging */
- &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */
- &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */
- &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */
- NULL, /* Default property registration routine */
- NULL, /* Class creation callback */
- NULL, /* Class creation callback info */
- NULL, /* Class copy callback */
- NULL, /* Class copy callback info */
- NULL, /* Class close callback */
- NULL /* Class close callback info */
-}};
-
/* Datatype creation property list class library initialization object */
/* (move to proper source code file when used for real) */
const H5P_libclass_t H5P_CLS_TCRT[1] = {{
@@ -200,6 +182,7 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */
H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */
H5_DLLVAR const H5P_libclass_t H5P_CLS_FACC[1]; /* File access */
H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */
+H5_DLLVAR const H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */
H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */
H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */
H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */
@@ -294,7 +277,7 @@ H5P_do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb)
HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed");
/* Check if the property value changed */
- if(HDmemcmp(tmp_value,prop->value,prop->size)) {
+ if((prop->cmp)(tmp_value,prop->value,prop->size)) {
/* Make a copy of the class's property */
if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL)
HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property");
@@ -406,7 +389,7 @@ H5P_init_interface(void)
/* Check for parent class */
if(lib_class->par_class_id) {
/* Get the pointer to the parent class */
- if(NULL == (par_pclass = H5I_object(*lib_class->par_class_id)))
+ if(NULL == (par_pclass = (H5P_genclass_t *)H5I_object(*lib_class->par_class_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class")
} /* end if */
@@ -419,13 +402,13 @@ H5P_init_interface(void)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register properties")
/* Register the new class */
- if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, new_pclass)) < 0)
+ if((*lib_class->class_id = H5I_register(H5I_GENPROP_CLS, new_pclass, FALSE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class")
/* Only register the default property list if it hasn't been created yet */
if(lib_class->def_plist_id && *lib_class->def_plist_id == (-1)) {
/* Register the default property list for the new class*/
- if((*lib_class->def_plist_id = H5P_create_id(new_pclass)) < 0)
+ if((*lib_class->def_plist_id = H5P_create_id(new_pclass, FALSE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list for class")
} /* end if */
@@ -482,7 +465,7 @@ H5P_term_interface(void)
if(n) {
/* Clear the lists */
if(nlist>0) {
- H5I_clear_type(H5I_GENPROP_LST, FALSE);
+ H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE);
/* Reset the default property lists, if they've been closed */
if(H5I_nmembers(H5I_GENPROP_LST)==0) {
@@ -505,7 +488,7 @@ H5P_term_interface(void)
/* Only attempt to close the classes after all the lists are closed */
if(nlist==0 && nclass>0) {
- H5I_clear_type(H5I_GENPROP_CLS, FALSE);
+ H5I_clear_type(H5I_GENPROP_CLS, FALSE, FALSE);
/* Reset the default property lists, if they've been closed */
if(H5I_nmembers(H5I_GENPROP_CLS)==0) {
@@ -588,7 +571,7 @@ H5P_copy_pclass(H5P_genclass_t *pclass)
curr_node=H5SL_first(pclass->props);
while(curr_node!=NULL) {
/* Make a copy of the class's property */
- if((pcopy=H5P_dup_prop(H5SL_item(curr_node),H5P_PROP_WITHIN_CLASS)) == NULL)
+ if(NULL == (pcopy = H5P_dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS)))
HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, NULL,"Can't copy property");
/* Insert the initialized property into the property list */
@@ -636,7 +619,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5P_copy_plist(H5P_genplist_t *old_plist)
+H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref)
{
H5P_genclass_t *tclass; /* Temporary class pointer */
H5P_genplist_t *new_plist=NULL; /* New property list generated from copy */
@@ -667,11 +650,11 @@ H5P_copy_plist(H5P_genplist_t *old_plist)
new_plist->class_init = 0; /* Initially, wait until the class callback finishes to set */
/* Initialize the skip list to hold the changed properties */
- if((new_plist->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((new_plist->props = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for changed properties");
/* Create the skip list for deleted properties */
- if((new_plist->del = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((new_plist->del = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for deleted properties");
/* Create the skip list to hold names of properties already seen
@@ -679,7 +662,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist)
* 'create' callback called, if a property in the class hierarchy has
* already been seen)
*/
- if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT))== NULL)
+ if((seen = H5SL_create(H5SL_TYPE_STR))== NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties");
nseen = 0;
@@ -712,11 +695,11 @@ H5P_copy_plist(H5P_genplist_t *old_plist)
curr_node=H5SL_first(old_plist->props);
while(curr_node) {
/* Get a pointer to the node's property */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Make a copy of the list's property */
- if((new_prop=H5P_dup_prop(tmp,H5P_PROP_WITHIN_LIST)) == NULL)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property");
+ if(NULL == (new_prop = H5P_dup_prop(tmp, H5P_PROP_WITHIN_LIST)))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property")
/* Call property copy callback, if it exists */
if(new_prop->copy) {
@@ -750,14 +733,14 @@ H5P_copy_plist(H5P_genplist_t *old_plist)
* initialize each with default value & make property 'copy' callback.
*/
tclass=old_plist->pclass;
- has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0);
+ has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0);
while(tclass!=NULL) {
if(tclass->nprops>0) {
/* Walk through the properties in the old class */
curr_node=H5SL_first(tclass->props);
while(curr_node!=NULL) {
/* Get pointer to property from node */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Only "copy" properties we haven't seen before */
if(nseen==0 || H5SL_search(seen,tmp->name) == NULL) {
@@ -793,20 +776,28 @@ H5P_copy_plist(H5P_genplist_t *old_plist)
HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't increment class ref count");
/* Get an atom for the property list */
- if((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist)) < 0)
+ if((new_plist_id = H5I_register(H5I_GENPROP_LST, new_plist, app_ref)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list");
/* Save the property list ID in the property list struct, for use in the property class's 'close' callback */
new_plist->plist_id=new_plist_id;
- /* Call the class callback (if it exists) now that we have the property list ID */
- if(new_plist->pclass->copy_func!=NULL) {
- if((new_plist->pclass->copy_func)(new_plist_id,old_plist->plist_id,old_plist->pclass->copy_data) < 0) {
- /* Delete ID, ignore return value */
- H5I_remove(new_plist_id);
- HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property");
+ /* Call the class callback (if it exists) now that we have the property list ID
+ * (up through chain of parent classes also)
+ */
+ tclass = new_plist->pclass;
+ while(NULL != tclass) {
+ if(NULL != tclass->copy_func) {
+ if((tclass->copy_func)(new_plist_id, old_plist->plist_id, old_plist->pclass->copy_data) < 0) {
+ /* Delete ID, ignore return value */
+ H5I_remove(new_plist_id);
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property")
+ } /* end if */
} /* end if */
- } /* end if */
+
+ /* Go up to parent class */
+ tclass = tclass->parent;
+ } /* end while */
/* Set the class initialization flag */
new_plist->class_init=1;
@@ -848,27 +839,27 @@ done:
static H5P_genprop_t *
H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type)
{
- H5P_genprop_t *prop=NULL; /* Pointer to new property copied */
+ H5P_genprop_t *prop = NULL; /* Pointer to new property copied */
H5P_genprop_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5P_dup_prop);
+ FUNC_ENTER_NOAPI_NOINIT(H5P_dup_prop)
- assert(oprop);
- assert(type!=H5P_PROP_WITHIN_UNKNOWN);
+ HDassert(oprop);
+ HDassert(type != H5P_PROP_WITHIN_UNKNOWN);
/* Allocate the new property */
- if(NULL==(prop = H5FL_MALLOC (H5P_genprop_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy basic property information */
- HDmemcpy(prop,oprop,sizeof(H5P_genprop_t));
+ HDmemcpy(prop, oprop, sizeof(H5P_genprop_t));
/* Check if we should duplicate the name or share it */
/* Duplicating property for a class */
- if(type==H5P_PROP_WITHIN_CLASS) {
- assert(oprop->type==H5P_PROP_WITHIN_CLASS);
- assert(oprop->shared_name==0);
+ if(type == H5P_PROP_WITHIN_CLASS) {
+ HDassert(oprop->type == H5P_PROP_WITHIN_CLASS);
+ HDassert(oprop->shared_name == 0);
/* Duplicate name */
prop->name = H5MM_xstrdup(oprop->name);
@@ -878,48 +869,48 @@ H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type)
/* Check if we are duplicating a property from a list or a class */
/* Duplicating a property from a list */
- if(oprop->type==H5P_PROP_WITHIN_LIST) {
+ if(oprop->type == H5P_PROP_WITHIN_LIST) {
/* If the old property's name wasn't shared, we have to copy it here also */
if(!oprop->shared_name)
prop->name = H5MM_xstrdup(oprop->name);
} /* end if */
/* Duplicating a property from a class */
else {
- assert(oprop->type==H5P_PROP_WITHIN_CLASS);
- assert(oprop->shared_name==0);
+ HDassert(oprop->type == H5P_PROP_WITHIN_CLASS);
+ HDassert(oprop->shared_name == 0);
/* Share the name */
- prop->shared_name=1;
+ prop->shared_name = 1;
/* Set the type */
- prop->type=type;
+ prop->type = type;
} /* end else */
} /* end else */
/* Duplicate current value, if it exists */
- if(oprop->value!=NULL) {
- assert(prop->size>0);
- if(NULL==(prop->value = H5MM_malloc (prop->size)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- HDmemcpy(prop->value,oprop->value,prop->size);
+ if(oprop->value != NULL) {
+ HDassert(prop->size > 0);
+ if(NULL == (prop->value = H5MM_malloc(prop->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HDmemcpy(prop->value, oprop->value, prop->size);
} /* end if */
/* Set return value */
- ret_value=prop;
+ ret_value = prop;
done:
/* Free any resources allocated */
- if(ret_value==NULL) {
- if(prop!=NULL) {
- if(prop->name!=NULL)
+ if(ret_value == NULL) {
+ if(prop != NULL) {
+ if(prop->name != NULL)
H5MM_xfree(prop->name);
- if(prop->value!=NULL)
+ if(prop->value != NULL)
H5MM_xfree(prop->value);
- H5FL_FREE(H5P_genprop_t,prop);
+ (void)H5FL_FREE(H5P_genprop_t, prop);
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_dup_prop() */
@@ -1014,7 +1005,7 @@ done:
H5MM_xfree(prop->name);
if(prop->value!=NULL)
H5MM_xfree(prop->value);
- H5FL_FREE(H5P_genprop_t,prop);
+ (void)H5FL_FREE(H5P_genprop_t, prop);
} /* end if */
} /* end if */
@@ -1083,40 +1074,40 @@ H5P_find_prop_plist(H5P_genplist_t *plist, const char *name)
{
H5P_genprop_t *ret_value; /* Property pointer return value */
- FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_plist);
+ FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_plist)
- assert(plist);
- assert(name);
+ HDassert(plist);
+ HDassert(name);
/* Check if the property has been deleted from list */
- if(H5SL_search(plist->del,name)!=NULL) {
- HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list");
+ if(H5SL_search(plist->del,name) != NULL) {
+ HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list")
} /* end if */
else {
/* Get the property data from the skip list */
- if((ret_value=H5SL_search(plist->props,name)) == NULL) {
+ if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(plist->props, name))) {
H5P_genclass_t *tclass; /* Temporary class pointer */
/* Couldn't find property in list itself, start searching through class info */
- tclass=plist->pclass;
- while(tclass!=NULL) {
+ tclass = plist->pclass;
+ while(tclass != NULL) {
/* Find the property in the class */
- if((ret_value=H5SL_search(tclass->props,name))!=NULL)
+ if(NULL != (ret_value = (H5P_genprop_t *)H5SL_search(tclass->props, name)))
/* Got pointer to property - leave now */
break;
/* Go up to parent class */
- tclass=tclass->parent;
+ tclass = tclass->parent;
} /* end while */
/* Check if we haven't found the property */
- if(ret_value==NULL)
- HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list");
+ if(ret_value == NULL)
+ HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list")
} /* end else */
} /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_find_prop_plist() */
@@ -1143,17 +1134,17 @@ H5P_find_prop_pclass(H5P_genclass_t *pclass, const char *name)
{
H5P_genprop_t *ret_value; /* Property pointer return value */
- FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_pclass);
+ FUNC_ENTER_NOAPI_NOINIT(H5P_find_prop_pclass)
- assert(pclass);
- assert(name);
+ HDassert(pclass);
+ HDassert(name);
/* Get the property from the skip list */
- if((ret_value=H5SL_search(pclass->props,name)) == NULL)
- HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list");
+ if(NULL == (ret_value = (H5P_genprop_t *)H5SL_search(pclass->props, name)))
+ HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,NULL,"can't find property in skip list")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_find_prop_pclass() */
@@ -1190,7 +1181,7 @@ H5P_free_prop(H5P_genprop_t *prop)
if(prop->shared_name==0)
H5MM_xfree(prop->name);
- H5FL_FREE(H5P_genprop_t,prop);
+ (void)H5FL_FREE(H5P_genprop_t, prop);
FUNC_LEAVE_NOAPI(SUCCEED);
} /* H5P_free_prop() */
@@ -1336,7 +1327,8 @@ H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod)
case H5P_MOD_ERR:
case H5P_MOD_MAX:
- assert(0 && "Invalid H5P class modification");
+ default:
+ HDassert(0 && "Invalid H5P class modification");
} /* end switch */
/* Check if we can release the class information now */
@@ -1353,7 +1345,7 @@ H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod)
H5SL_destroy(pclass->props,H5P_free_prop_cb,&make_cb);
} /* end if */
- H5FL_FREE(H5P_genclass_t,pclass);
+ (void)H5FL_FREE(H5P_genclass_t, pclass);
/* Reduce the number of dependent classes on parent class also */
if(par_class!=NULL)
@@ -1476,7 +1468,7 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned internal,
pclass->revision = H5P_GET_NEXT_REV; /* Get a revision number for the class */
/* Create the skip list for properties */
- if((pclass->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((pclass->props = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for properties");
/* Set callback functions and pass-along data */
@@ -1500,7 +1492,7 @@ done:
/* Free any resources allocated */
if(ret_value==NULL)
if(pclass!=NULL)
- H5FL_FREE(H5P_genclass_t,pclass);
+ (void)H5FL_FREE(H5P_genclass_t, pclass);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_create_class() */
@@ -1558,11 +1550,11 @@ H5P_create(H5P_genclass_t *pclass)
plist->class_init = 0; /* Initially, wait until the class callback finishes to set */
/* Create the skip list for changed properties */
- if((plist->props = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((plist->props = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for changed properties");
/* Create the skip list for deleted properties */
- if((plist->del = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((plist->del = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for deleted properties");
/* Create the skip list to hold names of properties already seen
@@ -1570,7 +1562,7 @@ H5P_create(H5P_genclass_t *pclass)
* 'create' callback called, if a property in the class hierarchy has
* already been seen)
*/
- if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,NULL,"can't create skip list for seen properties");
/*
@@ -1586,7 +1578,7 @@ H5P_create(H5P_genclass_t *pclass)
curr_node=H5SL_first(tclass->props);
while(curr_node!=NULL) {
/* Get pointer to property from node */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Only "create" properties we haven't seen before */
if(H5SL_search(seen,tmp->name) == NULL) {
@@ -1641,7 +1633,7 @@ done:
H5SL_close(plist->del);
/* Release the property list itself */
- H5FL_FREE(H5P_genplist_t,plist);
+ (void)H5FL_FREE(H5P_genplist_t, plist);
} /* end if */
} /* end if */
@@ -1672,10 +1664,11 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
hid_t
-H5P_create_id(H5P_genclass_t *pclass)
+H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref)
{
- H5P_genplist_t *plist=NULL; /* Property list created */
- hid_t plist_id=FAIL; /* Property list ID */
+ H5P_genclass_t *tclass; /* Temporary class pointer */
+ H5P_genplist_t *plist = NULL; /* Property list created */
+ hid_t plist_id = FAIL; /* Property list ID */
hid_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5P_create_id, FAIL);
@@ -1687,20 +1680,28 @@ H5P_create_id(H5P_genclass_t *pclass)
HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create property list");
/* Get an atom for the property list */
- if((plist_id = H5I_register(H5I_GENPROP_LST, plist)) < 0)
+ if((plist_id = H5I_register(H5I_GENPROP_LST, plist, app_ref)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list");
/* Save the property list ID in the property list struct, for use in the property class's 'close' callback */
plist->plist_id=plist_id;
- /* Call the class callback (if it exists) now that we have the property list ID */
- if(plist->pclass->create_func!=NULL) {
- if((plist->pclass->create_func)(plist_id,plist->pclass->create_data) < 0) {
- /* Delete ID, ignore return value */
- H5I_remove(plist_id);
- HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property");
+ /* Call the class callback (if it exists) now that we have the property list ID
+ * (up through chain of parent classes also)
+ */
+ tclass = plist->pclass;
+ while(NULL != tclass) {
+ if(NULL != tclass->create_func) {
+ if((tclass->create_func)(plist_id, tclass->create_data) < 0) {
+ /* Delete ID, ignore return value */
+ H5I_remove(plist_id);
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property")
+ } /* end if */
} /* end if */
- } /* end if */
+
+ /* Go up to parent class */
+ tclass = tclass->parent;
+ } /* end while */
/* Set the class initialization flag */
plist->class_init=1;
@@ -1908,10 +1909,10 @@ H5P_register(H5P_genclass_t *pclass, const char *name, size_t size,
/* Walk through the properties in the old class */
curr_node=H5SL_first(pclass->props);
- while(curr_node!=NULL) {
+ while(curr_node != NULL) {
/* Make a copy of the class's property */
- if((pcopy=H5P_dup_prop(H5SL_item(curr_node),H5P_PROP_WITHIN_CLASS)) == NULL)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property");
+ if(NULL == (pcopy = H5P_dup_prop((H5P_genprop_t *)H5SL_item(curr_node), H5P_PROP_WITHIN_CLASS)))
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property")
/* Insert the initialized property into the property list */
if(H5P_add_prop(new_class->props,pcopy) < 0)
@@ -1950,7 +1951,7 @@ done:
H5MM_xfree(new_prop->name);
if(new_prop->value!=NULL)
H5MM_xfree(new_prop->value);
- H5FL_FREE(H5P_genprop_t,new_prop);
+ (void)H5FL_FREE(H5P_genprop_t, new_prop);
} /* end if */
} /* end if */
FUNC_LEAVE_NOAPI(ret_value);
@@ -2162,7 +2163,7 @@ done:
H5MM_xfree(new_prop->name);
if(new_prop->value!=NULL)
H5MM_xfree(new_prop->value);
- H5FL_FREE(H5P_genprop_t,new_prop);
+ (void)H5FL_FREE(H5P_genprop_t, new_prop);
} /* end if */
} /* end if */
@@ -2219,7 +2220,7 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist");
/* Find property in changed list */
- if((prop=H5SL_search(plist->props,name))!=NULL) {
+ if(NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) {
/* Check for property size >0 */
if(prop->size==0)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size");
@@ -2258,7 +2259,7 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
while(tclass!=NULL) {
if(tclass->nprops>0) {
/* Find the property in the class */
- if((prop=H5SL_search(tclass->props,name))!=NULL) {
+ if((prop = (H5P_genprop_t *)H5SL_search(tclass->props,name))!=NULL) {
H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */
/* Check for property size >0 */
@@ -2280,7 +2281,7 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value");
} /* end if */
- if(HDmemcmp(tmp_value,prop->value,prop->size)) {
+ if((prop->cmp)(tmp_value,prop->value,prop->size)) {
/* Make a copy of the class's property */
if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property");
@@ -2298,7 +2299,7 @@ H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
} /* end if */
/* No 'set' callback, just copy value */
else {
- if(HDmemcmp(value,prop->value,prop->size)) {
+ if((prop->cmp)(value,prop->value,prop->size)) {
/* Make a copy of the class's property */
if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property");
@@ -2821,8 +2822,8 @@ H5P_cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2)
if(tnode1 != NULL && tnode2 == NULL) HGOTO_DONE(1);
/* Compare the two properties */
- prop1 = H5SL_item(tnode1);
- prop2 = H5SL_item(tnode2);
+ prop1 = (H5P_genprop_t *)H5SL_item(tnode1);
+ prop2 = (H5P_genprop_t *)H5SL_item(tnode2);
if((cmp_value = H5P_cmp_prop(prop1, prop2)) != 0)
HGOTO_DONE(cmp_value);
@@ -2893,8 +2894,8 @@ H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2)
if(tnode1 != NULL && tnode2 == NULL) HGOTO_DONE(1);
/* Compare the two deleted properties */
- name1 = H5SL_item(tnode1);
- name2 = H5SL_item(tnode2);
+ name1 = (const char *)H5SL_item(tnode1);
+ name2 = (const char *)H5SL_item(tnode2);
if((cmp_value = HDstrcmp(name1, name2)) != 0)
HGOTO_DONE(cmp_value);
@@ -2921,8 +2922,8 @@ H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2)
if(tnode1 != NULL && tnode2 == NULL) HGOTO_DONE(1);
/* Compare the two properties */
- prop1 = H5SL_item(tnode1);
- prop2 = H5SL_item(tnode2);
+ prop1 = (H5P_genprop_t *)H5SL_item(tnode1);
+ prop2 = (H5P_genprop_t *)H5SL_item(tnode2);
if((cmp_value = H5P_cmp_prop(prop1, prop2)) != 0)
HGOTO_DONE(cmp_value);
@@ -3027,9 +3028,9 @@ H5P_isa_class(hid_t plist_id, hid_t pclass_id)
FUNC_ENTER_NOAPI(H5P_isa_class, FAIL);
/* Check arguments. */
- if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
- if(NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
+ if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class");
/* Compare the property list's class against the other class */
@@ -3069,23 +3070,23 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void *
+H5P_genplist_t *
H5P_object_verify(hid_t plist_id, hid_t pclass_id)
{
- void *ret_value; /* return value */
+ H5P_genplist_t *ret_value; /* return value */
- FUNC_ENTER_NOAPI(H5P_object_verify, NULL);
+ FUNC_ENTER_NOAPI(H5P_object_verify, NULL)
/* Compare the property list's class against the other class */
if(H5P_isa_class(plist_id, pclass_id) != TRUE)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, NULL, "property list is not a member of the class");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, NULL, "property list is not a member of the class")
/* Get the plist structure */
- if(NULL == (ret_value = H5I_object(plist_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID");
+ if(NULL == (ret_value = (H5P_genplist_t *)H5I_object(plist_id)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_object_verify() */
@@ -3157,11 +3158,11 @@ H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_
HDassert(iter_func);
/* Get the property list object */
- if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
/* Create the skip list to hold names of properties already seen */
- if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties");
/* Walk through the changed properties in the list */
@@ -3169,7 +3170,7 @@ H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_
curr_node = H5SL_first(plist->props);
while(curr_node != NULL) {
/* Get pointer to property from node */
- tmp = H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Check if we've found the correctly indexed property */
if(curr_idx>=*idx) {
@@ -3200,7 +3201,7 @@ H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_
curr_node=H5SL_first(tclass->props);
while(curr_node!=NULL) {
/* Get pointer to property from node */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Only call iterator callback for properties we haven't seen
* before and that haven't been deleted
@@ -3313,7 +3314,7 @@ H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *ite
assert(iter_func);
/* Get the property list object */
- if(NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
+ if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class");
/* Cycle through the properties and call the callback */
@@ -3322,7 +3323,7 @@ H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *ite
while(curr_node!=NULL) {
if(curr_idx>=*idx) {
/* Get the property for the node */
- prop=H5SL_item(curr_node);
+ prop = (H5P_genprop_t *)H5SL_item(curr_node);
/* Call the callback function */
ret_value=(*iter_func)(pclass_id,prop->name,iter_data);
@@ -3573,7 +3574,7 @@ H5P_get(const H5P_genplist_t *plist, const char *name, void *value)
HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist");
/* Find property */
- if((prop=H5SL_search(plist->props,name))!=NULL) {
+ if((prop = (H5P_genprop_t *)H5SL_search(plist->props,name))!=NULL) {
/* Check for property size >0 */
if(prop->size==0)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size");
@@ -3610,7 +3611,7 @@ H5P_get(const H5P_genplist_t *plist, const char *name, void *value)
while(tclass!=NULL) {
if(tclass->nprops>0) {
/* Find the property in the class */
- if((prop=H5SL_search(tclass->props,name))!=NULL) {
+ if((prop = (H5P_genprop_t *)H5SL_search(tclass->props,name))!=NULL) {
/* Check for property size >0 */
if(prop->size==0)
HGOTO_ERROR(H5E_PLIST,H5E_BADVALUE,FAIL,"property has zero size");
@@ -3630,7 +3631,7 @@ H5P_get(const H5P_genplist_t *plist, const char *name, void *value)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value");
} /* end if */
- if(HDmemcmp(tmp_value,prop->value,prop->size)) {
+ if((prop->cmp)(tmp_value,prop->value,prop->size)) {
H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */
/* Make a copy of the class's property */
@@ -3719,7 +3720,7 @@ H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name)
HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list");
/* Get the property node from the changed property skip list */
- if((prop=H5SL_search(plist->props,name))!=NULL) {
+ if((prop = (H5P_genprop_t *)H5SL_search(plist->props,name))!=NULL) {
/* Pass value to 'close' callback, if it exists */
if(prop->del!=NULL) {
/* Call user's callback */
@@ -3851,7 +3852,7 @@ H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name)
assert(name);
/* Get the objects to operate on */
- if(NULL == (src_plist = H5I_object(src_id)) || NULL == (dst_plist = H5I_object(dst_id)))
+ if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_id)) || NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_id)))
HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist");
/* If the property exists in the destination alread */
@@ -4011,7 +4012,7 @@ H5P_unregister(H5P_genclass_t *pclass, const char *name)
assert(name);
/* Get the property node from the skip list */
- if((prop=H5SL_search(pclass->props,name)) == NULL)
+ if((prop = (H5P_genprop_t *)H5SL_search(pclass->props,name)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list");
/* Remove the property from the skip list */
@@ -4074,10 +4075,20 @@ H5P_close(void *_plist)
assert(plist);
- /* Make call to property list class close callback, if needed */
- if(plist->class_init!=0 && plist->pclass->close_func!=NULL) {
- /* Call user's "close" callback function, ignoring return value */
- (plist->pclass->close_func)(plist->plist_id,plist->pclass->close_data);
+ /* Make call to property list class close callback, if needed
+ * (up through chain of parent classes also)
+ */
+ if(plist->class_init !=0) {
+ tclass = plist->pclass;
+ while(NULL != tclass) {
+ if(NULL != tclass->close_func) {
+ /* Call user's "close" callback function, ignoring return value */
+ (tclass->close_func)(plist->plist_id, tclass->close_data);
+ } /* end if */
+
+ /* Go up to parent class */
+ tclass = tclass->parent;
+ } /* end while */
} /* end if */
/* Create the skip list to hold names of properties already seen
@@ -4085,7 +4096,7 @@ H5P_close(void *_plist)
* 'close' callback called, if a property in the class hierarchy has
* already been seen)
*/
- if((seen = H5SL_create(H5SL_TYPE_STR, 0.5, (size_t)H5P_DEFAULT_SKIPLIST_HEIGHT)) == NULL)
+ if((seen = H5SL_create(H5SL_TYPE_STR)) == NULL)
HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties");
nseen = 0;
@@ -4094,7 +4105,7 @@ H5P_close(void *_plist)
curr_node=H5SL_first(plist->props);
while(curr_node!=NULL) {
/* Get pointer to property from node */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Call property close callback, if it exists */
if(tmp->close) {
@@ -4120,14 +4131,14 @@ H5P_close(void *_plist)
* initialize each with default value & make property 'remove' callback.
*/
tclass=plist->pclass;
- has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0);
+ has_parent_class = (hbool_t)(tclass != NULL && tclass->parent != NULL && tclass->parent->nprops > 0);
while(tclass!=NULL) {
if(tclass->nprops>0) {
/* Walk through the properties in the class */
curr_node=H5SL_first(tclass->props);
while(curr_node!=NULL) {
/* Get pointer to property from node */
- tmp=H5SL_item(curr_node);
+ tmp = (H5P_genprop_t *)H5SL_item(curr_node);
/* Only "delete" properties we haven't seen before
* and that haven't already been deleted
@@ -4183,11 +4194,11 @@ H5P_close(void *_plist)
H5SL_destroy(plist->props,H5P_free_prop_cb,&make_cb);
/* Destroy property list object */
- H5FL_FREE(H5P_genplist_t,plist);
+ (void)H5FL_FREE(H5P_genplist_t, plist);
done:
/* Release the skip list of 'seen' properties */
- if(seen!=NULL)
+ if(seen != NULL)
H5SL_close(seen);
FUNC_LEAVE_NOAPI(ret_value);
@@ -4276,7 +4287,7 @@ H5P_get_class_path(H5P_genclass_t *pclass)
/* Allocate enough space for the parent class's path, plus the '/'
* separator, this class's name and the string terminator
*/
- if(NULL==(ret_value=H5MM_malloc(par_path_len+1+my_path_len+1)))
+ if(NULL == (ret_value = (char *)H5MM_malloc(par_path_len + 1 + my_path_len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for class name");
/* Build the full path for this class */
@@ -4320,24 +4331,24 @@ done:
H5P_genclass_t *
H5P_open_class_path(const char *path)
{
- char *tmp_path=NULL; /* Temporary copy of the path */
+ char *tmp_path = NULL; /* Temporary copy of the path */
char *curr_name; /* Pointer to current component of path name */
char *delimit; /* Pointer to path delimiter during traversal */
H5P_genclass_t *curr_class; /* Pointer to class during path traversal */
H5P_genclass_t *ret_value; /* Return value */
H5P_check_class_t check_info; /* Structure to hold the information for checking duplicate names */
- FUNC_ENTER_NOAPI_NOINIT(H5P_open_class_path);
+ FUNC_ENTER_NOAPI_NOINIT(H5P_open_class_path)
- assert(path);
+ HDassert(path);
/* Duplicate the path to use */
- tmp_path=H5MM_xstrdup(path);
- assert(tmp_path);
+ tmp_path = H5MM_xstrdup(path);
+ HDassert(tmp_path);
/* Find the generic property class with this full path */
- curr_name=tmp_path;
- curr_class=NULL;
+ curr_name = tmp_path;
+ curr_class = NULL;
while((delimit=HDstrchr(curr_name,'/'))!=NULL) {
/* Change the delimiter to terminate the string */
*delimit='\0';
@@ -4347,7 +4358,7 @@ H5P_open_class_path(const char *path)
check_info.name=curr_name;
/* Find the class with this name & parent by iterating over the open classes */
- if((curr_class=H5I_search(H5I_GENPROP_CLS,H5P_check_class,&check_info)) == NULL)
+ if(NULL == (curr_class = (H5P_genclass_t *)H5I_search(H5I_GENPROP_CLS, H5P_check_class, &check_info, FALSE)))
HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class");
/* Advance the pointer in the path to the start of the next component */
@@ -4357,22 +4368,22 @@ H5P_open_class_path(const char *path)
/* Should be pointing to the last component in the path name now... */
/* Set up the search structure */
- check_info.parent=curr_class;
- check_info.name=curr_name;
+ check_info.parent = curr_class;
+ check_info.name = curr_name;
/* Find the class with this name & parent by iterating over the open classes */
- if((curr_class=H5I_search(H5I_GENPROP_CLS,H5P_check_class,&check_info)) == NULL)
- HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class");
+ if(NULL == (curr_class = (H5P_genclass_t *)H5I_search(H5I_GENPROP_CLS, H5P_check_class, &check_info, FALSE)))
+ HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't locate class")
/* Copy it */
- if((ret_value=H5P_copy_pclass(curr_class)) == NULL)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "can't copy property class");
+ if(NULL == (ret_value = H5P_copy_pclass(curr_class)))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL, "can't copy property class")
done:
/* Free the duplicated path */
H5MM_xfree(tmp_path);
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5P_open_class_path() */