diff options
Diffstat (limited to 'src/H5Z.c')
-rw-r--r-- | src/H5Z.c | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -1084,3 +1084,83 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_all_filters_avail() */ + + +/*------------------------------------------------------------------------- + * Function: H5Z_delete + * + * Purpose: Delete filter FILTER from pipeline PLINE; + * deletes all filters if FILTER is H5Z_FILTER_NONE + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Pedro Vicente + * Monday, January 26, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +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) +} + + + |