diff options
Diffstat (limited to 'src/H5P.c')
-rw-r--r-- | src/H5P.c | 52 |
1 files changed, 35 insertions, 17 deletions
@@ -19,6 +19,10 @@ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5P_mask + /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -29,9 +33,6 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppkg.h" /* Property lists */ -/* Pablo mask */ -#define PABLO_MASK H5P_mask - /* Interface initialization */ static int interface_initialize_g = 0; #define INTERFACE_INIT H5P_init_interface @@ -213,10 +214,6 @@ H5P_init_interface(void) FUNC_ENTER_NOAPI_NOINIT(H5P_init_interface); - /* Make certain IDs are initialized */ - if (ret_value < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group"); - /* * Initialize the Generic Property class & object groups. */ @@ -472,6 +469,8 @@ H5P_copy_plist(H5P_genplist_t *old_plist) hid_t new_plist_id; /* Property list ID of new list created */ H5TB_NODE *curr_node; /* Current node in TBBT */ H5TB_TREE *seen=NULL; /* TBBT containing properties already seen */ + size_t nseen; /* Number of items 'seen' */ + hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ hid_t ret_value=FAIL; /* return value */ FUNC_ENTER_NOAPI(H5P_copy_plist, FAIL); @@ -506,6 +505,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist) */ if((seen=H5TB_fast_dmake(H5TB_FAST_STR_COMPARE))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTMAKETREE,FAIL,"can't create TBBT for seen properties"); + nseen=0; /* Cycle through the deleted properties & copy them into the new list's deleted section */ if(old_plist->del->root) { @@ -524,6 +524,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist) /* Add property name to "seen" list */ if(H5TB_dins(seen,new_name,new_name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + nseen++; /* Get the next property node in the TBBT */ curr_node=H5TB_next(curr_node); @@ -558,6 +559,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist) /* Add property name to "seen" list */ if(H5TB_dins(seen,new_prop->name,new_prop->name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + nseen++; /* Increment the number of properties in list */ new_plist->nprops++; @@ -572,6 +574,7 @@ 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); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the old class */ @@ -581,7 +584,7 @@ H5P_copy_plist(H5P_genplist_t *old_plist) tmp=curr_node->data; /* Only "copy" properties we haven't seen before */ - if(H5TB_dfind(seen,tmp->name,NULL)==NULL) { + if(nseen==0 || H5TB_dfind(seen,tmp->name,NULL)==NULL) { /* Call property creation callback, if it exists */ if(tmp->copy) { /* Call the callback & insert changed value into tree (if necessary) */ @@ -589,9 +592,12 @@ H5P_copy_plist(H5P_genplist_t *old_plist) HGOTO_ERROR (H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't create property"); } /* end if */ - /* Add property name to "seen" list */ - if(H5TB_dins(seen,tmp->name,tmp->name)==NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + /* Add property name to "seen" list, if we have other classes to work on */ + if(has_parent_class) { + if(H5TB_dins(seen,tmp->name,tmp->name)==NULL) + HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + nseen++; + } /* end if */ /* Increment the number of properties in list */ new_plist->nprops++; @@ -5122,6 +5128,9 @@ H5P_close(void *_plist) H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist=(H5P_genplist_t *)_plist; H5TB_TREE *seen=NULL; /* TBBT to hold names of properties already seen */ + size_t nseen; /* Number of items 'seen' */ + hbool_t has_parent_class; /* Flag to indicate that this property list's class has a parent */ + ssize_t ndel; /* Number of items deleted */ H5TB_NODE *curr_node; /* Current node in TBBT */ H5P_genprop_t *tmp; /* Temporary pointer to properties */ herr_t ret_value=SUCCEED; /* return value */ @@ -5143,6 +5152,7 @@ H5P_close(void *_plist) */ if((seen=H5TB_fast_dmake(H5TB_FAST_STR_COMPARE))==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTMAKETREE,FAIL,"can't create TBBT for seen properties"); + nseen=0; /* Walk through the changed properties in the list */ if(plist->props->root) { @@ -5160,17 +5170,23 @@ H5P_close(void *_plist) /* Add property name to "seen" list */ if(H5TB_dins(seen,tmp->name,tmp->name)==NULL) HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + nseen++; /* Get the next property node in the TBBT */ curr_node=H5TB_next(curr_node); } /* end while */ } /* end if */ + /* Determine number of deleted items from property list */ + if((ndel=H5TB_count(plist->del))<0) + HGOTO_ERROR(H5E_PLIST,H5E_CANTCOUNT,FAIL,"can't deterimine # of items in TBBT"); + /* * Check if we should remove class properties (up through list of parent classes also), * initialize each with default value & make property 'remove' callback. */ tclass=plist->pclass; + has_parent_class=(tclass!=NULL && tclass->parent!=NULL && tclass->parent->nprops>0); while(tclass!=NULL) { if(tclass->nprops>0) { /* Walk through the properties in the class */ @@ -5182,8 +5198,8 @@ H5P_close(void *_plist) /* Only "delete" properties we haven't seen before * and that haven't already been deleted */ - if(H5TB_dfind(seen,tmp->name,NULL)==NULL && - H5TB_dfind(plist->del,tmp->name,NULL)==NULL) { + if((nseen==0 || H5TB_dfind(seen,tmp->name,NULL)==NULL) && + (ndel==0 || H5TB_dfind(plist->del,tmp->name,NULL)==NULL)) { /* Call property close callback, if it exists */ if(tmp->close) { @@ -5201,9 +5217,12 @@ H5P_close(void *_plist) H5MM_xfree(tmp_value); } /* end if */ - /* Add property name to "seen" list */ - if(H5TB_dins(seen,tmp->name,tmp->name)==NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + /* Add property name to "seen" list, if we have other classes to work on */ + if(has_parent_class) { + if(H5TB_dins(seen,tmp->name,tmp->name)==NULL) + HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen TBBT"); + nseen++; + } /* end if */ } /* end if */ /* Get the next property node in the TBBT */ @@ -5669,4 +5688,3 @@ H5Pclose_class(hid_t cls_id) done: FUNC_LEAVE_API(ret_value); } /* H5Pclose_class() */ - |