summaryrefslogtreecommitdiffstats
path: root/src/H5Olayout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Olayout.c')
-rw-r--r--src/H5Olayout.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 8821694..b38d2a9 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -190,7 +190,7 @@ H5O_layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *
} /* end if */
else {
/* Layout class */
- mesg->type = (H5D_layout_t)*p++;
+ mesg->type = mesg->storage.type = (H5D_layout_t)*p++;
/* Interpret the rest of the message according to the layout class */
switch(mesg->type) {
@@ -389,19 +389,35 @@ H5O_layout_copy(const void *_mesg, void *_dest)
/* copy */
*dest = *mesg;
- /* Deep copy the buffer for compact datasets also */
- if(mesg->type == H5D_COMPACT && mesg->storage.u.compact.size > 0) {
- /* Allocate memory for the raw data */
- if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size)))
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
+ /* Special actions for each type of layout */
+ switch(mesg->type) {
+ case H5D_COMPACT:
+ /* Deep copy the buffer for compact datasets also */
+ if(mesg->storage.u.compact.size > 0) {
+ /* Allocate memory for the raw data */
+ if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size)))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset")
- /* Copy over the raw data */
- HDmemcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size);
- } /* end if */
+ /* Copy over the raw data */
+ HDmemcpy(dest->storage.u.compact.buf, mesg->storage.u.compact.buf, dest->storage.u.compact.size);
+ } /* end if */
+ break;
- /* Reset the pointer of the chunked storage index but not the address */
- if(dest->type == H5D_CHUNKED && dest->storage.u.chunk.ops)
- H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE);
+ case H5D_CONTIGUOUS:
+ /* Nothing required */
+ break;
+
+ case H5D_CHUNKED:
+ /* Reset the pointer of the chunked storage index but not the address */
+ if(dest->storage.u.chunk.ops)
+ H5D_chunk_idx_reset(&dest->storage.u.chunk, FALSE);
+ break;
+
+ case H5D_LAYOUT_ERROR:
+ case H5D_NLAYOUTS:
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, NULL, "Invalid layout class")
+ } /* end switch */
/* Set return value */
ret_value = dest;
@@ -686,7 +702,7 @@ H5O_layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const vo
FILE * stream, int indent, int fwidth)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
- unsigned u;
+ size_t u;
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -709,7 +725,7 @@ H5O_layout_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const vo
"Number of dimensions:",
(unsigned long)(mesg->u.chunk.ndims));
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Size:");
- for(u = 0; u < mesg->u.chunk.ndims; u++)
+ for(u = 0; u < (size_t)mesg->u.chunk.ndims; u++)
HDfprintf(stream, "%s%lu", u ? ", " : "", (unsigned long)(mesg->u.chunk.dim[u]));
HDfprintf(stream, "}\n");