summaryrefslogtreecommitdiffstats
path: root/src/H5HF.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HF.c')
-rw-r--r--src/H5HF.c301
1 files changed, 138 insertions, 163 deletions
diff --git a/src/H5HF.c b/src/H5HF.c
index 2e437ad..843ef9a 100644
--- a/src/H5HF.c
+++ b/src/H5HF.c
@@ -31,40 +31,34 @@
/* Module Setup */
/****************/
-#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
-
+#include "H5HFmodule.h" /* This source code file is part of the H5HF module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FOprivate.h" /* File objects */
-#include "H5HFpkg.h" /* Fractal heaps */
-#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FOprivate.h" /* File objects */
+#include "H5HFpkg.h" /* Fractal heaps */
+#include "H5MFprivate.h" /* File memory management */
+#include "H5MMprivate.h" /* Memory management */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local Prototypes */
/********************/
-
/*********************/
/* Package Variables */
/*********************/
@@ -72,12 +66,10 @@
/* Package initialization variable */
hbool_t H5_PKG_INIT_VAR = FALSE;
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
@@ -85,8 +77,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
/* Declare a free list to manage the H5HF_t struct */
H5FL_DEFINE_STATIC(H5HF_t);
-
-
/*-------------------------------------------------------------------------
* Function: H5HF__op_read
*
@@ -110,7 +100,6 @@ H5HF__op_read(const void *obj, size_t obj_len, void *op_data)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__op_read() */
-
/*-------------------------------------------------------------------------
* Function: H5HF__op_write
*
@@ -129,12 +118,11 @@ H5HF__op_write(const void *obj, size_t obj_len, void *op_data)
FUNC_ENTER_PACKAGE_NOERR
/* Perform "write", using memcpy() */
- H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */
+ H5MM_memcpy((void *)obj, op_data, obj_len); /* Casting away const OK -QAK */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF__op_write() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_create
*
@@ -151,10 +139,10 @@ H5HF__op_write(const void *obj, size_t obj_len, void *op_data)
H5HF_t *
H5HF_create(H5F_t *f, const H5HF_create_t *cparam)
{
- H5HF_t *fh = NULL; /* Pointer to new fractal heap */
- H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
- haddr_t fh_addr; /* Heap header address */
- H5HF_t *ret_value = NULL; /* Return value */
+ H5HF_t * fh = NULL; /* Pointer to new fractal heap */
+ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
+ haddr_t fh_addr; /* Heap header address */
+ H5HF_t * ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -165,25 +153,25 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam)
HDassert(cparam);
/* Create shared fractal heap header */
- if(HADDR_UNDEF == (fh_addr = H5HF__hdr_create(f, cparam)))
+ if (HADDR_UNDEF == (fh_addr = H5HF__hdr_create(f, cparam)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, NULL, "can't create fractal heap header")
/* Allocate fractal heap wrapper */
- if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
+ if (NULL == (fh = H5FL_MALLOC(H5HF_t)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info")
/* Lock the heap header into memory */
- if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET)))
+ if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header")
/* Point fractal heap wrapper at header and bump it's ref count */
fh->hdr = hdr;
- if(H5HF__hdr_incr(fh->hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
+ if (H5HF__hdr_incr(fh->hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
/* Increment # of files using this heap header */
- if(H5HF__hdr_fuse_incr(fh->hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header")
+ if (H5HF__hdr_fuse_incr(fh->hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header")
/* Set file pointer for this heap open context */
fh->f = f;
@@ -192,16 +180,15 @@ H5HF_create(H5F_t *f, const H5HF_create_t *cparam)
ret_value = fh;
done:
- if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header")
- if(!ret_value && fh)
- if(H5HF_close(fh) < 0)
+ if (!ret_value && fh)
+ if (H5HF_close(fh) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_create() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_open
*
@@ -218,9 +205,9 @@ done:
H5HF_t *
H5HF_open(H5F_t *f, haddr_t fh_addr)
{
- H5HF_t *fh = NULL; /* Pointer to new fractal heap */
- H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
- H5HF_t *ret_value = NULL; /* Return value */
+ H5HF_t * fh = NULL; /* Pointer to new fractal heap */
+ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
+ H5HF_t * ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
@@ -231,25 +218,25 @@ H5HF_open(H5F_t *f, haddr_t fh_addr)
HDassert(H5F_addr_defined(fh_addr));
/* Load the heap header into memory */
- if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG)))
+ if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap header")
/* Check for pending heap deletion */
- if(hdr->pending_delete)
+ if (hdr->pending_delete)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, NULL, "can't open fractal heap pending deletion")
/* Create fractal heap info */
- if(NULL == (fh = H5FL_MALLOC(H5HF_t)))
+ if (NULL == (fh = H5FL_MALLOC(H5HF_t)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "memory allocation failed for fractal heap info")
/* Point fractal heap wrapper at header */
fh->hdr = hdr;
- if(H5HF__hdr_incr(fh->hdr) < 0)
+ if (H5HF__hdr_incr(fh->hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared heap header")
/* Increment # of files using this heap header */
- if(H5HF__hdr_fuse_incr(fh->hdr) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header")
+ if (H5HF__hdr_fuse_incr(fh->hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment file reference count on shared heap header")
/* Set file pointer for this heap open context */
fh->f = f;
@@ -258,16 +245,15 @@ H5HF_open(H5F_t *f, haddr_t fh_addr)
ret_value = fh;
done:
- if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release fractal heap header")
- if(!ret_value && fh)
- if(H5HF_close(fh) < 0)
+ if (!ret_value && fh)
+ if (H5HF_close(fh) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTCLOSEOBJ, NULL, "unable to close fractal heap")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_open() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_get_id_len
*
@@ -297,7 +283,6 @@ H5HF_get_id_len(H5HF_t *fh, size_t *id_len_p)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_get_id_len() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_get_heap_addr
*
@@ -327,7 +312,6 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_get_heap_addr() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_insert
*
@@ -342,10 +326,10 @@ H5HF_get_heap_addr(const H5HF_t *fh, haddr_t *heap_addr_p)
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/)
+H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id /*out*/)
{
- H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
- herr_t ret_value = SUCCEED;
+ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -355,7 +339,7 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/)
HDassert(id);
/* Check arguments */
- if(size == 0)
+ if (size == 0)
HGOTO_ERROR(H5E_HEAP, H5E_BADRANGE, FAIL, "can't insert 0-sized objects")
/* Set the shared heap header's file context for this operation */
@@ -365,35 +349,34 @@ H5HF_insert(H5HF_t *fh, size_t size, const void *obj, void *id/*out*/)
hdr = fh->hdr;
/* Check for 'huge' object */
- if(size > hdr->max_man_size) {
+ if (size > hdr->max_man_size) {
/* Store 'huge' object in heap */
/* (Casting away const OK - QAK) */
- if(H5HF__huge_insert(hdr, size, (void *)obj, id) < 0)
+ if (H5HF__huge_insert(hdr, size, (void *)obj, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'huge' object in fractal heap")
} /* end if */
/* Check for 'tiny' object */
- else if(size <= hdr->tiny_max_len) {
+ else if (size <= hdr->tiny_max_len) {
/* Store 'tiny' object in heap */
- if(H5HF__tiny_insert(hdr, size, obj, id) < 0)
+ if (H5HF__tiny_insert(hdr, size, obj, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'tiny' object in fractal heap")
} /* end if */
else {
/* Check if we are in "append only" mode, or if there's enough room for the object */
- if(hdr->write_once) {
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet")
+ if (hdr->write_once) {
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "'write once' managed blocks not supported yet")
} /* end if */
else {
/* Allocate space for object in 'managed' heap */
- if(H5HF__man_insert(hdr, size, obj, id) < 0)
+ if (H5HF__man_insert(hdr, size, obj, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "can't store 'managed' object in fractal heap")
} /* end else */
- } /* end else */
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_insert() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_get_obj_len
*
@@ -409,9 +392,9 @@ done:
herr_t
H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p)
{
- const uint8_t *id = (const uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -426,35 +409,34 @@ H5HF_get_obj_len(H5HF_t *fh, const void *_id, size_t *obj_len_p)
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
- if(H5HF__man_get_obj_len(fh->hdr, id, obj_len_p) < 0)
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if (H5HF__man_get_obj_len(fh->hdr, id, obj_len_p) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'managed' object's length")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
- if(H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0)
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ if (H5HF__huge_get_obj_len(fh->hdr, id, obj_len_p) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's length")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
- if(H5HF__tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0)
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ if (H5HF__tiny_get_obj_len(fh->hdr, id, obj_len_p) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'tiny' object's length")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_get_obj_len() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_get_obj_off
*
@@ -470,9 +452,9 @@ done:
herr_t
H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p)
{
- const uint8_t *id = (const uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -487,35 +469,34 @@ H5HF_get_obj_off(H5HF_t *fh, const void *_id, hsize_t *obj_off_p)
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
H5HF__man_get_obj_off(fh->hdr, id, obj_off_p);
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
/* Huge objects are located directly in the file */
- if(H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0)
+ if (H5HF__huge_get_obj_off(fh->hdr, id, obj_off_p) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's offset")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
/* Tiny objects are not stored in the heap */
*obj_off_p = (hsize_t)0;
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_get_obj_off() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_read
*
@@ -529,11 +510,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/)
+H5HF_read(H5HF_t *fh, const void *_id, void *obj /*out*/)
{
- const uint8_t *id = (const uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -548,38 +529,37 @@ H5HF_read(H5HF_t *fh, const void *_id, void *obj/*out*/)
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
/* Read object from managed heap blocks */
- if(H5HF__man_read(fh->hdr, id, obj) < 0)
+ if (H5HF__man_read(fh->hdr, id, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
/* Read 'huge' object from file */
- if(H5HF__huge_read(fh->hdr, id, obj) < 0)
+ if (H5HF__huge_read(fh->hdr, id, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'huge' object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
/* Read 'tiny' object from file */
- if(H5HF__tiny_read(fh->hdr, id, obj) < 0)
+ if (H5HF__tiny_read(fh->hdr, id, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't read 'tiny' object from fractal heap")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_read() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_write
*
@@ -607,9 +587,9 @@ done:
herr_t
H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void *obj)
{
- uint8_t *id = (uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ uint8_t *id = (uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -624,39 +604,38 @@ H5HF_write(H5HF_t *fh, void *_id, hbool_t H5_ATTR_UNUSED *id_changed, const void
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
/* Operate on object from managed heap blocks */
/* (ID can't change and modifying object is "easy" to manage) */
- if(H5HF__man_write(fh->hdr, id, obj) < 0)
+ if (H5HF__man_write(fh->hdr, id, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'managed' heap object")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
/* Operate on "huge" object */
- if(H5HF__huge_write(fh->hdr, id, obj) < 0)
+ if (H5HF__huge_write(fh->hdr, id, obj) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "can't write to 'huge' heap object")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
/* Check for writing a 'tiny' object */
/* (which isn't supported yet - ID will change) */
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "modifying 'tiny' object not supported yet")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_write() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_op
*
@@ -677,9 +656,9 @@ done:
herr_t
H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data)
{
- const uint8_t *id = (const uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -694,38 +673,37 @@ H5HF_op(H5HF_t *fh, const void *_id, H5HF_operator_t op, void *op_data)
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
/* Operate on object from managed heap blocks */
- if(H5HF__man_op(fh->hdr, id, op, op_data) < 0)
+ if (H5HF__man_op(fh->hdr, id, op, op_data) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
/* Operate on 'huge' object from file */
- if(H5HF__huge_op(fh->hdr, id, op, op_data) < 0)
+ if (H5HF__huge_op(fh->hdr, id, op, op_data) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'huge' object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
/* Operate on 'tiny' object from file */
- if(H5HF__tiny_op(fh->hdr, id, op, op_data) < 0)
+ if (H5HF__tiny_op(fh->hdr, id, op, op_data) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPERATE, FAIL, "can't operate on 'tiny' object from fractal heap")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_op() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_remove
*
@@ -741,9 +719,9 @@ done:
herr_t
H5HF_remove(H5HF_t *fh, const void *_id)
{
- const uint8_t *id = (const uint8_t *)_id; /* Object ID */
- uint8_t id_flags; /* Heap ID flag bits */
- herr_t ret_value = SUCCEED; /* Return value */
+ const uint8_t *id = (const uint8_t *)_id; /* Object ID */
+ uint8_t id_flags; /* Heap ID flag bits */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -758,38 +736,37 @@ H5HF_remove(H5HF_t *fh, const void *_id)
id_flags = *id;
/* Check for correct heap ID version */
- if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
+ if ((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR)
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version")
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
/* Check type of object in heap */
- if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
+ if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) {
/* Remove object from managed heap blocks */
- if(H5HF__man_remove(fh->hdr, id) < 0)
+ if (H5HF__man_remove(fh->hdr, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) {
/* Remove 'huge' object from file & v2 B-tree tracker */
- if(H5HF__huge_remove(fh->hdr, id) < 0)
+ if (H5HF__huge_remove(fh->hdr, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'huge' object from fractal heap")
} /* end if */
- else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
+ else if ((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) {
/* Remove 'tiny' object from heap statistics */
- if(H5HF__tiny_remove(fh->hdr, id) < 0)
+ if (H5HF__tiny_remove(fh->hdr, id) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTREMOVE, FAIL, "can't remove 'tiny' object from fractal heap")
} /* end if */
else {
-HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
-HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
+ HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC);
+ HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet")
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_remove() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_close
*
@@ -805,9 +782,9 @@ done:
herr_t
H5HF_close(H5HF_t *fh)
{
- hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */
- haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t pending_delete = FALSE; /* Whether the heap is pending deletion */
+ haddr_t heap_addr = HADDR_UNDEF; /* Address of heap (for deletion) */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -817,7 +794,7 @@ H5HF_close(H5HF_t *fh)
HDassert(fh);
/* Decrement file reference & check if this is the last open fractal heap using the shared heap header */
- if(0 == H5HF__hdr_fuse_decr(fh->hdr)) {
+ if (0 == H5HF__hdr_fuse_decr(fh->hdr)) {
/* Set the shared heap header's file context for this operation */
fh->hdr->f = fh->f;
@@ -827,7 +804,7 @@ H5HF_close(H5HF_t *fh)
* a reference loop and the objects couldn't be removed from
* the metadata cache - QAK)
*/
- if(H5HF__space_close(fh->hdr) < 0)
+ if (H5HF__space_close(fh->hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release free space info")
/* Reset the block iterator, if necessary */
@@ -836,8 +813,8 @@ H5HF_close(H5HF_t *fh)
* a reference loop and the objects couldn't be removed from
* the metadata cache - QAK)
*/
- if(H5HF__man_iter_ready(&fh->hdr->next_block))
- if(H5HF__man_iter_reset(&fh->hdr->next_block) < 0)
+ if (H5HF__man_iter_ready(&fh->hdr->next_block))
+ if (H5HF__man_iter_reset(&fh->hdr->next_block) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't reset block iterator")
/* Shut down the huge object information */
@@ -845,36 +822,36 @@ H5HF_close(H5HF_t *fh)
* has the address of an object in the file, which might be
* modified by the shutdown routine - QAK)
*/
- if(H5HF__huge_term(fh->hdr) < 0)
+ if (H5HF__huge_term(fh->hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release 'huge' object info")
/* Check for pending heap deletion */
- if(fh->hdr->pending_delete) {
+ if (fh->hdr->pending_delete) {
/* Set local info, so heap deletion can occur after decrementing the
* header's ref count
*/
pending_delete = TRUE;
- heap_addr = fh->hdr->heap_addr;
+ heap_addr = fh->hdr->heap_addr;
} /* end if */
- } /* end if */
+ } /* end if */
/* Decrement the reference count on the heap header */
/* (don't put in H5HF__hdr_fuse_decr() as the heap header may be evicted
* immediately -QAK)
*/
- if(H5HF__hdr_decr(fh->hdr) < 0)
+ if (H5HF__hdr_decr(fh->hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared heap header")
/* Check for pending heap deletion */
- if(pending_delete) {
- H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */
+ if (pending_delete) {
+ H5HF_hdr_t *hdr; /* Another pointer to fractal heap header */
/* Lock the heap header into memory */
- if(NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET)))
+ if (NULL == (hdr = H5HF__hdr_protect(fh->f, heap_addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header")
/* Delete heap, starting with header (unprotects header) */
- if(H5HF__hdr_delete(hdr) < 0)
+ if (H5HF__hdr_delete(hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap")
} /* end if */
@@ -885,7 +862,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_close() */
-
/*-------------------------------------------------------------------------
* Function: H5HF_delete
*
@@ -901,8 +877,8 @@ done:
herr_t
H5HF_delete(H5F_t *f, haddr_t fh_addr)
{
- H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -913,24 +889,23 @@ H5HF_delete(H5F_t *f, haddr_t fh_addr)
HDassert(H5F_addr_defined(fh_addr));
/* Lock the heap header into memory */
- if(NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET)))
+ if (NULL == (hdr = H5HF__hdr_protect(f, fh_addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header")
/* Check for files using shared heap header */
- if(hdr->file_rc)
+ if (hdr->file_rc)
hdr->pending_delete = TRUE;
else {
/* Delete heap now, starting with header (unprotects header) */
- if(H5HF__hdr_delete(hdr) < 0)
+ if (H5HF__hdr_delete(hdr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap")
hdr = NULL;
} /* end if */
done:
/* Unprotect the header, if an error occurred */
- if(hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
+ if (hdr && H5AC_unprotect(f, H5AC_FHEAP_HDR, fh_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap header")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_delete() */
-