summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Dcompact.c6
-rw-r--r--src/H5Dlayout.c63
-rw-r--r--src/H5Dpkg.h2
-rw-r--r--src/H5Olayout.c69
-rw-r--r--src/H5Oprivate.h3
5 files changed, 71 insertions, 72 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 7639c2e..17bf531 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -172,7 +172,7 @@ static herr_t
H5D_compact_construct(H5F_t *f, H5D_t *dset)
{
hssize_t tmp_size; /* Temporary holder for raw data size */
- hsize_t comp_data_size; /* Size of compact data */
+ hsize_t max_comp_data_size; /* Max. allowed size of compact data */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5D_compact_construct)
@@ -191,8 +191,8 @@ H5D_compact_construct(H5F_t *f, H5D_t *dset)
/* Verify data size is smaller than maximum header message size
* (64KB) minus other layout message fields.
*/
- comp_data_size = H5O_MESG_MAX_SIZE - H5O_layout_meta_size(f, &(dset->shared->layout));
- if(dset->shared->layout.store.u.compact.size > comp_data_size)
+ max_comp_data_size = H5O_MESG_MAX_SIZE - H5D_layout_meta_size(f, &(dset->shared->layout), FALSE);
+ if(dset->shared->layout.store.u.compact.size > max_comp_data_size)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "compact dataset size is bigger than header message maximum size")
done:
diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c
index 4966cb5..1c74a66 100644
--- a/src/H5Dlayout.c
+++ b/src/H5Dlayout.c
@@ -114,6 +114,69 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D_layout_meta_size
+ *
+ * Purpose: Returns the size of the raw message in bytes except raw data
+ * part for compact dataset. This function doesn't take into
+ * account message alignment.
+ *
+ * Return: Success: Message data size in bytes
+ * Failure: 0
+ *
+ * Programmer: Raymond Lu
+ * August 14, 2002
+ *
+ *-------------------------------------------------------------------------
+ */
+size_t
+H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data)
+{
+ size_t ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT(H5D_layout_meta_size)
+
+ /* check args */
+ HDassert(f);
+ HDassert(layout);
+
+ ret_value = 1 + /* Version number */
+ 1; /* layout class type */
+
+ switch(layout->type) {
+ case H5D_COMPACT:
+ /* Size of raw data */
+ ret_value += 2;
+ if(include_compact_data)
+ ret_value += layout->store.u.compact.size;/* data for compact dataset */
+ break;
+
+ case H5D_CONTIGUOUS:
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
+ break;
+
+ case H5D_CHUNKED:
+ /* Number of dimensions (1 byte) */
+ HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
+ ret_value++;
+
+ /* Dimension sizes */
+ ret_value += layout->u.chunk.ndims * 4;
+
+ /* B-tree address */
+ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_layout_meta_size() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_layout_oh_create
*
* Purpose: Create layout/pline/efl information for dataset
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 3167f56..b77c391 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -559,6 +559,8 @@ H5_DLL herr_t H5D_scatgath_write(const H5D_io_info_t *io_info,
/* Functions that operate on dataset's layout information */
H5_DLL herr_t H5D_layout_set_io_ops(const H5D_t *dataset);
+H5_DLL size_t H5D_layout_meta_size(const H5F_t *f, const H5O_layout_t *layout,
+ hbool_t include_compact_data);
H5_DLL herr_t H5D_layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh,
H5D_t *dset, hid_t dapl_id);
H5_DLL herr_t H5D_layout_oh_read(H5D_t *dset, hid_t dxpl_id, hid_t dapl_id,
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 0f9370a..8c3e266 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -430,9 +430,9 @@ H5O_layout_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg
HDassert(f);
HDassert(mesg);
- ret_value = H5O_layout_meta_size(f, mesg);
- if(H5D_COMPACT == mesg->type)
- ret_value += mesg->store.u.compact.size;/* data for compact dataset */
+ /* Compute serialized size */
+ /* (including possibly compact data) */
+ ret_value = H5D_layout_meta_size(f, mesg, TRUE);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_layout_size() */
@@ -740,66 +740,3 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_layout_debug() */
-
-/*-------------------------------------------------------------------------
- * Function: H5O_layout_meta_size
- *
- * Purpose: Returns the size of the raw message in bytes except raw data
- * part for compact dataset. This function doesn't take into
- * account message alignment.
- *
- * Return: Success: Message data size in bytes(except raw data
- * for compact dataset)
- * Failure: 0
- *
- * Programmer: Raymond Lu
- * August 14, 2002
- *
- *-------------------------------------------------------------------------
- */
-size_t
-H5O_layout_meta_size(const H5F_t *f, const void *_mesg)
-{
- const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
- size_t ret_value;
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_layout_meta_size)
-
- /* check args */
- HDassert(f);
- HDassert(mesg);
-
- ret_value = 1 + /* Version number */
- 1; /* layout class type */
-
- switch(mesg->type) {
- case H5D_COMPACT:
- /* Size of raw data */
- ret_value += 2;
- break;
-
- case H5D_CONTIGUOUS:
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
- ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */
- break;
-
- case H5D_CHUNKED:
- /* Number of dimensions (1 byte) */
- HDassert(mesg->u.chunk.ndims > 0 && mesg->u.chunk.ndims <= H5O_LAYOUT_NDIMS);
- ret_value++;
-
- /* Dimension sizes */
- ret_value += mesg->u.chunk.ndims * 4;
-
- /* B-tree address */
- ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */
- break;
-
- default:
- HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, 0, "Invalid layout class")
- } /* end switch */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_layout_meta_size() */
-
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 74f6b97..085557b 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -680,9 +680,6 @@ H5_DLL herr_t H5O_loc_copy(H5O_loc_t *dst, const H5O_loc_t *src, H5_copy_depth_t
H5_DLL herr_t H5O_loc_hold_file(H5O_loc_t *loc);
H5_DLL herr_t H5O_loc_free(H5O_loc_t *loc);
-/* Layout operators */
-H5_DLL size_t H5O_layout_meta_size(const H5F_t *f, const void *_mesg);
-
/* EFL operators */
H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl);