summaryrefslogtreecommitdiffstats
path: root/src/H5HG.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HG.c')
-rw-r--r--src/H5HG.c116
1 files changed, 48 insertions, 68 deletions
diff --git a/src/H5HG.c b/src/H5HG.c
index e8eb2eb..53f1b2a 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -5,12 +5,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
@@ -84,7 +82,7 @@
/* Local Prototypes */
/********************/
-static haddr_t H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size);
+static haddr_t H5HG__create(H5F_t *f, size_t size);
/*********************/
@@ -116,7 +114,7 @@ H5FL_BLK_DEFINE(gheap_chunk);
/*-------------------------------------------------------------------------
- * Function: H5HG_create
+ * Function: H5HG__create
*
* Purpose: Creates a global heap collection of the specified size. If
* SIZE is less than some minimum it will be readjusted. The
@@ -135,7 +133,7 @@ H5FL_BLK_DEFINE(gheap_chunk);
*-------------------------------------------------------------------------
*/
static haddr_t
-H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
+H5HG__create(H5F_t *f, size_t size)
{
H5HG_heap_t *heap = NULL;
uint8_t *p = NULL;
@@ -143,7 +141,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
size_t n;
haddr_t ret_value = HADDR_UNDEF; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, HADDR_UNDEF)
+ FUNC_ENTER_STATIC_TAG(H5AC__GLOBALHEAP_TAG)
/* Check args */
HDassert(f);
@@ -153,7 +151,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
/* Create it */
H5_CHECK_OVERFLOW(size, size_t, hsize_t);
- if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, dxpl_id, (hsize_t)size)))
+ if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file space for global heap")
if(NULL == (heap = H5FL_CALLOC(H5HG_heap_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed")
@@ -209,7 +207,7 @@ H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to add global heap collection to file's CWFS")
/* Add the heap to the cache */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(H5AC_insert_entry(f, H5AC_GHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, HADDR_UNDEF, "unable to cache global heap collection")
ret_value = addr;
@@ -219,7 +217,7 @@ done:
if(!H5F_addr_defined(ret_value)) {
if(H5F_addr_defined(addr)) {
/* Release the space on disk */
- if(H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, addr, (hsize_t)size) < 0)
+ if(H5MF_xfree(f, H5FD_MEM_GHEAP, addr, (hsize_t)size) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTFREE, HADDR_UNDEF, "unable to free global heap")
/* Check if the heap object was allocated */
@@ -230,12 +228,12 @@ done:
} /* end if */
} /* end if */
- FUNC_LEAVE_NOAPI_TAG(ret_value, HADDR_UNDEF);
-} /* H5HG_create() */
+ FUNC_LEAVE_NOAPI_TAG(ret_value);
+} /* H5HG__create() */
/*-------------------------------------------------------------------------
- * Function: H5HG_protect
+ * Function: H5HG__protect
*
* Purpose: Convenience wrapper around H5AC_protect on an indirect block
*
@@ -247,12 +245,12 @@ done:
*-------------------------------------------------------------------------
*/
H5HG_heap_t *
-H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
+H5HG__protect(H5F_t *f, haddr_t addr, unsigned flags)
{
H5HG_heap_t *heap; /* Global heap */
H5HG_heap_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Check arguments */
HDassert(f);
@@ -262,7 +260,7 @@ H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
/* Lock the heap into memory */
- if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, f, flags)))
+ if(NULL == (heap = (H5HG_heap_t *)H5AC_protect(f, H5AC_GHEAP, addr, f, flags)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap")
/* Set the heap's address */
@@ -273,7 +271,7 @@ H5HG_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, unsigned flags)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5HG_protect() */
+} /* H5HG__protect() */
/*-------------------------------------------------------------------------
@@ -414,20 +412,10 @@ done:
* Programmer: Quincey Koziol
* Saturday, June 12, 2004
*
- * Modifications:
- *
- * John Mainzer, 6/8/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
- * In this case, that required adding the new heap_dirtied_ptr
- * parameter to the function's argument list.
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
+H5HG_extend(H5F_t *f, haddr_t addr, size_t need)
{
H5HG_heap_t *heap = NULL; /* Pointer to heap to extend */
unsigned heap_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting heap */
@@ -444,7 +432,7 @@ H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
HDassert(H5F_addr_defined(addr));
/* Protect the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Re-allocate the heap information in memory */
@@ -487,7 +475,7 @@ H5HG_extend(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t need)
heap_flags |= H5AC__DIRTIED_FLAG;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap")
FUNC_LEAVE_NOAPI(ret_value)
@@ -517,7 +505,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/)
+H5HG_insert(H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
{
size_t need; /*total space needed for object */
size_t idx;
@@ -526,7 +514,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
unsigned heap_flags = H5AC__NO_FLAGS_SET;
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -541,7 +529,7 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
/* Look for a heap in the file's CWFS that has enough space for the object */
addr = HADDR_UNDEF;
- if(H5F_cwfs_find_free_heap(f, dxpl_id, need, &addr) < 0)
+ if(H5F_cwfs_find_free_heap(f, need, &addr) < 0)
HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "error trying to locate heap")
/*
@@ -549,14 +537,14 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
* new collection large enough for the message plus the collection header.
*/
if(!H5F_addr_defined(addr)) {
- addr = H5HG_create(f, dxpl_id, need + H5HG_SIZEOF_HDR(f));
+ addr = H5HG__create(f, need + H5HG_SIZEOF_HDR(f));
if(!H5F_addr_defined(addr))
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection")
} /* end if */
HDassert(H5F_addr_defined(addr));
- if(NULL == (heap = H5HG_protect(f, dxpl_id, addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
/* Split the free space to make room for the new object */
@@ -579,10 +567,10 @@ H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out*/
hobj->idx = idx;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, heap->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to unprotect heap.")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* H5HG_insert() */
@@ -604,8 +592,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
-H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
- size_t *buf_size)
+H5HG_read(H5F_t *f, H5HG_t *hobj, void *object/*out*/, size_t *buf_size)
{
H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
size_t size; /* Size of the heap object */
@@ -613,14 +600,14 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
void *orig_object = object; /* Keep a copy of the original object pointer */
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, NULL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, NULL)
/* Check args */
HDassert(f);
HDassert(hobj);
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__READ_ONLY_FLAG)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -650,13 +637,13 @@ H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/,
ret_value = object;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, NULL, "unable to release object header")
if(NULL == ret_value && NULL == orig_object && object)
H5MM_free(object);
- FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_read() */
@@ -679,13 +666,13 @@ done:
*-------------------------------------------------------------------------
*/
int
-H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
+H5HG_link(H5F_t *f, const H5HG_t *hobj, int adjust)
{
H5HG_heap_t *heap = NULL;
unsigned heap_flags = H5AC__NO_FLAGS_SET;
int ret_value = -1; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -694,7 +681,7 @@ H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
if(adjust != 0) {
@@ -712,10 +699,10 @@ H5HG_link(H5F_t *f, hid_t dxpl_id, const H5HG_t *hobj, int adjust)
ret_value = heap->obj[hobj->idx].nrefs;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, heap_flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_link() */
@@ -733,12 +720,12 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
+H5HG_get_obj_size(H5F_t *f, H5HG_t *hobj, size_t *obj_size)
{
H5HG_heap_t *heap = NULL; /* Pointer to global heap object */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL)
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -746,7 +733,7 @@ H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
HDassert(obj_size);
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__READ_ONLY_FLAG)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__READ_ONLY_FLAG)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -756,10 +743,10 @@ H5HG_get_obj_size(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, size_t *obj_size)
*obj_size = heap->obj[hobj->idx].size;
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
} /* end H5HG_get_obj_size() */
@@ -773,17 +760,10 @@ done:
* Programmer: Robb Matzke
* Monday, March 30, 1998
*
- * Modifications:
- *
- * John Mainzer - 6/8/05
- * Modified function to use the dirtied parameter of
- * H5AC_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
+H5HG_remove (H5F_t *f, H5HG_t *hobj)
{
H5HG_heap_t *heap = NULL;
uint8_t *p = NULL, *obj_start = NULL;
@@ -792,7 +772,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
unsigned flags = H5AC__NO_FLAGS_SET;/* Whether the heap gets deleted */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_TAG(dxpl_id, H5AC__GLOBALHEAP_TAG, FAIL);
+ FUNC_ENTER_NOAPI_TAG(H5AC__GLOBALHEAP_TAG, FAIL)
/* Check args */
HDassert(f);
@@ -801,7 +781,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file")
/* Load the heap */
- if(NULL == (heap = H5HG_protect(f, dxpl_id, hobj->addr, H5AC__NO_FLAGS_SET)))
+ if(NULL == (heap = H5HG__protect(f, hobj->addr, H5AC__NO_FLAGS_SET)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap")
HDassert(hobj->idx < heap->nused);
@@ -851,10 +831,10 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
} /* end else */
done:
- if(heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, flags) < 0)
+ if(heap && H5AC_unprotect(f, H5AC_GHEAP, hobj->addr, heap, flags) < 0)
HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL);
+ FUNC_LEAVE_NOAPI_TAG(ret_value);
} /* end H5HG_remove() */