summaryrefslogtreecommitdiffstats
path: root/src/H5Olayout.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
commit4a17aff4085ad6ee265b95730aca3f493056dec8 (patch)
tree8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5Olayout.c
parent853ae26333592faf69cd8c454ef92ffea8549df5 (diff)
downloadhdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5Olayout.c')
-rw-r--r--src/H5Olayout.c146
1 files changed, 20 insertions, 126 deletions
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 838a80f..e854884 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -33,25 +33,21 @@
/* Local macros */
-/* Version # of encoded virtual dataset global heap blocks */
-#define H5O_LAYOUT_VDS_GH_ENC_VERS 0
-
/* PRIVATE PROTOTYPES */
-static void *H5O__layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
- unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
+static void *H5O__layout_decode(H5F_t *f, H5O_t *open_oh, unsigned mesg_flags,
+ unsigned *ioflags, const uint8_t *p);
static herr_t H5O__layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O__layout_copy(const void *_mesg, void *_dest);
static size_t H5O__layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
static herr_t H5O__layout_reset(void *_mesg);
static herr_t H5O__layout_free(void *_mesg);
-static herr_t H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
- void *_mesg);
+static herr_t H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg);
static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src,
H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags,
- H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
-static herr_t H5O__layout_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
- FILE * stream, int indent, int fwidth);
+ H5O_copy_t *cpy_info, void *udata);
+static herr_t H5O__layout_debug(H5F_t *f, const void *_mesg, FILE *stream,
+ int indent, int fwidth);
/* This message derives from H5O message class */
const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
@@ -98,7 +94,7 @@ H5FL_DEFINE(H5O_layout_t);
*-------------------------------------------------------------------------
*/
static void *
-H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh,
+H5O__layout_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh,
unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p)
{
H5O_layout_t *mesg = NULL;
@@ -395,7 +391,7 @@ H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED
size_t i;
/* Read heap */
- if(NULL == (heap_block = (uint8_t *)H5HG_read(f, dxpl_id, &(mesg->storage.u.virt.serial_list_hobjid), NULL, &block_size)))
+ if(NULL == (heap_block = (uint8_t *)H5HG_read(f, &(mesg->storage.u.virt.serial_list_hobjid), NULL, &block_size)))
HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "Unable to read global heap block")
heap_block_p = (const uint8_t *)heap_block;
@@ -550,8 +546,6 @@ static herr_t
H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
- uint8_t *heap_block = NULL;
- size_t *str_size = NULL;
unsigned u;
herr_t ret_value = SUCCEED; /* Return value */
@@ -676,106 +670,9 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
break;
case H5D_VIRTUAL:
- /* Create heap block if it has not been created yet */
- /* Note that we assume here that the contents of the heap block
- * cannot change! If this ever stops being the case we must change
- * this code to allow overwrites of the heap block. -NAF */
- if((mesg->storage.u.virt.serial_list_hobjid.addr == HADDR_UNDEF)
- && (mesg->storage.u.virt.list_nused > 0)) {
- uint8_t *heap_block_p;
- size_t block_size;
- hssize_t select_serial_size;
- hsize_t tmp_hsize;
- uint32_t chksum;
- size_t i;
-
- /* Allocate array for caching results of strlen */
- if(NULL == (str_size = (size_t *)H5MM_malloc(2 * mesg->storage.u.virt.list_nused *sizeof(size_t))))
- HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate string length array")
-
- /*
- * Calculate heap block size
- */
- /* Version and number of entries */
- block_size = (size_t)1 + H5F_SIZEOF_SIZE(f);
-
- /* Calculate size of each entry */
- for(i = 0; i < mesg->storage.u.virt.list_nused; i++) {
- HDassert(mesg->storage.u.virt.list[i].source_file_name);
- HDassert(mesg->storage.u.virt.list[i].source_dset_name);
- HDassert(mesg->storage.u.virt.list[i].source_select);
- HDassert(mesg->storage.u.virt.list[i].source_dset.virtual_select);
-
- /* Source file name */
- str_size[2 * i] = HDstrlen(mesg->storage.u.virt.list[i].source_file_name) + (size_t)1;
- block_size += str_size[2 * i];
-
- /* Source dset name */
- str_size[(2 * i) + 1] = HDstrlen(mesg->storage.u.virt.list[i].source_dset_name) + (size_t)1;
- block_size += str_size[(2 * i) + 1];
-
- /* Source selection */
- if((select_serial_size = H5S_SELECT_SERIAL_SIZE(mesg->storage.u.virt.list[i].source_select)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size")
- block_size += (size_t)select_serial_size;
-
- /* Virtual dataset selection */
- if((select_serial_size = H5S_SELECT_SERIAL_SIZE(mesg->storage.u.virt.list[i].source_dset.virtual_select)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to check dataspace selection size")
- block_size += (size_t)select_serial_size;
- } /* end for */
-
- /* Checksum */
- block_size += 4;
-
- /* Allocate heap block */
- if(NULL == (heap_block = (uint8_t *)H5MM_malloc(block_size)))
- HGOTO_ERROR(H5E_OHDR, H5E_RESOURCE, FAIL, "unable to allocate heap block")
-
- /*
- * Encode heap block
- */
- heap_block_p = heap_block;
-
- /* Encode heap block encoding version */
- *heap_block_p++ = (uint8_t)H5O_LAYOUT_VDS_GH_ENC_VERS;
-
- /* Number of entries */
- tmp_hsize = (hsize_t)mesg->storage.u.virt.list_nused;
- H5F_ENCODE_LENGTH(f, heap_block_p, tmp_hsize)
-
- /* Encode each entry */
- for(i = 0; i < mesg->storage.u.virt.list_nused; i++) {
- /* Source file name */
- (void)HDmemcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_file_name, str_size[2 * i]);
- heap_block_p += str_size[2 * i];
-
- /* Source dataset name */
- (void)HDmemcpy((char *)heap_block_p, mesg->storage.u.virt.list[i].source_dset_name, str_size[(2 * i) + 1]);
- heap_block_p += str_size[(2 * i) + 1];
-
- /* Source selection */
- if(H5S_SELECT_SERIALIZE(mesg->storage.u.virt.list[i].source_select, &heap_block_p) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize source selection")
-
- /* Virtual selection */
- if(H5S_SELECT_SERIALIZE(mesg->storage.u.virt.list[i].source_dset.virtual_select, &heap_block_p) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to serialize virtual selection")
- } /* end for */
-
- /* Checksum */
- chksum = H5_checksum_metadata(heap_block, block_size - (size_t)4, 0);
- UINT32ENCODE(heap_block_p, chksum)
-
- /* Insert block into global heap */
- if(H5HG_insert(f, H5AC_ind_read_dxpl_id, block_size, heap_block, &((H5O_layout_t *)mesg)->storage.u.virt.serial_list_hobjid) < 0) /* Casting away const OK --NAF */
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to insert virtual dataset heap block")
- } /* end if */
-
- /* Heap information */
+ /* Encode heap ID for VDS info */
H5F_addr_encode(f, &p, mesg->storage.u.virt.serial_list_hobjid.addr);
UINT32ENCODE(p, mesg->storage.u.virt.serial_list_hobjid.idx);
-
break;
case H5D_LAYOUT_ERROR:
@@ -785,9 +682,6 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
} /* end switch */
done:
- heap_block = (uint8_t *)H5MM_xfree(heap_block);
- str_size = (size_t *)H5MM_xfree(str_size);
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__layout_encode() */
@@ -997,7 +891,7 @@ H5O__layout_free(void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
+H5O__layout_delete(H5F_t *f, H5O_t *open_oh, void *_mesg)
{
H5O_layout_t *mesg = (H5O_layout_t *) _mesg;
herr_t ret_value = SUCCEED; /* Return value */
@@ -1017,19 +911,19 @@ H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg)
case H5D_CONTIGUOUS: /* Contiguous block on disk */
/* Free the file space for the raw data */
- if(H5D__contig_delete(f, dxpl_id, &mesg->storage) < 0)
+ if(H5D__contig_delete(f, &mesg->storage) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
break;
case H5D_CHUNKED: /* Chunked blocks on disk */
/* Free the file space for the index & chunk raw data */
- if(H5D__chunk_delete(f, dxpl_id, open_oh, &mesg->storage) < 0)
+ if(H5D__chunk_delete(f, open_oh, &mesg->storage) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
break;
case H5D_VIRTUAL: /* Virtual dataset */
/* Free the file space virtual dataset */
- if(H5D__virtual_delete(f, dxpl_id, &mesg->storage) < 0)
+ if(H5D__virtual_delete(f, &mesg->storage) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free raw data")
break;
@@ -1061,7 +955,7 @@ done:
static void *
H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
hbool_t H5_ATTR_UNUSED *recompute_size, unsigned H5_ATTR_UNUSED *mesg_flags,
- H5O_copy_t *cpy_info, void *_udata, hid_t dxpl_id)
+ H5O_copy_t *cpy_info, void *_udata)
{
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
H5O_layout_t *layout_src = (H5O_layout_t *) mesg_src;
@@ -1085,7 +979,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
case H5D_COMPACT:
if(layout_src->storage.u.compact.buf) {
/* copy compact raw data */
- if(H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ if(H5D__compact_copy(file_src, &layout_src->storage.u.compact, file_dst, &layout_dst->storage.u.compact, udata->src_dtype, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
copied = TRUE;
} /* end if */
@@ -1102,7 +996,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
if(H5D__contig_is_space_alloc(&layout_src->storage)) {
/* copy contiguous raw data */
- if(H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info, dxpl_id) < 0)
+ if(H5D__contig_copy(file_src, &layout_src->storage.u.contig, file_dst, &layout_dst->storage.u.contig, udata->src_dtype, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy contiguous storage")
copied = TRUE;
} /* end if */
@@ -1111,7 +1005,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
case H5D_CHUNKED:
if(H5D__chunk_is_space_alloc(&layout_src->storage)) {
/* Create chunked layout */
- if(H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info, dxpl_id) < 0)
+ if(H5D__chunk_copy(file_src, &layout_src->storage.u.chunk, &layout_src->u.chunk, file_dst, &layout_dst->storage.u.chunk, udata->src_space_extent, udata->src_dtype, udata->common.src_pline, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy chunked storage")
copied = TRUE;
} /* end if */
@@ -1120,7 +1014,7 @@ H5O__layout_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst,
case H5D_VIRTUAL:
/* Copy virtual layout. Always copy so the memory fields get copied
* properly. */
- if(H5D__virtual_copy(file_dst, layout_dst, dxpl_id) < 0)
+ if(H5D__virtual_copy(file_dst, layout_dst) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy virtual storage")
break;
@@ -1159,8 +1053,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_mesg,
- FILE * stream, int indent, int fwidth)
+H5O__layout_debug(H5F_t H5_ATTR_UNUSED *f, const void *_mesg, FILE *stream,
+ int indent, int fwidth)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
size_t u;