summaryrefslogtreecommitdiffstats
path: root/src/H5Ofill.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Ofill.c')
-rw-r--r--src/H5Ofill.c215
1 files changed, 126 insertions, 89 deletions
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 613b521..cf64594 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -21,15 +21,15 @@
#include "H5Omodule.h" /* This source code file is part of the H5O module */
-#include "H5private.h" /* Generic Functions */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Opkg.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
-#include "H5Sprivate.h" /* Dataspaces */
+#include "H5private.h" /* Generic Functions */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Opkg.h" /* Object headers */
+#include "H5Pprivate.h" /* Property lists */
+#include "H5Sprivate.h" /* Dataspaces */
static void *H5O_fill_old_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
@@ -43,6 +43,8 @@ static size_t H5O_fill_new_size(const H5F_t *f, const void *_mesg);
static void *H5O_fill_copy(const void *_mesg, void *_dest);
static herr_t H5O_fill_reset(void *_mesg);
static herr_t H5O_fill_free(void *_mesg);
+static herr_t H5O_fill_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
@@ -105,55 +107,55 @@ static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *s
/* This message derives from H5O message class, for old fill value before version 1.5 */
const H5O_msg_class_t H5O_MSG_FILL[1] = {{
- H5O_FILL_ID, /*message id number */
- "fill", /*message name for debugging */
- sizeof(H5O_fill_t), /*native message size */
- H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
- H5O_fill_shared_decode, /*decode message */
- H5O_fill_shared_encode, /*encode message */
- H5O_fill_copy, /*copy the native value */
- H5O_fill_shared_size, /*raw message size */
- H5O_fill_reset, /*free internal memory */
- H5O_fill_free, /* free method */
- H5O_fill_shared_delete, /* file delete method */
- H5O_fill_shared_link, /* link method */
- NULL, /* set share method */
- NULL, /*can share method */
- NULL, /* pre copy native value to file */
- H5O_fill_shared_copy_file, /* copy native value to file */
- H5O_fill_shared_post_copy_file, /* post copy native value to file */
- NULL, /* get creation index */
- NULL, /* set creation index */
- H5O_fill_shared_debug /*debug the message */
+ H5O_FILL_ID, /*message id number */
+ "fill", /*message name for debugging */
+ sizeof(H5O_fill_t), /*native message size */
+ H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
+ H5O_fill_shared_decode, /*decode message */
+ H5O_fill_shared_encode, /*encode message */
+ H5O_fill_copy, /*copy the native value */
+ H5O_fill_shared_size, /*raw message size */
+ H5O_fill_reset, /*free internal memory */
+ H5O_fill_free, /* free method */
+ H5O_fill_shared_delete, /* file delete method */
+ H5O_fill_shared_link, /* link method */
+ NULL, /* set share method */
+ NULL, /*can share method */
+ H5O_fill_pre_copy_file, /* pre copy native value to file */
+ H5O_fill_shared_copy_file, /* copy native value to file */
+ H5O_fill_shared_post_copy_file, /* post copy native value to file */
+ NULL, /* get creation index */
+ NULL, /* set creation index */
+ H5O_fill_shared_debug /*debug the message */
}};
/* This message derives from H5O message class, for new fill value after version 1.4 */
const H5O_msg_class_t H5O_MSG_FILL_NEW[1] = {{
- H5O_FILL_NEW_ID, /*message id number */
- "fill_new", /*message name for debugging */
- sizeof(H5O_fill_t), /*native message size */
- H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
- H5O_fill_new_shared_decode, /*decode message */
- H5O_fill_new_shared_encode, /*encode message */
- H5O_fill_copy, /*copy the native value */
- H5O_fill_new_shared_size, /*raw message size */
- H5O_fill_reset, /*free internal memory */
- H5O_fill_free, /* free method */
- H5O_fill_new_shared_delete, /* file delete method */
- H5O_fill_new_shared_link, /* link method */
- NULL, /* set share method */
- NULL, /*can share method */
- NULL, /* pre copy native value to file */
- H5O_fill_new_shared_copy_file, /* copy native value to file */
- H5O_fill_new_shared_post_copy_file, /* post copy native value to file */
- NULL, /* get creation index */
- NULL, /* set creation index */
- H5O_fill_new_shared_debug /*debug the message */
+ H5O_FILL_NEW_ID, /*message id number */
+ "fill_new", /*message name for debugging */
+ sizeof(H5O_fill_t), /*native message size */
+ H5O_SHARE_IS_SHARABLE|H5O_SHARE_IN_OHDR, /* messages are sharable? */
+ H5O_fill_new_shared_decode, /*decode message */
+ H5O_fill_new_shared_encode, /*encode message */
+ H5O_fill_copy, /*copy the native value */
+ H5O_fill_new_shared_size, /*raw message size */
+ H5O_fill_reset, /*free internal memory */
+ H5O_fill_free, /* free method */
+ H5O_fill_new_shared_delete, /* file delete method */
+ H5O_fill_new_shared_link, /* link method */
+ NULL, /* set share method */
+ NULL, /*can share method */
+ H5O_fill_pre_copy_file, /* pre copy native value to file */
+ H5O_fill_new_shared_copy_file, /* copy native value to file */
+ H5O_fill_new_shared_post_copy_file, /* post copy native value to file */
+ NULL, /* get creation index */
+ NULL, /* set creation index */
+ H5O_fill_new_shared_debug /*debug the message */
}};
/* Format version bounds for fill value */
-static const unsigned H5O_fill_ver_bounds[] = {
- H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */
+const unsigned H5O_fill_ver_bounds[] = {
+ H5O_FILL_VERSION_1, /* H5F_LIBVER_EARLIEST */
H5O_FILL_VERSION_3, /* H5F_LIBVER_V18 */
H5O_FILL_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
@@ -178,11 +180,11 @@ H5FL_BLK_EXTERN(type_conv);
* Function: H5O_fill_new_decode
*
* Purpose: Decode a new fill value message. The new fill value
- * message is fill value plus space allocation time and
- * fill value writing time and whether fill value is defined.
+ * message is fill value plus space allocation time and
+ * fill value writing time and whether fill value is defined.
*
- * Return: Success: Ptr to new message in native struct.
- * Failure: NULL
+ * Return: Success: Ptr to new message in native struct.
+ * Failure: NULL
*
* Programmer: Raymond Lu
* Feb 26, 2002
@@ -202,7 +204,7 @@ H5O_fill_new_decode(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t
HDassert(p);
if(NULL == (fill = H5FL_CALLOC(H5O_fill_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message")
/* Version */
fill->version = *p++;
@@ -283,7 +285,7 @@ done:
if(!ret_value && fill) {
if(fill->buf)
H5MM_xfree(fill->buf);
- fill = H5FL_FREE(H5O_fill_t, fill);
+ fill = H5FL_FREE(H5O_fill_t, fill);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -343,7 +345,7 @@ done:
if(!ret_value && fill) {
if(fill->buf)
H5MM_xfree(fill->buf);
- fill = H5FL_FREE(H5O_fill_t, fill);
+ fill = H5FL_FREE(H5O_fill_t, fill);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -354,8 +356,8 @@ done:
* Function: H5O_fill_new_encode
*
* Purpose: Encode a new fill value message. The new fill value
- * message is fill value plus space allocation time and
- * fill value writing time and whether fill value is defined.
+ * message is fill value plus space allocation time and
+ * fill value writing time and whether fill value is defined.
*
* Return: Non-negative on success/Negative on failure
*
@@ -488,7 +490,7 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill)
* whether fill value is defined.
*
* Return: Success: Ptr to _DEST
- * Failure: NULL
+ * Failure: NULL
*
* Programmer: Raymond Lu
* Feb 26, 2002
@@ -498,16 +500,16 @@ H5O_fill_old_encode(H5F_t H5_ATTR_UNUSED *f, uint8_t *p, const void *_fill)
static void *
H5O_fill_copy(const void *_src, void *_dst)
{
- const H5O_fill_t *src = (const H5O_fill_t *)_src;
- H5O_fill_t *dst = (H5O_fill_t *)_dst;
- void *ret_value = NULL; /* Return value */
+ const H5O_fill_t *src = (const H5O_fill_t *)_src;
+ H5O_fill_t *dst = (H5O_fill_t *)_dst;
+ void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
HDassert(src);
if(!dst && NULL == (dst = H5FL_MALLOC(H5O_fill_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message")
/* Shallow copy basic fields */
*dst = *src;
@@ -523,9 +525,9 @@ H5O_fill_copy(const void *_src, void *_dst)
/* Copy fill value and its size */
if(src->buf) {
H5_CHECK_OVERFLOW(src->size, ssize_t, size_t);
- if(NULL == (dst->buf = H5MM_malloc((size_t)src->size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
- HDmemcpy(dst->buf, src->buf, (size_t)src->size);
+ if(NULL == (dst->buf = H5MM_malloc((size_t)src->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value")
+ HDmemcpy(dst->buf, src->buf, (size_t)src->size);
/* Check for needing to convert/copy fill value */
if(src->type) {
@@ -586,9 +588,9 @@ done:
if(!ret_value && dst) {
if(dst->buf)
H5MM_xfree(dst->buf);
- if(dst->type)
+ if(dst->type)
H5T_close(dst->type);
- if(!_dst)
+ if(!_dst)
dst = H5FL_FREE(H5O_fill_t, dst);
} /* end if */
@@ -600,13 +602,13 @@ done:
* Function: H5O_fill_new_size
*
* Purpose: Returns the size of the raw message in bytes not counting the
- * message type or size fields, but only the data fields. This
- * function doesn't take into account alignment. The new fill
- * value message is fill value plus space allocation time and
- * fill value writing time and whether fill value is defined.
+ * message type or size fields, but only the data fields. This
+ * function doesn't take into account alignment. The new fill
+ * value message is fill value plus space allocation time and
+ * fill value writing time and whether fill value is defined.
*
* Return: Success: Message data size in bytes w/o alignment.
- * Failure: 0
+ * Failure: 0
*
* Programmer: Raymond Lu
* Feb 26, 2002
@@ -616,8 +618,8 @@ done:
static size_t
H5O_fill_new_size(const H5F_t H5_ATTR_UNUSED *f, const void *_fill)
{
- const H5O_fill_t *fill = (const H5O_fill_t *)_fill;
- size_t ret_value = 0; /* Return value */
+ const H5O_fill_t *fill = (const H5O_fill_t *)_fill;
+ size_t ret_value = 0; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -728,8 +730,8 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
} /* end if */
fill->size = 0;
if(fill->type) {
- H5T_close(fill->type);
- fill->type = NULL;
+ H5T_close(fill->type);
+ fill->type = NULL;
} /* end if */
done:
@@ -799,6 +801,41 @@ H5O_fill_free(void *fill)
/*-------------------------------------------------------------------------
+ * Function: H5O_fill_pre_copy_file
+ *
+ * Purpose: Perform any necessary actions before copying message between
+ * files.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, March 9, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_fill_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src,
+ hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata)
+{
+ const H5O_fill_t *fill_src = (const H5O_fill_t *)mesg_src; /* Source fill value */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* check args */
+ HDassert(cpy_info);
+ HDassert(cpy_info->file_dst);
+
+ if(fill_src->version > H5O_fill_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "fill value message version out of bounds")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_fill_pre_copy_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_fill_debug
*
* Purpose: Prints debugging info for the message.
@@ -890,11 +927,11 @@ H5O_fill_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void
"Size:", fill->size);
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Data type:");
if(fill->type) {
- H5T_debug(fill->type, stream);
- fprintf(stream, "\n");
+ H5T_debug(fill->type, stream);
+ fprintf(stream, "\n");
} /* end if */
else
- fprintf(stream, "<dataset type>\n");
+ fprintf(stream, "<dataset type>\n");
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5O_fill_debug() */
@@ -904,9 +941,9 @@ H5O_fill_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void
* Function: H5O_fill_convert
*
* Purpose: Convert a fill value from whatever data type it currently has
- * to the specified dataset type. The `type' field of the fill
- * value struct will be set to NULL to indicate that it has the
- * same type as the dataset.
+ * to the specified dataset type. The `type' field of the fill
+ * value struct will be set to NULL to indicate that it has the
+ * same type as the dataset.
*
* Return: Non-negative on success/Negative on failure
*
@@ -932,21 +969,21 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_
/* No-op cases */
if(!fill->buf || !fill->type || 0 == H5T_cmp(fill->type, dset_type, FALSE)) {
/* Don't need datatype for fill value */
- if(fill->type)
+ if(fill->type)
H5T_close(fill->type);
- fill->type = NULL;
+ fill->type = NULL;
/* Note that the fill value info has changed */
*fill_changed = TRUE;
- HGOTO_DONE(SUCCEED);
+ HGOTO_DONE(SUCCEED);
} /* end if */
/*
* Can we convert between source and destination data types?
*/
if(NULL == (tpath = H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
/* Don't bother doing anything if there will be no actual conversion */
if(!H5T_path_noop(tpath)) {