diff options
author | Songyu Lu <songyulu@hdfgroup.org> | 2019-04-04 18:16:27 (GMT) |
---|---|---|
committer | Songyu Lu <songyulu@hdfgroup.org> | 2019-04-04 18:16:27 (GMT) |
commit | 5e7cccb5a2813c203fc9493a2c0d42c9f666d5af (patch) | |
tree | 257600fe3193e2f324d8dd8fe193a14e23a186e8 /src/H5Pint.c | |
parent | 50d9a397ab4bcbeaa6466eabe1c2ec6e2cf61f89 (diff) | |
parent | aa696a47715c3dd9c068f71915c6dcf23745441c (diff) | |
download | hdf5-5e7cccb5a2813c203fc9493a2c0d42c9f666d5af.zip hdf5-5e7cccb5a2813c203fc9493a2c0d42c9f666d5af.tar.gz hdf5-5e7cccb5a2813c203fc9493a2c0d42c9f666d5af.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/~songyulu/hdf5_ray into HDFFV-10658-performance-drop-from-1-8
Diffstat (limited to 'src/H5Pint.c')
-rw-r--r-- | src/H5Pint.c | 144 |
1 files changed, 127 insertions, 17 deletions
diff --git a/src/H5Pint.c b/src/H5Pint.c index e2ae792..b07f42d 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -631,7 +631,7 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) /* Allocate space for a temporary copy of the property value */ if(NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") - HDmemcpy(tmp_value, prop->value, prop->size); + H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call "type 1" callback ('create', 'copy' or 'close') */ if(cb(prop->name, prop->size, tmp_value) < 0) @@ -642,7 +642,7 @@ H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") /* Copy the changed value into the new property */ - HDmemcpy(pcopy->value, tmp_value, prop->size); + H5MM_memcpy(pcopy->value, tmp_value, prop->size); /* Insert the changed property into the property list */ if(H5P__add_prop(slist, pcopy) < 0) @@ -990,7 +990,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy basic property information */ - HDmemcpy(prop, oprop, sizeof(H5P_genprop_t)); + H5MM_memcpy(prop, oprop, sizeof(H5P_genprop_t)); /* Check if we should duplicate the name or share it */ @@ -1030,7 +1030,7 @@ H5P__dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type) 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); + H5MM_memcpy(prop->value, oprop->value, prop->size); } /* end if */ /* Set return value */ @@ -1117,7 +1117,7 @@ H5P__create_prop(const char *name, size_t size, H5P_prop_within_t type, if(value != NULL) { if(NULL == (prop->value = H5MM_malloc (prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - HDmemcpy(prop->value, value, prop->size); + H5MM_memcpy(prop->value, value, prop->size); } /* end if */ else prop->value = NULL; @@ -2727,7 +2727,7 @@ H5P__poke_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Overwrite value in property */ - HDmemcpy(prop->value, udata->value, prop->size); + H5MM_memcpy(prop->value, udata->value, prop->size); done: FUNC_LEAVE_NOAPI(ret_value) @@ -2779,7 +2779,7 @@ H5P__poke_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") - HDmemcpy(pcopy->value, udata->value, pcopy->size); + H5MM_memcpy(pcopy->value, udata->value, pcopy->size); /* Insert the changed property into the property list */ if(H5P__add_prop(plist->props, pcopy) < 0) @@ -2888,7 +2888,7 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, /* Make a copy of the current value, in case the callback fails */ if(NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value, udata->value, prop->size); + H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) @@ -2909,7 +2909,7 @@ H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, } /* end if */ /* Copy new [possibly unchanged] value into property value */ - HDmemcpy(prop->value, prp_value, prop->size); + H5MM_memcpy(prop->value, prp_value, prop->size); done: /* Free the temporary value buffer */ @@ -2968,7 +2968,7 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, /* Make a copy of the current value, in case the callback fails */ if(NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value, udata->value, prop->size); + H5MM_memcpy(tmp_value, udata->value, prop->size); /* Call user's callback */ if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) @@ -2985,7 +2985,7 @@ H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, if(NULL == (pcopy = H5P__dup_prop(prop, H5P_PROP_WITHIN_LIST))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") - HDmemcpy(pcopy->value, prp_value, pcopy->size); + H5MM_memcpy(pcopy->value, prp_value, pcopy->size); /* Insert the changed property into the property list */ if(H5P__add_prop(plist->props, pcopy) < 0) @@ -3061,6 +3061,116 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__class_get + PURPOSE + Internal routine to get a property's value from a property class. + USAGE + herr_t H5P__class_get(pclass, name, value) + const H5P_genclass_t *pclass; IN: Property class to find property in + const char *name; IN: Name of property to get + void *value; IN: Pointer to the value for the property + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Gets the current value for a property in a property class. The property + name must exist or this routine will fail. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + The 'get' callback routine registered for this property will _NOT_ be + called, this routine is designed for internal library use only! + + This routine may not be called for zero-sized properties and will + return an error in that case. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P__class_get(const H5P_genclass_t *pclass, const char *name, void *value) +{ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(pclass); + HDassert(name); + HDassert(value); + + /* Find property in list */ + if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Copy the property value */ + HDmemcpy(value, prop->value, prop->size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__class_get() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P__class_set + PURPOSE + Internal routine to set a property's value in a property class. + USAGE + herr_t H5P__class_set(pclass, name, value) + const H5P_genclass_t *pclass; IN: Property class to find property in + const char *name; IN: Name of property to set + const void *value; IN: Pointer to the value for the property + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Sets a new value for a property in a property class. The property name + must exist or this routine will fail. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + The 'set' callback routine registered for this property will _NOT_ be + called, this routine is designed for internal library use only! + + This routine may not be called for zero-sized properties and will + return an error in that case. + + The previous value is overwritten, not released in any way. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P__class_set(const H5P_genclass_t *pclass, const char *name, const void *value) +{ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(pclass); + HDassert(name); + HDassert(value); + + /* Find property in list */ + if(NULL == (prop = (H5P_genprop_t *)H5SL_search(pclass->props, name))) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Copy the property value */ + HDmemcpy(prop->value, value, prop->size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__class_set() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_exist_plist PURPOSE Internal routine to query the existance of a property in a property list. @@ -4234,7 +4344,7 @@ H5P__peek_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") /* Make a (shallow) copy of the value */ - HDmemcpy(udata->value, prop->value, prop->size); + H5MM_memcpy(udata->value, prop->value, prop->size); done: FUNC_LEAVE_NOAPI(ret_value) @@ -4334,18 +4444,18 @@ H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, /* Make a copy of the current value, in case the callback fails */ if(NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value, prop->value, prop->size); + H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ if((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") /* Copy new [possibly unchanged] value into return value */ - HDmemcpy(udata->value, tmp_value, prop->size); + H5MM_memcpy(udata->value, tmp_value, prop->size); } /* end if */ /* No 'get' callback, just copy value */ else - HDmemcpy(udata->value, prop->value, prop->size); + H5MM_memcpy(udata->value, prop->value, prop->size); done: /* Free the temporary value buffer */ @@ -4518,7 +4628,7 @@ H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, /* Allocate space for a temporary copy of the property value */ if(NULL == (tmp_value = H5MM_malloc(prop->size))) HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") - HDmemcpy(tmp_value, prop->value, prop->size); + H5MM_memcpy(tmp_value, prop->value, prop->size); /* Call user's callback */ if((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) @@ -4967,7 +5077,7 @@ H5P_close(void *_plist) /* Allocate space for a temporary copy of the property value */ if(NULL==(tmp_value=H5MM_malloc(tmp->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value") - HDmemcpy(tmp_value,tmp->value,tmp->size); + H5MM_memcpy(tmp_value,tmp->value,tmp->size); /* Call the 'close' callback */ (tmp->close)(tmp->name,tmp->size,tmp_value); |