diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
commit | 4a17aff4085ad6ee265b95730aca3f493056dec8 (patch) | |
tree | 8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5HFspace.c | |
parent | 853ae26333592faf69cd8c454ef92ffea8549df5 (diff) | |
download | hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2 |
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5HFspace.c')
-rw-r--r-- | src/H5HFspace.c | 125 |
1 files changed, 58 insertions, 67 deletions
diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 41954fc..5d659a6 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -78,7 +78,7 @@ /*------------------------------------------------------------------------- - * Function: H5HF_space_start + * Function: H5HF__space_start * * Purpose: "Start up" free space for heap - open existing free space * structure if one exists, otherwise create a new free space @@ -92,15 +92,10 @@ * koziol@ncsa.uiuc.edu * May 2 2006 * - * Modifications: - * Vailin Choi, July 29th, 2008 - * Pass values of alignment and threshold to FS_create() and FS_open() - * for handling alignment. - * *------------------------------------------------------------------------- */ herr_t -H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create) +H5HF__space_start(H5HF_hdr_t *hdr, hbool_t may_create) { const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */ H5HF_FSPACE_SECT_CLS_SINGLE, @@ -109,7 +104,7 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create) H5HF_FSPACE_SECT_CLS_INDIRECT}; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -119,7 +114,7 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create) /* Check for creating free space info for the heap */ if(H5F_addr_defined(hdr->fs_addr)) { /* Open an existing free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_open(hdr->f, dxpl_id, hdr->fs_addr, + if(NULL == (hdr->fspace = H5FS_open(hdr->f, hdr->fs_addr, NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") } /* end if */ @@ -136,7 +131,7 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create) fs_create.max_sect_addr = hdr->man_dtable.cparam.max_index; /* Create the free space structure for the heap */ - if(NULL == (hdr->fspace = H5FS_create(hdr->f, dxpl_id, &hdr->fs_addr, + if(NULL == (hdr->fspace = H5FS_create(hdr->f, &hdr->fs_addr, &fs_create, NELMTS(classes), classes, hdr, (hsize_t)H5HF_FSPACE_THRHD_DEF, (hsize_t)H5HF_FSPACE_ALIGN_DEF))) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info") HDassert(H5F_addr_defined(hdr->fs_addr)); @@ -145,11 +140,11 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_start() */ +} /* end H5HF__space_start() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_add + * Function: H5HF__space_add * * Purpose: Add a section to the free space for the heap * @@ -164,13 +159,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node, - unsigned flags) +H5HF__space_add(H5HF_hdr_t *hdr, H5HF_free_section_t *node, unsigned flags) { H5HF_sect_add_ud_t udata; /* User data for free space manager 'add' */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -180,29 +174,27 @@ H5HF_space_add(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node, /* Check if the free space for the heap has been initialized */ if(!hdr->fspace) - if(H5HF_space_start(hdr, dxpl_id, TRUE) < 0) + if(H5HF__space_start(hdr, TRUE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Construct user data */ udata.hdr = hdr; - udata.dxpl_id = dxpl_id; /* Add to the free space for the heap */ - if(H5FS_sect_add(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) + if(H5FS_sect_add(hdr->f, hdr->fspace, (H5FS_section_info_t *)node, flags, &udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't add section to heap free space") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_add() */ +} /* end H5HF__space_add() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_find + * Function: H5HF__space_find * * Purpose: Attempt to find space in a fractal heap * * Return: Success: non-negative - * * Failure: negative * * Programmer: Quincey Koziol @@ -212,12 +204,12 @@ done: *------------------------------------------------------------------------- */ htri_t -H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_section_t **node) +H5HF__space_find(H5HF_hdr_t *hdr, hsize_t request, H5HF_free_section_t **node) { htri_t node_found = FALSE; /* Whether an existing free list node was found */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -228,12 +220,12 @@ H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_secti /* Check if the free space for the heap has been initialized */ if(!hdr->fspace) - if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0) + if(H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Search for free space in the heap */ if(hdr->fspace) - if((node_found = H5FS_sect_find(hdr->f, dxpl_id, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) + if((node_found = H5FS_sect_find(hdr->f, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap") /* Set return value */ @@ -241,7 +233,7 @@ H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_secti done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_find() */ +} /* end H5HF__space_find() */ /*------------------------------------------------------------------------- @@ -277,7 +269,7 @@ H5HF_space_revert_root_cb(H5FS_section_info_t *_sect, void H5_ATTR_UNUSED *_udat if(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE && sect->sect_info.state == H5FS_SECT_LIVE) { /* Release hold on previous indirect block (we must have one) */ HDassert(sect->u.single.parent); - if(H5HF_iblock_decr(sect->u.single.parent) < 0) + if(H5HF__iblock_decr(sect->u.single.parent) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on section's indirect block") /* Reset parent information */ @@ -291,7 +283,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_space_revert_root + * Function: H5HF__space_revert_root * * Purpose: Reset 'parent' pointers in sections, when the heap is * changing from having a root indirect block to a direct block. @@ -306,11 +298,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_revert_root(const H5HF_hdr_t *hdr, hid_t dxpl_id) +H5HF__space_revert_root(const H5HF_hdr_t *hdr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -318,15 +310,14 @@ H5HF_space_revert_root(const H5HF_hdr_t *hdr, hid_t dxpl_id) HDassert(hdr); /* Only need to scan the sections if the free space has been initialized */ - if(hdr->fspace) { + if(hdr->fspace) /* Iterate over all sections, reseting the parent pointers in 'single' sections */ - if(H5FS_sect_iterate(hdr->f, dxpl_id, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) + if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to reset parent pointers") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_revert_root() */ +} /* end H5HF__space_revert_root() */ /*------------------------------------------------------------------------- @@ -383,7 +374,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_space_create_root + * Function: H5HF__space_create_root * * Purpose: Set 'parent' pointers in sections to new indirect block, when * the heap is changing from having a root direct block to a @@ -399,11 +390,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_create_root(const H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *root_iblock) +H5HF__space_create_root(const H5HF_hdr_t *hdr, H5HF_indirect_t *root_iblock) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -412,19 +403,18 @@ H5HF_space_create_root(const H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *ro HDassert(root_iblock); /* Only need to scan the sections if the free space has been initialized */ - if(hdr->fspace) { + if(hdr->fspace) /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect block */ - if(H5FS_sect_iterate(hdr->f, dxpl_id, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) + if(H5FS_sect_iterate(hdr->f, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to set parent pointers") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_create_root() */ +} /* end H5HF__space_create_root() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_size + * Function: H5HF__space_size * * Purpose: Query the size of the heap's free space info on disk * @@ -438,11 +428,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size) +H5HF__space_size(H5HF_hdr_t *hdr, hsize_t *fs_size) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -452,7 +442,7 @@ H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size) /* Check if the free space for the heap has been initialized */ if(!hdr->fspace) - if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0) + if(H5HF__space_start(hdr, FALSE) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space") /* Get free space metadata size */ @@ -465,11 +455,11 @@ H5HF_space_size(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t *fs_size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_size() */ +} /* end H5HF__space_size() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_remove + * Function: H5HF__space_remove * * Purpose: Remove a section from the free space for the heap * @@ -483,11 +473,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node) +H5HF__space_remove(H5HF_hdr_t *hdr, H5HF_free_section_t *node) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -497,16 +487,16 @@ H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *node) HDassert(node); /* Remove from the free space for the heap */ - if(H5FS_sect_remove(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)node) < 0) + if(H5FS_sect_remove(hdr->f, hdr->fspace, (H5FS_section_info_t *)node) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove section from heap free space") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_remove() */ +} /* end H5HF__space_remove() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_close + * Function: H5HF__space_close * * Purpose: Close the free space for the heap * @@ -521,11 +511,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_close(H5HF_hdr_t *hdr, hid_t dxpl_id) +H5HF__space_close(H5HF_hdr_t *hdr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -544,13 +534,13 @@ HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects); #endif /* QAK */ /* Close the free space for the heap */ - if(H5FS_close(hdr->f, dxpl_id, hdr->fspace) < 0) + if(H5FS_close(hdr->f, hdr->fspace) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info") hdr->fspace = NULL; /* Check if we can delete the free space manager for this heap */ if(!nsects) { - if(H5FS_delete(hdr->f, dxpl_id, hdr->fs_addr) < 0) + if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "can't delete free space info") hdr->fs_addr = HADDR_UNDEF; } /* end if */ @@ -558,11 +548,11 @@ HDfprintf(stderr, "%s: nsects = %Hu\n", FUNC, nsects); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_close() */ +} /* end H5HF__space_close() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_delete + * Function: H5HF__space_delete * * Purpose: Delete the free space manager for the heap * @@ -576,11 +566,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) +H5HF__space_delete(H5HF_hdr_t *hdr) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* * Check arguments. @@ -588,16 +578,16 @@ H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) HDassert(hdr); /* Delete the free space manager */ - if(H5FS_delete(hdr->f, dxpl_id, hdr->fs_addr) < 0) + if(H5FS_delete(hdr->f, hdr->fs_addr) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "can't delete to free space manager") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_delete() */ +} /* end H5HF__space_delete() */ /*------------------------------------------------------------------------- - * Function: H5HF_space_change_sect_class + * Function: H5HF__space_sect_change_class * * Purpose: Change a section's class * @@ -612,11 +602,12 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, uint16_t new_class) +H5HF__space_sect_change_class(H5HF_hdr_t *hdr, H5HF_free_section_t *sect, + uint16_t new_class) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE #ifdef QAK HDfprintf(stderr, "%s: Called\n", FUNC); #endif /* QAK */ @@ -629,10 +620,10 @@ HDfprintf(stderr, "%s: Called\n", FUNC); HDassert(sect); /* Notify the free space manager that a section has changed class */ - if(H5FS_sect_change_class(hdr->f, dxpl_id, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) + if(H5FS_sect_change_class(hdr->f, hdr->fspace, (H5FS_section_info_t *)sect, new_class) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTMODIFY, FAIL, "can't modify class of free space section") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_space_sect_change_class() */ +} /* end H5HF__space_sect_change_class() */ |