diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-01-27 20:39:20 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-01-27 20:39:20 (GMT) |
commit | 61a451f89ea2015eac08e361e6ad244bd4af5f25 (patch) | |
tree | 0f2dccdca39001329f6004a149e8384fa4e4433f /src | |
parent | 6042adf10b2c00796c52dec2a1f97a4989c42cfd (diff) | |
download | hdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.zip hdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.tar.gz hdf5-61a451f89ea2015eac08e361e6ad244bd4af5f25.tar.bz2 |
[svn-r8117] Purpose:
Code cleanup
Description:
Add C++ and FORTRAN wrappers for new H5Pdelete_filter routine, along with
documentation and a note in the release notes.
Platforms tested:
FreeBSD 4.9 (sleipnir)
Linux 2.4 (verbena) w/ C++ and FORTRAN
Too minor for full h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Pdcpl.c | 54 | ||||
-rw-r--r-- | src/H5Z.c | 107 |
2 files changed, 77 insertions, 84 deletions
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 5ee9c17..f0f1b31 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1640,33 +1640,33 @@ done: herr_t H5Pdelete_filter(hid_t plist_id, H5Z_filter_t filter) { - H5P_genplist_t *plist; /* Property list pointer */ - H5O_pline_t pline; /* Filter pipeline */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(H5Pdelete_filter, FAIL); - H5TRACE2("e","iZf",plist_id,filter); - - /* Get the property list structure */ - if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - - /* Get pipeline info */ - if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline"); - - if (pline.filter) - { - /* Delete filter */ - if(H5Z_delete(&pline, filter) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter"); - - /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline"); - } - + H5P_genplist_t *plist; /* Property list pointer */ + H5O_pline_t pline; /* Filter pipeline */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Pdelete_filter, FAIL) + H5TRACE2("e","iZf",plist_id,filter); + + /* Get the property list structure */ + if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Get pipeline info */ + if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") + + /* Check if there are any filters */ + if (pline.filter) { + /* Delete filter */ + if(H5Z_delete(&pline, filter) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't delete filter") + + /* Put the I/O pipeline information back into the property list */ + if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") + } /* end if */ + done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value); } @@ -1104,63 +1104,56 @@ done: herr_t H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - herr_t ret_value=SUCCEED; /* Return value */ - size_t i, found=0; - - FUNC_ENTER_NOAPI(H5Z_delete, FAIL) - - /* Check args */ - assert(pline); - assert(filter>=0 && filter<=H5Z_FILTER_MAX); - - /* if the pipeline has no filters, just return */ - if(pline->nused==0) - HGOTO_DONE(FALSE) - - /* Delete all filters */ - if (H5Z_FILTER_NONE==filter) - { - if(H5O_reset(H5O_PLINE_ID, pline)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info") - } - /* Delete filter */ - else - { - /* Locate the filter in the pipeline */ - for(idx=0; idx<pline->nused; idx++) - { - if(pline->filter[idx].id==filter) - { - found=1; - break; - } - } - /* filter was not found in the pipeline */ - if (!found) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") - - /* Free, reset */ - H5MM_xfree(pline->filter[idx].name); - H5MM_xfree(pline->filter[idx].cd_values); - HDmemset(&pline->filter[idx], 0, sizeof (H5Z_filter_info_t)); - - /* Reorder array */ - if (idx+1<pline->nused) - { - for(i=idx; i<pline->nused; i++) - { - pline->filter[i] = pline->filter[i+1]; - } - } - /* Decrement number of used filters */ - pline->nused--; - - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5Z_delete, FAIL) + + /* Check args */ + assert(pline); + assert(filter>=0 && filter<=H5Z_FILTER_MAX); + + /* if the pipeline has no filters, just return */ + if(pline->nused==0) + HGOTO_DONE(SUCCEED) + + /* Delete all filters */ + if (H5Z_FILTER_NONE==filter) { + if(H5O_reset(H5O_PLINE_ID, pline)<0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info") + } /* end if */ + /* Delete filter */ + else { + size_t idx; /* Index of filter in pipeline */ + unsigned found=0; /* Indicate filter was found in pipeline */ + /* Locate the filter in the pipeline */ + for(idx=0; idx<pline->nused; idx++) + if(pline->filter[idx].id==filter) { + found=1; + break; + } + + /* filter was not found in the pipeline */ + if (!found) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") + + /* Free information for deleted filter */ + H5MM_xfree(pline->filter[idx].name); + H5MM_xfree(pline->filter[idx].cd_values); + + /* Remove filter from pipeline array */ + if((idx+1)<pline->nused) + HDmemcpy(&pline->filter[idx], &pline->filter[idx+1], + sizeof (H5Z_filter_info_t)*(pline->nused-(idx+1))); + + /* Decrement number of used filters */ + pline->nused--; + /* Reset information for previous last filter in pipeline */ + HDmemset(&pline->filter[pline->nused], 0, sizeof (H5Z_filter_info_t)); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} |