diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-16 22:27:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-16 22:27:49 (GMT) |
commit | ee7612be44b3797a903e21433558a52331515ce1 (patch) | |
tree | cce28a3a6e169f1668ad1a0356e907f0dddbfde6 /src/H5Plapl.c | |
parent | 222e7186ea78e49b387284cbb9997677c933c368 (diff) | |
download | hdf5-ee7612be44b3797a903e21433558a52331515ce1.zip hdf5-ee7612be44b3797a903e21433558a52331515ce1.tar.gz hdf5-ee7612be44b3797a903e21433558a52331515ce1.tar.bz2 |
[svn-r27811] Description:
Refactor property list code to "deep copy" properties in the correct way,
retraining the rest of the library to copy & release things correctly. This
cleans up another batch of memory leaks, etc. within the library.
Tested on:
MacOSX/64 10.10.5 (amazon) w/serial & parallel
Linux/32 2.6.x (jam) w/serial & parallel
(h5committest forthcoming)
Diffstat (limited to 'src/H5Plapl.c')
-rw-r--r-- | src/H5Plapl.c | 406 |
1 files changed, 262 insertions, 144 deletions
diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 443e068..f70fe5e 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -57,22 +57,26 @@ /* Definitions for external link prefix */ #define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) #define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ -#define H5L_ACS_ELINK_PREFIX_ENC H5P_lacc_elink_pref_enc -#define H5L_ACS_ELINK_PREFIX_DEC H5P_lacc_elink_pref_dec -#define H5L_ACS_ELINK_PREFIX_DEL H5P_lacc_elink_pref_del -#define H5L_ACS_ELINK_PREFIX_COPY H5P_lacc_elink_pref_copy -#define H5L_ACS_ELINK_PREFIX_CMP H5P_lacc_elink_pref_cmp -#define H5L_ACS_ELINK_PREFIX_CLOSE H5P_lacc_elink_pref_close +#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set +#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get +#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc +#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec +#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del +#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy +#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp +#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close /* Definitions for setting fapl of external link access */ #define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) #define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT -#define H5L_ACS_ELINK_FAPL_ENC H5P_lacc_elink_fapl_enc -#define H5L_ACS_ELINK_FAPL_DEC H5P_lacc_elink_fapl_dec -#define H5L_ACS_ELINK_FAPL_DEL H5P_lacc_elink_fapl_del -#define H5L_ACS_ELINK_FAPL_COPY H5P_lacc_elink_fapl_copy -#define H5L_ACS_ELINK_FAPL_CMP H5P_lacc_elink_fapl_cmp -#define H5L_ACS_ELINK_FAPL_CLOSE H5P_lacc_elink_fapl_close +#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set +#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get +#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc +#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec +#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del +#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy +#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp +#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close /* Definitions for file access flags for external link traversal */ #define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) @@ -100,21 +104,25 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_lacc_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass); /* Property list callbacks */ -static herr_t H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size); -static herr_t H5P_lacc_elink_pref_dec(const void **_pp, void *value); -static herr_t H5P_lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_pref_copy(const char* name, size_t size, void* value); -static int H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P_lacc_elink_pref_close(const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size); -static herr_t H5P_lacc_elink_fapl_dec(const void **_pp, void *value); -static herr_t H5P_lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_fapl_copy(const char* name, size_t size, void* value); -static int H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P_lacc_elink_fapl_close(const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__lacc_elink_pref_dec(const void **_pp, void *value); +static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_copy(const char* name, size_t size, void* value); +static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_pref_close(const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__lacc_elink_fapl_dec(const void **_pp, void *value); +static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_copy(const char* name, size_t size, void* value); +static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* value); /*********************/ @@ -130,7 +138,7 @@ const H5P_libclass_t H5P_CLS_LACC[1] = {{ &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P_lacc_reg_prop, /* Default property registration routine */ + H5P__lacc_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ @@ -160,7 +168,7 @@ static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Defaul /*------------------------------------------------------------------------- - * Function: H5P_lacc_reg_prop + * Function: H5P__lacc_reg_prop * * Purpose: Register the dataset creation property list class's properties * @@ -169,18 +177,14 @@ static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Defaul * Programmer: Quincey Koziol * October 31, 2006 * - * Modifications: - * Vailin Choi, Sept. 12th 2008 - * Register the setting of file access property list for link access - * *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_reg_prop(H5P_genclass_t *pclass) +H5P__lacc_reg_prop(H5P_genclass_t *pclass) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register property for number of links traversed */ if(H5P_register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, @@ -190,13 +194,13 @@ H5P_lacc_reg_prop(H5P_genclass_t *pclass) /* Register property for external link prefix */ if(H5P_register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, &H5L_def_elink_prefix_g, - NULL, NULL, NULL, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, + NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, H5L_ACS_ELINK_PREFIX_DEL, H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, H5L_ACS_ELINK_PREFIX_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register fapl for link access */ if(H5P_register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, - NULL, NULL, NULL, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, + NULL, H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -214,11 +218,97 @@ H5P_lacc_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_reg_prop() */ +} /* end H5P__lacc_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_enc + * Function: H5P__lacc_elink_fapl_set + * + * Purpose: Copies an external link FAPL property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Get the FAPL ID */ + l_fapl_id = *(const hid_t *)value; + + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { + H5P_genplist_t *l_fapl_plist; + + if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") + if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__lacc_elink_fapl_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_fapl_get + * + * Purpose: Copies an external link FAPL property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Get the FAPL ID */ + l_fapl_id = *(const hid_t *)value; + + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { + H5P_genplist_t *l_fapl_plist; + + if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") + if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__lacc_elink_fapl_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_fapl_enc * * Purpose: Callback routine which is called whenever the elink FAPL * property in the dataset access property list is @@ -233,7 +323,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) +H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) { const hid_t *elink_fapl = (const hid_t *)value; /* Property to encode */ uint8_t **pp = (uint8_t **)_pp; @@ -242,7 +332,7 @@ H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) size_t fapl_size = 0; /* FAPL's encoded size */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check for non-default FAPL */ if(*elink_fapl != H5P_DEFAULT) { @@ -286,11 +376,11 @@ H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_enc() */ +} /* end H5P__lacc_elink_fapl_enc() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_dec + * Function: H5P__lacc_elink_fapl_dec * * Purpose: Callback routine which is called whenever the elink FAPL * property in the dataset access property list is @@ -305,15 +395,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_fapl_dec(const void **_pp, void *_value) +H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) { hid_t *elink_fapl = (hid_t *)_value; /* The elink FAPL value */ const uint8_t **pp = (const uint8_t **)_pp; hbool_t non_default_fapl; /* Whether the FAPL is non-default */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(pp); HDassert(*pp); HDassert(elink_fapl); @@ -344,11 +435,11 @@ H5P_lacc_elink_fapl_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_dec() */ +} /* end H5P__lacc_elink_fapl_dec() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_del + * Function: H5P__lacc_elink_fapl_del * * Purpose: Close the FAPL for link access * @@ -362,27 +453,30 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + /* Close the FAPL */ + if(l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_del() */ +} /* end H5P__lacc_elink_fapl_del() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_copy + * Function: H5P__lacc_elink_fapl_copy * * Purpose: Copy the FAPL for link access * @@ -396,34 +490,36 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); - if(l_fapl_id > H5P_DEFAULT) { + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties") + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_copy() */ +} /* end H5P__lacc_elink_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_cmp + * Function: H5P__lacc_elink_fapl_cmp * * Purpose: Callback routine which is called whenever the elink FAPL * property in the link access property list is @@ -437,14 +533,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) +H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { const hid_t *fapl1 = (const hid_t *)value1; const hid_t *fapl2 = (const hid_t *)value2; H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check for comparison with default value */ if(*fapl1 == 0 && *fapl2 > 0) HGOTO_DONE(1); @@ -466,11 +562,11 @@ H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_U done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_cmp() */ +} /* end H5P__lacc_elink_fapl_cmp() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_close + * Function: H5P__lacc_elink_fapl_close * * Purpose: Close the FAPL for link access * @@ -484,26 +580,88 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); + + /* Close the FAPL */ if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_close() */ +} /* end H5P__lacc_elink_fapl_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_pref_set + * + * Purpose: Copies an external link prefix property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(value); + + /* Copy the prefix */ + *(char **)value = H5MM_xstrdup(*(const char **)value); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__lacc_elink_pref_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_pref_get + * + * Purpose: Copies an external link prefix property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(value); + + /* Copy the prefix */ + *(char **)value = H5MM_xstrdup(*(const char **)value); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__lacc_elink_pref_get() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_enc + * Function: H5P__lacc_elink_pref_enc * * Purpose: Callback routine which is called whenever the elink flags * property in the dataset access property list is @@ -518,7 +676,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) +H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) { const char *elink_pref = *(const char * const *)value; uint8_t **pp = (uint8_t **)_pp; @@ -526,7 +684,7 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) uint64_t enc_value; unsigned enc_size; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); @@ -555,11 +713,11 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_enc() */ +} /* end H5P__lacc_elink_pref_enc() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_dec + * Function: H5P__lacc_elink_pref_dec * * Purpose: Callback routine which is called whenever the elink prefix * property in the dataset access property list is @@ -574,7 +732,7 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_pref_dec(const void **_pp, void *_value) +H5P__lacc_elink_pref_dec(const void **_pp, void *_value) { char **elink_pref = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; @@ -583,7 +741,7 @@ H5P_lacc_elink_pref_dec(const void **_pp, void *_value) unsigned enc_size; /* Size of encoded property */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(pp); HDassert(*pp); @@ -612,11 +770,11 @@ H5P_lacc_elink_pref_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_pref_dec() */ +} /* end H5P__lacc_elink_pref_dec() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_del + * Function: H5P__lacc_elink_pref_del * * Purpose: Frees memory used to store the external link prefix string * @@ -629,20 +787,20 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_del() */ +} /* end H5P__lacc_elink_pref_del() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_copy + * Function: H5P__lacc_elink_pref_copy * * Purpose: Creates a copy of the external link prefix string * @@ -655,20 +813,20 @@ H5P_lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); *(char **)value = H5MM_xstrdup(*(const char **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_copy() */ +} /* end H5P__lacc_elink_pref_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_cmp + * Function: H5P__lacc_elink_pref_cmp * * Purpose: Callback routine which is called whenever the elink prefix * property in the dataset creation property list is @@ -682,13 +840,13 @@ H5P_lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static int -H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) +H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { const char *pref1 = *(const char * const *)value1; const char *pref2 = *(const char * const *)value2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if(NULL == pref1 && NULL != pref2) HGOTO_DONE(1); @@ -699,11 +857,11 @@ H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_U done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_pref_cmp() */ +} /* end H5P__lacc_elink_pref_cmp() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_close + * Function: H5P__lacc_elink_pref_close * * Purpose: Frees memory used to store the external link prefix string * @@ -716,16 +874,16 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_close() */ +} /* end H5P__lacc_elink_pref_close() */ /*------------------------------------------------------------------------- @@ -833,7 +991,6 @@ herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix) { H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Copy of prefix string */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -843,19 +1000,8 @@ H5Pset_elink_prefix(hid_t plist_id, const char *prefix) if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get current prefix value */ - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get prefix info") - - /* Free existing prefix, if there is one */ - H5MM_xfree(my_prefix); - - /* Make a copy of the user's prefix string */ - if(NULL == (my_prefix = H5MM_xstrdup(prefix))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy prefix") - /* Set prefix */ - if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: @@ -895,7 +1041,7 @@ H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") /* Check for prefix being set */ @@ -933,9 +1079,8 @@ done: herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) { - H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */ - hid_t l_fapl_id, new_fapl_id; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", lapl_id, fapl_id); @@ -944,23 +1089,8 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link access property list"); - /* Get the current file access property list for the link access */ - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl") - - /* Close the current file access property list if set */ - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") - - if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list"); - - /* Make a copy of the property list for FAPL_ID */ - if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file access properties") - /* Set the file access property list for the link access */ - if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &new_fapl_id) < 0) + if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fapl for link") done: @@ -984,9 +1114,8 @@ done: hid_t H5Pget_elink_fapl(hid_t lapl_id) { - H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */ - hid_t l_fapl_id; - hid_t ret_value=FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", lapl_id); @@ -995,18 +1124,9 @@ H5Pget_elink_fapl(hid_t lapl_id) if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0) + if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") - if(l_fapl_id > H5P_DEFAULT) { - if(NULL==(fapl_plist = H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - - if((ret_value = H5P_copy_plist(fapl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties") - } else - ret_value = l_fapl_id; - done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_elink_fapl() */ @@ -1019,7 +1139,7 @@ done: * external link. This should be either H5F_ACC_RDONLY or * H5F_ACC_RDWR, or H5F_ACC_DEFAULT to unset the value. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 9, 2008 @@ -1058,7 +1178,7 @@ done: * Purpose: Gets the file access flags to be used when traversing an * external link. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 9, 2008 @@ -1079,8 +1199,8 @@ H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get flags */ - if (flags) - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags)<0) + if(flags) + if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get access flags") done: @@ -1095,7 +1215,7 @@ done: * external link. This should be either H5F_ACC_RDONLY or * H5F_ACC_RDWR. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 15, 2008 @@ -1140,7 +1260,7 @@ done: * Purpose: Gets the file access flags to be used when traversing an * external link. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 15, 2008 @@ -1162,12 +1282,11 @@ H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info)<0) + if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") if(func) *func = cb_info.func; - if(op_data) *op_data = cb_info.user_data; @@ -1175,4 +1294,3 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_cb() */ - |