summaryrefslogtreecommitdiffstats
path: root/src/H5HFspace.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HFspace.c')
-rw-r--r--src/H5HFspace.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/H5HFspace.c b/src/H5HFspace.c
index 16eae51..77d8b1b 100644
--- a/src/H5HFspace.c
+++ b/src/H5HFspace.c
@@ -94,7 +94,7 @@
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id)
+H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id, hbool_t may_create)
{
const H5FS_section_class_t *classes[] = { /* Free space section classes implemented for fractal heap */
H5HF_FSPACE_SECT_CLS_SINGLE,
@@ -118,19 +118,22 @@ H5HF_space_start(H5HF_hdr_t *hdr, hid_t dxpl_id)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
} /* end if */
else {
- H5FS_create_t fs_create; /* Free space creation parameters */
-
- /* Set the free space creation parameters */
- fs_create.client = H5FS_CLIENT_FHEAP_ID;
- fs_create.shrink_percent = H5HF_FSPACE_SHRINK;
- fs_create.expand_percent = H5HF_FSPACE_EXPAND;
- fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size;
- 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,
- &fs_create, NELMTS(classes), classes, hdr)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
+ /* Check if we are allowed to create the free space manager */
+ if(may_create) {
+ H5FS_create_t fs_create; /* Free space creation parameters */
+
+ /* Set the free space creation parameters */
+ fs_create.client = H5FS_CLIENT_FHEAP_ID;
+ fs_create.shrink_percent = H5HF_FSPACE_SHRINK;
+ fs_create.expand_percent = H5HF_FSPACE_EXPAND;
+ fs_create.max_sect_size = hdr->man_dtable.cparam.max_direct_size;
+ 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,
+ &fs_create, NELMTS(classes), classes, hdr)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize free space info")
+ } /* end if */
} /* end else */
done:
@@ -170,7 +173,7 @@ 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) < 0)
+ if(H5HF_space_start(hdr, dxpl_id, TRUE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Construct user data */
@@ -204,7 +207,7 @@ done:
htri_t
H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_section_t **node)
{
- htri_t node_found; /* Whether an existing free list node was found */
+ htri_t node_found = FALSE; /* Whether an existing free list node was found */
htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5HF_space_find)
@@ -218,12 +221,13 @@ 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) < 0)
+ if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Search for free space in the heap */
- if((node_found = H5FS_sect_find(hdr->f, dxpl_id, hdr->fspace, request, (H5FS_section_info_t **)node)) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "can't locate free space in fractal heap")
+ if(hdr->fspace)
+ if((node_found = H5FS_sect_find(hdr->f, dxpl_id, 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 */
ret_value = node_found;
@@ -262,12 +266,16 @@ 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) < 0)
+ if(H5HF_space_start(hdr, dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't initialize heap free space")
/* Get free space metadata size */
- if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0)
- HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
+ if(hdr->fspace) {
+ if(H5FS_size(hdr->f, hdr->fspace, fs_size) < 0)
+ HGOTO_ERROR(H5E_FSPACE, H5E_CANTGET, FAIL, "can't retrieve FS meta storage info")
+ } /* end if */
+ else
+ *fs_size = 0;
done:
FUNC_LEAVE_NOAPI(ret_value)