summaryrefslogtreecommitdiffstats
path: root/src/H5HL.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5HL.c')
-rw-r--r--src/H5HL.c97
1 files changed, 52 insertions, 45 deletions
diff --git a/src/H5HL.c b/src/H5HL.c
index 5d29678..01f0a13 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -46,18 +46,17 @@ typedef struct H5HL_t {
} H5HL_t;
/* PRIVATE PROTOTYPES */
-static H5HL_t *H5HL_load(H5F_t *f, const haddr_t *addr, const void *udata1,
+static H5HL_t *H5HL_load(H5F_t *f, haddr_t addr, const void *udata1,
void *udata2);
-static herr_t H5HL_flush(H5F_t *f, hbool_t dest, const haddr_t *addr,
- H5HL_t *heap);
+static herr_t H5HL_flush(H5F_t *f, hbool_t dest, haddr_t addr, H5HL_t *heap);
/*
* H5HL inherits cache-like properties from H5AC
*/
static const H5AC_class_t H5AC_LHEAP[1] = {{
H5AC_LHEAP_ID,
- (void *(*)(H5F_t*, const haddr_t*, const void*, void*))H5HL_load,
- (herr_t (*)(H5F_t*, hbool_t, const haddr_t*, void*))H5HL_flush,
+ (void *(*)(H5F_t*, haddr_t, const void*, void*))H5HL_load,
+ (herr_t (*)(H5F_t*, hbool_t, haddr_t, void*))H5HL_flush,
}};
/* Interface initialization */
@@ -93,7 +92,7 @@ static intn interface_initialize_g = 0;
*-------------------------------------------------------------------------
*/
herr_t
-H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
+H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p/*out*/)
{
H5HL_t *heap = NULL;
size_t total_size; /*total heap size on disk */
@@ -103,7 +102,7 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
/* check arguments */
assert(f);
- assert(addr);
+ assert(addr_p);
if (size_hint && size_hint < H5HL_SIZEOF_FREE(f)) {
size_hint = H5HL_SIZEOF_FREE(f);
@@ -112,8 +111,8 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
/* allocate file version */
total_size = H5HL_SIZEOF_HDR(f) + size_hint;
- if (H5MF_alloc(f, H5MF_META, (hsize_t)total_size, addr/*out*/) < 0) {
- H5F_addr_undef (addr);
+ if (H5MF_alloc(f, H5MF_META, (hsize_t)total_size, addr_p/*out*/) < 0) {
+ H5F_addr_undef(addr_p);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
"unable to allocate file memory");
}
@@ -123,7 +122,7 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
"memory allocation failed");
}
- heap->addr = *addr;
+ heap->addr = *addr_p;
H5F_addr_inc(&(heap->addr), (hsize_t)H5HL_SIZEOF_HDR(f));
heap->disk_alloc = size_hint;
heap->mem_alloc = size_hint;
@@ -147,7 +146,7 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
/* add to cache */
heap->dirty = 1;
- if (H5AC_set(f, H5AC_LHEAP, addr, heap) < 0) {
+ if (H5AC_set(f, H5AC_LHEAP, *addr_p, heap) < 0) {
HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL,
"unable to cache heap");
}
@@ -155,8 +154,8 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
done:
if (ret_value<0) {
- if (H5F_addr_defined (addr)) {
- H5MF_xfree (f, addr, total_size);
+ if (H5F_addr_defined(*addr_p)) {
+ H5MF_xfree (f, *addr_p, total_size);
}
if (heap) {
H5MM_xfree (heap->chunk);
@@ -181,11 +180,12 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr/*out*/)
* Jul 17 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
static H5HL_t *
-H5HL_load(H5F_t *f, const haddr_t *addr, const void UNUSED *udata1,
+H5HL_load(H5F_t *f, haddr_t addr, const void UNUSED *udata1,
void UNUSED *udata2)
{
uint8_t hdr[52];
@@ -199,7 +199,7 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void UNUSED *udata1,
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(H5HL_SIZEOF_HDR(f) <= sizeof hdr);
assert(!udata1);
assert(!udata2);
@@ -244,7 +244,7 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void UNUSED *udata1,
"memory allocation failed");
}
if (heap->disk_alloc &&
- H5F_block_read(f, &(heap->addr), (hsize_t)(heap->disk_alloc),
+ H5F_block_read(f, heap->addr, (hsize_t)(heap->disk_alloc),
&H5F_xfer_dflt, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) {
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
"unable to read heap data");
@@ -304,12 +304,15 @@ H5HL_load(H5F_t *f, const haddr_t *addr, const void UNUSED *udata1,
* Jul 17 1997
*
* Modifications:
- * rky 980828 Only p0 writes metadata to disk.
+ * rky, 1998-08-28
+ * Only p0 writes metadata to disk.
*
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
static herr_t
-H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
+H5HL_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5HL_t *heap)
{
uint8_t *p = heap->chunk;
H5HL_free_t *fl = heap->freelist;
@@ -319,7 +322,7 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(heap);
if (heap->dirty) {
@@ -336,7 +339,7 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
"unable to allocate file space for heap");
}
heap->addr = new_addr;
- H5MF_xfree(f, &old_addr, (hsize_t)(heap->disk_alloc));
+ H5MF_xfree(f, old_addr, (hsize_t)(heap->disk_alloc));
H5E_clear(); /*don't really care if the free failed */
heap->disk_alloc = heap->mem_alloc;
}
@@ -352,7 +355,7 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
*p++ = 0; /*reserved*/
H5F_encode_length(f, p, heap->mem_alloc);
H5F_encode_length(f, p, fl ? fl->offset : H5HL_FREE_NULL);
- H5F_addr_encode(f, &p, &(heap->addr));
+ H5F_addr_encode(f, &p, heap->addr);
/*
* Write the free list.
@@ -372,9 +375,9 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
/*
* Copy buffer to disk.
*/
- hdr_end_addr = *addr;
+ hdr_end_addr = addr;
H5F_addr_inc(&hdr_end_addr, (hsize_t)H5HL_SIZEOF_HDR(f));
- if (H5F_addr_eq(&(heap->addr), &hdr_end_addr)) {
+ if (H5F_addr_eq(heap->addr, hdr_end_addr)) {
/* The header and data are contiguous */
#ifdef HAVE_PARALLEL
H5F_mpio_tas_allsame( f->shared->lf, TRUE ); /* only p0 writes */
@@ -397,7 +400,7 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
#ifdef HAVE_PARALLEL
H5F_mpio_tas_allsame( f->shared->lf, TRUE ); /* only p0 writes */
#endif /* HAVE_PARALLEL */
- if (H5F_block_write(f, &(heap->addr), (hsize_t)(heap->disk_alloc),
+ if (H5F_block_write(f, heap->addr, (hsize_t)(heap->disk_alloc),
&H5F_xfer_dflt,
heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) {
HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
@@ -446,11 +449,12 @@ H5HL_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5HL_t *heap)
* Jul 16 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
void *
-H5HL_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
+H5HL_read(H5F_t *f, haddr_t addr, size_t offset, size_t size, void *buf)
{
H5HL_t *heap = NULL;
@@ -458,7 +462,7 @@ H5HL_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
/* check arguments */
assert(f);
- assert (addr && H5F_addr_defined(addr));
+ assert (H5F_addr_defined(addr));
if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
@@ -503,11 +507,12 @@ H5HL_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
* Jul 16 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
const void *
-H5HL_peek(H5F_t *f, const haddr_t *addr, size_t offset)
+H5HL_peek(H5F_t *f, haddr_t addr, size_t offset)
{
H5HL_t *heap = NULL;
const void *retval = NULL;
@@ -516,7 +521,7 @@ H5HL_peek(H5F_t *f, const haddr_t *addr, size_t offset)
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
@@ -567,11 +572,12 @@ H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl)
* Jul 17 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
size_t
-H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
+H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
{
H5HL_t *heap = NULL;
H5HL_free_t *fl = NULL, *max_fl = NULL;
@@ -583,7 +589,7 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(buf_size > 0);
assert(buf);
if (0==(f->intent & H5F_ACC_RDWR)) {
@@ -732,12 +738,12 @@ H5HL_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
* Jul 16 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5HL_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- const void *buf)
+H5HL_write(H5F_t *f, haddr_t addr, size_t offset, size_t size, const void *buf)
{
H5HL_t *heap = NULL;
@@ -745,7 +751,7 @@ H5HL_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(buf);
assert (offset==H5HL_ALIGN (offset));
if (0==(f->intent & H5F_ACC_RDWR)) {
@@ -789,11 +795,12 @@ H5HL_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
* Jul 16 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
+H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
{
H5HL_t *heap = NULL;
H5HL_free_t *fl = NULL, *fl2 = NULL;
@@ -802,7 +809,7 @@ H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(size > 0);
assert (offset==H5HL_ALIGN (offset));
if (0==(f->intent & H5F_ACC_RDWR)) {
@@ -909,12 +916,12 @@ H5HL_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
* Aug 1 1997
*
* Modifications:
- *
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
-H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
- intn fwidth)
+H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, intn indent, intn fwidth)
{
H5HL_t *h = NULL;
int i, j, overlap;
@@ -927,7 +934,7 @@ H5HL_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
/* check arguments */
assert(f);
- assert(addr && H5F_addr_defined(addr));
+ assert(H5F_addr_defined(addr));
assert(stream);
assert(indent >= 0);
assert(fwidth >= 0);