summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-03 00:54:33 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-03 00:54:33 (GMT)
commite9ea7e8eaf0627f863d8a5f7805fdbb4334a67b0 (patch)
tree541b769b58cd16e4b297cd8f5abee0fb820a2802
parent84a4166e72abac9eb08a7daa3f67c90227641cda (diff)
downloadhdf5-e9ea7e8eaf0627f863d8a5f7805fdbb4334a67b0.zip
hdf5-e9ea7e8eaf0627f863d8a5f7805fdbb4334a67b0.tar.gz
hdf5-e9ea7e8eaf0627f863d8a5f7805fdbb4334a67b0.tar.bz2
[svn-r12708] Description:
Add the "use the latest version of the format" support to datatype messages. And a regression test to check that it's working. Also, found that we have been over-allocating space for compound datatype messages (when they have array datatypes or can use the latest version of the format) and trimmed the size back. Clean up datatype & dataspace encode/decode routines by having them allocate & release "fake" file structures, which gets them out of needing to "know" about the internals of file structures. Other minor whitespace/formatting cleanups, etc. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
-rw-r--r--MANIFEST1
-rw-r--r--src/H5F.c56
-rw-r--r--src/H5Ffake.c128
-rw-r--r--src/H5Fpkg.h21
-rw-r--r--src/H5Fprivate.h7
-rw-r--r--src/H5Fsuper.c7
-rw-r--r--src/H5Gobj.c6
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Odtype.c444
-rw-r--r--src/H5S.c85
-rw-r--r--src/H5T.c82
-rw-r--r--src/H5Tcommit.c34
-rwxr-xr-xsrc/Makefile.am2
-rw-r--r--src/Makefile.in5
-rw-r--r--test/dtypes.c139
15 files changed, 684 insertions, 335 deletions
diff --git a/MANIFEST b/MANIFEST
index e2480e4..8d19fca 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -456,6 +456,7 @@
./src/H5Eterm.h
./src/H5F.c
./src/H5Fdbg.c
+./src/H5Ffake.c
./src/H5Fmount.c
./src/H5Fsfile.c
./src/H5Fsuper.c
diff --git a/src/H5F.c b/src/H5F.c
index 1fd7efd..322b980 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -26,7 +26,6 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5FDprivate.h" /* File drivers */
-#include "H5FLprivate.h" /* Free lists */
#include "H5Gprivate.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
@@ -73,10 +72,10 @@ static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned fla
static herr_t H5F_close(H5F_t *f);
/* Declare a free list to manage the H5F_t struct */
-H5FL_DEFINE_STATIC(H5F_t);
+H5FL_DEFINE(H5F_t);
/* Declare a free list to manage the H5F_file_t struct */
-H5FL_DEFINE_STATIC(H5F_file_t);
+H5FL_DEFINE(H5F_file_t);
/*-------------------------------------------------------------------------
@@ -1450,7 +1449,7 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
FUNC_ENTER_NOAPI_NOINIT(H5F_new)
if(NULL == (f = H5FL_CALLOC(H5F_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
f->file_id = -1;
if(shared) {
@@ -1459,7 +1458,8 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
} /* end if */
else {
HDassert(lf != NULL);
- f->shared = H5FL_CALLOC(H5F_file_t);
+ if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t)))
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
f->shared->super_addr = HADDR_UNDEF;
f->shared->base_addr = HADDR_UNDEF;
f->shared->freespace_addr = HADDR_UNDEF;
@@ -2856,11 +2856,6 @@ H5F_sizeof_addr(const H5F_t *f)
* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
* September 29, 2000
*
- * Modifications:
- *
- * Raymond Lu, Oct 14, 2001
- * Changed to the new generic property list.
- *
*-------------------------------------------------------------------------
*/
size_t
@@ -2873,7 +2868,7 @@ H5F_sizeof_size(const H5F_t *f)
assert(f->shared);
FUNC_LEAVE_NOAPI(f->shared->sizeof_size)
-}
+} /* H5F_sizeof_size() */
/*-------------------------------------------------------------------------
@@ -2892,9 +2887,6 @@ H5F_sizeof_size(const H5F_t *f)
* slu@ncsa.uiuc.edu
* Oct 14 2001
*
- * Modifications:
- * Quincey Koziol, 2001-10-15
- * Added this header and removed unused ret_value variable.
*-------------------------------------------------------------------------
*/
unsigned
@@ -2907,7 +2899,7 @@ H5F_sym_leaf_k(const H5F_t *f)
assert(f->shared);
FUNC_LEAVE_NOAPI(f->shared->sym_leaf_k)
-}
+} /* end H5F_sym_leaf_k() */
/*-------------------------------------------------------------------------
@@ -2926,9 +2918,6 @@ H5F_sym_leaf_k(const H5F_t *f)
* slu@ncsa.uiuc.edu
* Oct 14 2001
*
- * Modifications:
- * Quincey Koziol, 2001-10-15
- * Added this header and removed unused ret_value variable.
*-------------------------------------------------------------------------
*/
unsigned
@@ -3455,8 +3444,6 @@ H5F_gc_ref(const H5F_t *f)
* koziol@ncsa.uiuc.edu
* May 25 2005
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
hid_t
@@ -3473,6 +3460,35 @@ H5F_get_fcpl(const H5F_t *f)
/*-------------------------------------------------------------------------
+ * Function: H5F_use_latest_format
+ *
+ * Purpose: Retrieve the 'use the latest version of the format' flag for
+ * the file.
+ *
+ * Return: Success: Non-negative, the 'use the latest format' flag
+ *
+ * Failure: (can't happen)
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 2 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5F_use_latest_format(const H5F_t *f)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_use_latest_format)
+
+ HDassert(f);
+ HDassert(f->shared);
+
+ FUNC_LEAVE_NOAPI(f->shared->latest_format)
+} /* end H5F_use_latest_format() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_block_read
*
* Purpose: Reads some data from a file/server/etc into a buffer.
diff --git a/src/H5Ffake.c b/src/H5Ffake.c
new file mode 100644
index 0000000..f9adc39
--- /dev/null
+++ b/src/H5Ffake.c
@@ -0,0 +1,128 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+
+/* Interface initialization */
+#define H5_INTERFACE_INIT_FUNC H5F_init_fake_interface
+
+
+/* Packages needed by this file... */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+
+/* PRIVATE PROTOTYPES */
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5F_init_fake_interface -- Initialize interface-specific information
+USAGE
+ herr_t H5F_init_fake_interface()
+
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines. (Just calls
+ H5F_init_iterface currently).
+
+--------------------------------------------------------------------------*/
+static herr_t
+H5F_init_fake_interface(void)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_init_fake_interface)
+
+ FUNC_LEAVE_NOAPI(H5F_init())
+} /* H5F_init_fake_interface() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_fake_alloc
+ *
+ * Purpose: Allocate a "fake" file structure, for various routines to
+ * use for encoding/decoding data structures using internal API
+ * routines that need a file structure, but don't ultimately
+ * depend on having a "real" file.
+ *
+ * Return: Success: Pointer to 'faked up' file structure
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 2, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+H5F_t *
+H5F_fake_alloc(size_t sizeof_size)
+{
+ H5F_t *f = NULL; /* Pointer to fake file struct */
+ H5F_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5F_fake_alloc, NULL)
+
+ /* Allocate faked file struct */
+ if(NULL == (f = H5FL_CALLOC(H5F_t)))
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
+ if(NULL == (f->shared = H5FL_CALLOC(H5F_file_t)))
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate shared file structure")
+
+ /* Only set fields necessary for clients */
+ if(sizeof_size == 0)
+ f->shared->sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF;
+ else
+ f->shared->sizeof_size = sizeof_size;
+
+ /* Set return value */
+ ret_value = f;
+
+done:
+ if(!ret_value)
+ H5F_fake_free(f);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_fake_alloc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_fake_free
+ *
+ * Purpose: Free a "fake" file structure.
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 2, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_fake_free(H5F_t *f)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_fake_free)
+
+ /* Free faked file struct */
+ if(f) {
+ /* Destroy shared file struct */
+ if(f->shared)
+ f->shared = H5FL_FREE(H5F_file_t, f->shared);
+ H5FL_FREE(H5F_t, f);
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5F_fake_free() */
+
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 7944c89..a0e96d7 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -35,6 +35,7 @@
/* Other private headers needed by this file */
#include "H5private.h" /* Generic Functions */
+#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5Gprivate.h" /* Groups */
#include "H5RCprivate.h" /* Reference counted object functions */
@@ -155,12 +156,22 @@ struct H5F_t {
H5F_mtab_t mtab; /* File mount table */
};
-/* Forward declarations for prototype arguments */
-struct H5D_dxpl_cache_t;
-struct H5D_dcpl_cache_t;
-union H5D_storage_t;
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* Declare a free list to manage the H5F_t struct */
+H5FL_EXTERN(H5F_t);
+
+/* Declare a free list to manage the H5F_file_t struct */
+H5FL_EXTERN(H5F_file_t);
+
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
-/* Private functions, not part of the publicly documented API */
#ifdef NOT_YET
H5_DLL void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l);
#endif /* NOT_YET */
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index bfba2e5..c0659d3 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -262,6 +262,7 @@ typedef struct H5F_t H5F_t;
/* Sieve buffer size for datasets */
#define H5F_SIEVE_BUF_SIZE(F) ((F)->shared->sieve_buf_size)
#define H5F_GC_REF(F) ((F)->shared->gc_ref)
+#define H5F_USE_LATEST_FORMAT(F) ((F)->shared->latest_format)
#else /* H5F_PACKAGE */
#define H5F_FCPL(F) (H5F_get_fcpl(F))
#define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F))
@@ -276,6 +277,7 @@ typedef struct H5F_t H5F_t;
#define H5F_BASE_ADDR(F) (H5F_get_base_addr(F))
#define H5F_SIEVE_BUF_SIZE(F) (H5F_sieve_buf_size(F))
#define H5F_GC_REF(F) (H5F_gc_ref(F))
+#define H5F_USE_LATEST_FORMAT(F) (H5F_use_latest_format(F))
#endif /* H5F_PACKAGE */
@@ -515,6 +517,7 @@ H5_DLL double H5F_rdcc_w0(const H5F_t *f);
H5_DLL struct H5RC_t *H5F_grp_btree_shared(const H5F_t *f);
H5_DLL size_t H5F_sieve_buf_size(const H5F_t *f);
H5_DLL unsigned H5F_gc_ref(const H5F_t *f);
+H5_DLL hbool_t H5F_use_latest_format(const H5F_t *f);
/* Functions that operate on blocks of bytes wrt super block */
H5_DLL herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr,
@@ -536,6 +539,10 @@ H5_DLL herr_t H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id,
/* Shared file list related routines */
H5_DLL herr_t H5F_sfile_assert_num(unsigned n);
+/* Routines for creating & destroying "fake" file structures */
+H5_DLL H5F_t *H5F_fake_alloc(size_t sizeof_size);
+H5_DLL herr_t H5F_fake_free(H5F_t *f);
+
/* Debugging functions */
H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth);
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index d7fa782..e3dd12f 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -33,7 +33,7 @@
NAME
H5F_init_super_interface -- Initialize interface-specific information
USAGE
- herr_t H5T_init_super_interface()
+ herr_t H5F_init_super_interface()
RETURNS
Non-negative on success/Negative on failure
@@ -96,7 +96,6 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc, haddr_t addr,
H5P_genplist_t *c_plist; /* File creation property list */
herr_t ret_value = SUCCEED;
- /* Decoding */
FUNC_ENTER_NOAPI(H5F_read_superblock, FAIL)
/* Short cuts */
@@ -363,7 +362,7 @@ H5F_read_superblock(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc, haddr_t addr,
done:
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5F_read_superblock() */
/*-------------------------------------------------------------------------
@@ -395,7 +394,6 @@ H5F_init_superblock(const H5F_t *f, hid_t dxpl_id)
H5P_genplist_t *plist; /* Property list */
hsize_t ret_value;
- /* Encoding */
FUNC_ENTER_NOAPI(H5F_init_superblock, UFAIL)
/* Get the shared file creation property list */
@@ -500,7 +498,6 @@ H5F_write_superblock(H5F_t *f, hid_t dxpl_id)
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
- /* Encoding */
FUNC_ENTER_NOAPI(H5F_write_superblock, FAIL)
/* Get the shared file creation property list */
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index 960061f..4500ed4 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -236,8 +236,8 @@ H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo,
HDassert(oloc);
/* Check for using the latest version of the group format */
-/* XXX: add more checks for creating "new format" groups when needed */
- if(f->shared->latest_format || ginfo->track_corder)
+ /* (add more checks for creating "new format" groups when needed) */
+ if(H5F_USE_LATEST_FORMAT(f) || ginfo->track_corder)
use_latest_format = TRUE;
else
use_latest_format = FALSE;
@@ -277,7 +277,7 @@ H5G_obj_create(H5F_t *f, hid_t dxpl_id, const H5O_ginfo_t *ginfo,
hdr_size = 4 + 2 * H5F_SIZEOF_ADDR(f);
/*
- * Create symbol table object header. It has a zero link count
+ * Create group's object header. It has a zero link count
* since nothing refers to it yet. The link count will be
* incremented if the object is added to the group directed graph.
*/
diff --git a/src/H5O.c b/src/H5O.c
index 821f4ce..2e865f7 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -3996,6 +3996,7 @@ H5O_encode(H5F_t *f, unsigned char *buf, const void *obj, unsigned type_id)
FUNC_ENTER_NOAPI(H5O_encode,FAIL)
/* check args */
+ HDassert(f);
HDassert(type_id < NELMTS(H5O_msg_class_g));
type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
@@ -4037,6 +4038,7 @@ H5O_decode(H5F_t *f, hid_t dxpl_id, const unsigned char *buf, unsigned type_id)
FUNC_ENTER_NOAPI(H5O_decode, NULL)
/* check args */
+ HDassert(f);
HDassert(type_id < NELMTS(H5O_msg_class_g));
type = H5O_msg_class_g[type_id]; /* map the type ID to the actual type object */
HDassert(type);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index afe6e27..5723808 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -18,6 +18,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free Lists */
+#include "H5Fprivate.h" /* Files */
#include "H5Gprivate.h" /* Groups */
#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
@@ -25,19 +26,19 @@
/* PRIVATE PROTOTYPES */
-static herr_t H5O_dtype_encode (H5F_t *f, uint8_t *p, const void *mesg);
-static void *H5O_dtype_decode (H5F_t *f, hid_t dxpl_id, const uint8_t *p);
-static void *H5O_dtype_copy (const void *_mesg, void *_dest, unsigned update_flags);
-static size_t H5O_dtype_size (const H5F_t *f, const void *_mesg);
-static herr_t H5O_dtype_reset (void *_mesg);
-static herr_t H5O_dtype_free (void *_mesg);
-static herr_t H5O_dtype_get_share (H5F_t *f, const void *_mesg,
+static herr_t H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg);
+static void *H5O_dtype_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p);
+static void *H5O_dtype_copy(const void *_mesg, void *_dest, unsigned update_flags);
+static size_t H5O_dtype_size(const H5F_t *f, const void *_mesg);
+static herr_t H5O_dtype_reset(void *_mesg);
+static herr_t H5O_dtype_free(void *_mesg);
+static herr_t H5O_dtype_get_share(H5F_t *f, const void *_mesg,
H5O_shared_t *sh);
-static herr_t H5O_dtype_set_share (H5F_t *f, void *_mesg,
+static herr_t H5O_dtype_set_share(H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
-static herr_t H5O_dtype_debug (H5F_t *f, hid_t dxpl_id, const void *_mesg,
+static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
/* This message derives from H5O message class */
@@ -80,6 +81,10 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
*/
#define H5O_DTYPE_VERSION_3 3
+/* The latest version of the format. Look through the 'encode helper' routine
+ * and 'size' callback for places to change when updating this. */
+#define H5O_DTYPE_VERSION_LATEST H5O_DTYPE_VERSION_3
+
/*-------------------------------------------------------------------------
* Function: H5O_dtype_decode_helper
@@ -102,16 +107,16 @@ const H5O_msg_class_t H5O_MSG_DTYPE[1] = {{
static herr_t
H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
{
- unsigned flags, version;
- unsigned i, j;
- size_t z;
- herr_t ret_value=SUCCEED; /* Return value */
+ unsigned flags, version;
+ unsigned i, j;
+ size_t z;
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_decode_helper);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_decode_helper)
/* check args */
- assert(pp && *pp);
- assert(dt && dt->shared);
+ HDassert(pp && *pp);
+ HDassert(dt && dt->shared);
/* decode */
UINT32DECODE(*pp, flags);
@@ -122,7 +127,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
flags >>= 8;
UINT32DECODE(*pp, dt->shared->size);
- switch (dt->shared->type) {
+ switch(dt->shared->type) {
case H5T_INTEGER:
/*
* Integer types...
@@ -151,9 +156,9 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
* Opaque types...
*/
z = flags & (H5T_OPAQUE_TAG_MAX - 1);
- assert(0==(z&0x7)); /*must be aligned*/
- if (NULL==(dt->shared->u.opaque.tag=H5MM_malloc(z+1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HDassert(0==(z&0x7)); /*must be aligned*/
+ if(NULL == (dt->shared->u.opaque.tag = H5MM_malloc(z + 1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
HDmemcpy(dt->shared->u.opaque.tag, *pp, z);
dt->shared->u.opaque.tag[z] = '\0';
*pp += z;
@@ -165,39 +170,42 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
*/
dt->shared->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
if(version == H5O_DTYPE_VERSION_3) {
- /*Unsupported byte order*/
+ /* Unsupported byte order*/
if((flags & 0x40) && !(flags & 0x1))
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bad byte order for datatype message")
- /*VAX order if both 1st and 6th bits are turned on*/
+ /* VAX order if both 1st and 6th bits are turned on*/
if(flags & 0x40)
dt->shared->u.atomic.order = H5T_ORDER_VAX;
- }
+ } /* end if */
dt->shared->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
dt->shared->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- switch ((flags >> 4) & 0x03) {
+ switch((flags >> 4) & 0x03) {
case 0:
dt->shared->u.atomic.u.f.norm = H5T_NORM_NONE;
break;
+
case 1:
dt->shared->u.atomic.u.f.norm = H5T_NORM_MSBSET;
break;
+
case 2:
dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED;
break;
+
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization")
+ } /* end switch */
dt->shared->u.atomic.u.f.sign = (flags >> 8) & 0xff;
UINT16DECODE(*pp, dt->shared->u.atomic.offset);
UINT16DECODE(*pp, dt->shared->u.atomic.prec);
dt->shared->u.atomic.u.f.epos = *(*pp)++;
dt->shared->u.atomic.u.f.esize = *(*pp)++;
- assert(dt->shared->u.atomic.u.f.esize > 0);
+ HDassert(dt->shared->u.atomic.u.f.esize > 0);
dt->shared->u.atomic.u.f.mpos = *(*pp)++;
dt->shared->u.atomic.u.f.msize = *(*pp)++;
- assert(dt->shared->u.atomic.u.f.msize > 0);
+ HDassert(dt->shared->u.atomic.u.f.msize > 0);
UINT32DECODE(*pp, dt->shared->u.atomic.u.f.ebias);
break;
@@ -206,24 +214,23 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
* Compound datatypes...
*/
dt->shared->u.compnd.nmembs = flags & 0xffff;
- assert(dt->shared->u.compnd.nmembs > 0);
+ HDassert(dt->shared->u.compnd.nmembs > 0);
dt->shared->u.compnd.packed = TRUE; /* Start off packed */
dt->shared->u.compnd.nalloc = dt->shared->u.compnd.nmembs;
- dt->shared->u.compnd.memb = H5MM_calloc(dt->shared->u.compnd.nalloc*
- sizeof(H5T_cmemb_t));
- if (NULL==dt->shared->u.compnd.memb)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- unsigned ndims=0; /* Number of dimensions of the array field */
+ dt->shared->u.compnd.memb = H5MM_calloc(dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t));
+ if(NULL == dt->shared->u.compnd.memb)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ unsigned ndims = 0; /* Number of dimensions of the array field */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */
int perm[H5O_LAYOUT_NDIMS]; /* Dimension permutations */
- unsigned perm_word=0; /* Dimension permutation information */
+ unsigned perm_word = 0; /* Dimension permutation information */
H5T_t *array_dt; /* Temporary pointer to the array datatype */
H5T_t *temp_type; /* Temporary pointer to the field's datatype */
/* Decode the field name */
dt->shared->u.compnd.memb[i].name = H5MM_xstrdup((const char *)*pp);
- /*multiple of 8 w/ null terminator */
+ /* multiple of 8 w/ null terminator */
*pp += ((HDstrlen((const char *)*pp) + 8) / 8) * 8;
/* Decode the field offset */
@@ -235,7 +242,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
if(version == H5O_DTYPE_VERSION_1) {
/* Decode the number of dimensions */
ndims = *(*pp)++;
- assert(ndims <= 4);
+ HDassert(ndims <= 4);
*pp += 3; /*reserved bytes */
/* Decode dimension permutation (unused currently) */
@@ -245,43 +252,43 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
*pp += 4;
/* Decode array dimension sizes */
- for (j=0; j<4; j++)
+ for(j = 0; j < 4; j++)
UINT32DECODE(*pp, dim[j]);
} /* end if */
/* Allocate space for the field's datatype */
if(NULL == (temp_type = H5T_alloc()))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Decode the field's datatype information */
- if (H5O_dtype_decode_helper(f, pp, temp_type)<0) {
- for (j=0; j<=i; j++)
+ if(H5O_dtype_decode_helper(f, pp, temp_type) < 0) {
+ for(j = 0; j <= i; j++)
H5MM_xfree(dt->shared->u.compnd.memb[j].name);
H5MM_xfree(dt->shared->u.compnd.memb);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type")
+ } /* end if */
/* Go create the array datatype now, for older versions of the datatype message */
if(version == H5O_DTYPE_VERSION_1) {
/* Check if this member is an array field */
- if(ndims>0) {
+ if(ndims > 0) {
/* Set up the permutation vector for the array create */
- for (j=0; j<ndims; j++)
- perm[j]=(perm_word>>(j*8))&0xff;
+ for(j = 0; j < ndims; j++)
+ perm[j]=(perm_word >> (j * 8)) & 0xff;
/* Create the array datatype for the field */
- if ((array_dt=H5T_array_create(temp_type,(int)ndims,dim,perm))==NULL) {
- for (j=0; j<=i; j++)
+ if((array_dt = H5T_array_create(temp_type, (int)ndims, dim, perm)) == NULL) {
+ for(j = 0; j <= i; j++)
H5MM_xfree(dt->shared->u.compnd.memb[j].name);
H5MM_xfree(dt->shared->u.compnd.memb);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype")
+ } /* end if */
/* Close the base type for the array */
H5T_close(temp_type);
/* Make the array type the type that is set for the field */
- temp_type=array_dt;
+ temp_type = array_dt;
} /* end if */
} /* end if */
@@ -289,38 +296,38 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
* Set the "force conversion" flag if VL datatype fields exist in this
* type or any component types
*/
- if(temp_type->shared->force_conv==TRUE)
- dt->shared->force_conv=TRUE;
+ if(temp_type->shared->force_conv == TRUE)
+ dt->shared->force_conv = TRUE;
/* Member size */
dt->shared->u.compnd.memb[i].size = temp_type->shared->size;
/* Set the field datatype (finally :-) */
- dt->shared->u.compnd.memb[i].type=temp_type;
+ dt->shared->u.compnd.memb[i].type = temp_type;
/* Check if the datatype stayed packed */
if(dt->shared->u.compnd.packed) {
/* Check if the member type is packed */
- if(H5T_is_packed(temp_type)>0) {
- if(i==0) {
+ if(H5T_is_packed(temp_type) > 0) {
+ if(i == 0) {
/* If the is the first member, the datatype is not packed
* if the first member isn't at offset 0
*/
- if(dt->shared->u.compnd.memb[i].offset>0)
- dt->shared->u.compnd.packed=FALSE;
+ if(dt->shared->u.compnd.memb[i].offset > 0)
+ dt->shared->u.compnd.packed = FALSE;
} /* end if */
else {
/* If the is not the first member, the datatype is not
* packed if the new member isn't adjoining the previous member
*/
- if(dt->shared->u.compnd.memb[i].offset!=(dt->shared->u.compnd.memb[i-1].offset+dt->shared->u.compnd.memb[i-1].size))
- dt->shared->u.compnd.packed=FALSE;
+ if(dt->shared->u.compnd.memb[i].offset != (dt->shared->u.compnd.memb[i - 1].offset + dt->shared->u.compnd.memb[i - 1].size))
+ dt->shared->u.compnd.packed = FALSE;
} /* end else */
} /* end if */
else
- dt->shared->u.compnd.packed=FALSE;
+ dt->shared->u.compnd.packed = FALSE;
} /* end if */
- }
+ } /* end for */
break;
case H5T_ENUM:
@@ -330,22 +337,21 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
dt->shared->u.enumer.nmembs = dt->shared->u.enumer.nalloc = flags & 0xffff;
if(NULL == (dt->shared->parent = H5T_alloc()))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype");
- if (NULL==(dt->shared->u.enumer.name=H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) ||
- NULL==(dt->shared->u.enumer.value=H5MM_calloc(dt->shared->u.enumer.nalloc *
- dt->shared->parent->shared->size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if(H5O_dtype_decode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent datatype")
+ if(NULL == (dt->shared->u.enumer.name = H5MM_calloc(dt->shared->u.enumer.nalloc * sizeof(char*))) ||
+ NULL == (dt->shared->u.enumer.value = H5MM_calloc(dt->shared->u.enumer.nalloc * dt->shared->parent->shared->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Names, each a multiple of 8 with null termination */
- for (i=0; i<dt->shared->u.enumer.nmembs; i++) {
+ for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
dt->shared->u.enumer.name[i] = H5MM_xstrdup((const char*)*pp);
- *pp += ((HDstrlen((const char*)*pp)+8)/8)*8;
- }
+ *pp += ((HDstrlen((const char*)*pp) + 8) / 8) * 8;
+ } /* end for */
/* Values */
HDmemcpy(dt->shared->u.enumer.value, *pp,
- dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
+ dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
*pp += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
@@ -360,12 +366,12 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
dt->shared->u.atomic.u.r.rtype = (H5R_type_t)(flags & 0x0f);
/* Set extra information for object references, so the hobj_ref_t gets swizzled correctly */
- if(dt->shared->u.atomic.u.r.rtype==H5R_OBJECT) {
+ if(dt->shared->u.atomic.u.r.rtype == H5R_OBJECT) {
/* This type is on disk */
dt->shared->u.atomic.u.r.loc = H5T_LOC_DISK;
/* This type needs conversion */
- dt->shared->force_conv=TRUE;
+ dt->shared->force_conv = TRUE;
} /* end if */
break;
@@ -380,27 +386,27 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
dt->shared->u.atomic.u.s.pad = (H5T_str_t)(flags & 0x0f);
- dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags>>4) & 0x0f);
+ dt->shared->u.atomic.u.s.cset = (H5T_cset_t)((flags >> 4) & 0x0f);
break;
case H5T_VLEN: /* Variable length datatypes... */
/* Set the type of VL information, either sequence or string */
dt->shared->u.vlen.type = (H5T_vlen_type_t)(flags & 0x0f);
if(dt->shared->u.vlen.type == H5T_VLEN_STRING) {
- dt->shared->u.vlen.pad = (H5T_str_t)((flags>>4) & 0x0f);
- dt->shared->u.vlen.cset = (H5T_cset_t)((flags>>8) & 0x0f);
+ dt->shared->u.vlen.pad = (H5T_str_t)((flags >> 4) & 0x0f);
+ dt->shared->u.vlen.cset = (H5T_cset_t)((flags >> 8) & 0x0f);
} /* end if */
/* Decode base type of VL information */
if(NULL == (dt->shared->parent = H5T_alloc()))
- HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(H5O_dtype_decode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type")
dt->shared->force_conv=TRUE;
/* Mark this type as on disk */
- if (H5T_set_loc(dt, f, H5T_LOC_DISK)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location");
+ if(H5T_set_loc(dt, f, H5T_LOC_DISK) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
break;
case H5T_TIME: /* Time datatypes */
@@ -419,44 +425,44 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
*pp += 3;
/* Decode array dimension sizes & compute number of elements */
- for (j=0, dt->shared->u.array.nelem=1; j<(unsigned)dt->shared->u.array.ndims; j++) {
+ for(j = 0, dt->shared->u.array.nelem = 1; j < (unsigned)dt->shared->u.array.ndims; j++) {
UINT32DECODE(*pp, dt->shared->u.array.dim[j]);
dt->shared->u.array.nelem *= dt->shared->u.array.dim[j];
} /* end for */
/* Decode array dimension permutations (even though they are unused currently) */
- for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++)
+ for(j = 0; j < (unsigned)dt->shared->u.array.ndims; j++)
UINT32DECODE(*pp, dt->shared->u.array.perm[j]);
/* Decode base type of array */
if(NULL == (dt->shared->parent = H5T_alloc()))
- HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
- if (H5O_dtype_decode_helper(f, pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ if(H5O_dtype_decode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type")
/*
* Set the "force conversion" flag if a VL base datatype is used or
* or if any components of the base datatype are VL types.
*/
- if(dt->shared->parent->shared->force_conv==TRUE)
- dt->shared->force_conv=TRUE;
+ if(dt->shared->parent->shared->force_conv == TRUE)
+ dt->shared->force_conv = TRUE;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown datatype class found");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown datatype class found")
+ } /* end switch */
done:
- if(ret_value <0)
- {
+ if(ret_value < 0) {
if(dt != NULL) {
if(dt->shared != NULL)
H5FL_FREE(H5T_shared_t, dt->shared);
H5FL_FREE(H5T_t, dt);
} /* end if */
- }
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dtype_decode_helper() */
/*-------------------------------------------------------------------------
@@ -469,37 +475,35 @@ done:
* Programmer: Robb Matzke
* Monday, December 8, 1997
*
- * Modifications:
- * Robb Matzke, Thursday, May 20, 1999
- * Added support for bitfields and opaque types.
- *
- * Raymond Lu. Monday, Mar 13, 2006
- * Added support for VAX floating-point types.
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
+H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt)
{
- htri_t has_array = FALSE; /* Whether a compound datatype has an array inside it */
- hbool_t has_vax = FALSE; /* Whether VAX floating number exists */
- unsigned flags = 0;
- char *hdr = (char *)*pp;
- unsigned i, j;
- size_t n, z, aligned;
- uint8_t version; /* version number */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode_helper);
+ htri_t has_array = FALSE; /* Whether a compound datatype has an array inside it */
+ hbool_t has_vax = FALSE; /* Whether VAX floating number exists */
+ unsigned flags = 0;
+ char *hdr = (char *)*pp;
+ unsigned i;
+ size_t n, z;
+ uint8_t version; /* version number */
+ hbool_t use_latest_format; /* Flag indicating the new group format should be used */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode_helper)
/* check args */
- assert(pp && *pp);
- assert(dt);
+ HDassert(pp && *pp);
+ HDassert(dt);
+
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
/* skip the type and class bit-field for now */
*pp += 4;
UINT32ENCODE(*pp, dt->shared->size);
- switch (dt->shared->type) {
+ switch(dt->shared->type) {
case H5T_INTEGER:
/*
* Integer datatypes...
@@ -511,7 +515,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
}
switch (dt->shared->u.atomic.lsb_pad) {
@@ -521,7 +525,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.msb_pad) {
@@ -531,7 +535,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.u.i.sign) {
@@ -541,7 +545,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x08;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet")
}
UINT16ENCODE(*pp, dt->shared->u.atomic.offset);
@@ -559,7 +563,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
}
switch (dt->shared->u.atomic.lsb_pad) {
@@ -569,7 +573,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.msb_pad) {
@@ -579,7 +583,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
UINT16ENCODE(*pp, dt->shared->u.atomic.offset);
@@ -592,12 +596,17 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
* multiple of eight characters and null padded (not necessarily
* null terminated).
*/
- z = HDstrlen(dt->shared->u.opaque.tag);
- aligned = (z+7) & (H5T_OPAQUE_TAG_MAX - 8);
- flags |= aligned;
- HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned));
- for (n=MIN(z,aligned); n<aligned; n++) (*pp)[n] = 0;
- *pp += aligned;
+ {
+ size_t aligned;
+
+ z = HDstrlen(dt->shared->u.opaque.tag);
+ aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8);
+ flags |= aligned;
+ HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned));
+ for(n = MIN(z, aligned); n < aligned; n++)
+ (*pp)[n] = 0;
+ *pp += aligned;
+ }
break;
case H5T_FLOAT:
@@ -615,7 +624,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
has_vax = TRUE;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
}
switch (dt->shared->u.atomic.lsb_pad) {
@@ -625,7 +634,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.msb_pad) {
@@ -635,7 +644,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.u.f.pad) {
@@ -645,7 +654,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x08;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet")
}
switch (dt->shared->u.atomic.u.f.norm) {
@@ -658,7 +667,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x20;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet")
}
flags |= (dt->shared->u.atomic.u.f.sign << 8) & 0xff00;
@@ -677,19 +686,18 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
case H5T_COMPOUND:
/* Check for an array datatype somewhere within the compound type */
- if((has_array=H5T_detect_class(dt,H5T_ARRAY))<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't detect array class");
+ if((has_array = H5T_detect_class(dt, H5T_ARRAY)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't detect array class")
/*
* Compound datatypes...
*/
flags = dt->shared->u.compnd.nmembs & 0xffff;
- for (i=0; i<dt->shared->u.compnd.nmembs; i++) {
-
+ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
/* Name, multiple of eight bytes */
HDstrcpy((char*)(*pp), dt->shared->u.compnd.memb[i].name);
n = HDstrlen(dt->shared->u.compnd.memb[i].name);
- for (z=n+1; z%8; z++)
+ for(z = n + 1; z % 8; z++)
(*pp)[z] = '\0';
*pp += z;
@@ -700,7 +708,9 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
* member information, for better backward compatibility
* Write out all zeros for the array information, though...
*/
- if(!has_array) {
+ if(!has_array && !use_latest_format) {
+ unsigned j;
+
/* Dimensionality */
*(*pp)++ = 0;
@@ -716,14 +726,14 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
UINT32ENCODE(*pp, 0);
/* Dimensions */
- for (j=0; j<4; j++)
+ for(j = 0; j < 4; j++)
UINT32ENCODE(*pp, 0);
} /* end if */
/* Subtype */
- if (H5O_dtype_encode_helper(pp, dt->shared->u.compnd.memb[i].type)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type");
- }
+ if(H5O_dtype_encode_helper(f, pp, dt->shared->u.compnd.memb[i].type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type")
+ } /* end for */
break;
case H5T_ENUM:
@@ -733,17 +743,17 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags = dt->shared->u.enumer.nmembs & 0xffff;
/* Parent type */
- if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype");
+ if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent datatype")
/* Names, each a multiple of eight bytes */
- for (i=0; i<dt->shared->u.enumer.nmembs; i++) {
+ for(i=0; i<dt->shared->u.enumer.nmembs; i++) {
HDstrcpy((char*)(*pp), dt->shared->u.enumer.name[i]);
n = HDstrlen(dt->shared->u.enumer.name[i]);
- for (z=n+1; z%8; z++)
+ for(z = n + 1; z % 8; z++)
(*pp)[z] = '\0';
*pp += z;
- }
+ } /* end for */
/* Values */
HDmemcpy(*pp, dt->shared->u.enumer.value, dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size);
@@ -776,8 +786,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Encode base type of VL information */
- if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
+ if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
case H5T_TIME: /* Time datatypes... */
@@ -788,7 +798,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet")
}
UINT16ENCODE(*pp, dt->shared->u.atomic.prec);
break;
@@ -806,16 +816,16 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*(*pp)++ = '\0';
/* Encode array dimensions */
- for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++)
- UINT32ENCODE(*pp, dt->shared->u.array.dim[j]);
+ for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++)
+ UINT32ENCODE(*pp, dt->shared->u.array.dim[i]);
/* Encode array dimension permutations */
- for (j=0; j<(unsigned)dt->shared->u.array.ndims; j++)
- UINT32ENCODE(*pp, dt->shared->u.array.perm[j]);
+ for (i=0; i<(unsigned)dt->shared->u.array.ndims; i++)
+ UINT32ENCODE(*pp, dt->shared->u.array.perm[i]);
/* Encode base type of array's information */
- if (H5O_dtype_encode_helper(pp, dt->shared->parent)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
+ if(H5O_dtype_encode_helper(f, pp, dt->shared->parent) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type")
break;
default:
@@ -824,10 +834,15 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
}
/* Set version #, based on actual features used for datatype */
- if(has_vax)
- version = H5O_DTYPE_VERSION_3;
- else
- version = (dt->shared->type == H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_2 : H5O_DTYPE_VERSION_1;
+ /* (unless the "use the latest format" flag is set) */
+ if(use_latest_format)
+ version = H5O_DTYPE_VERSION_LATEST;
+ else {
+ if(has_vax)
+ version = H5O_DTYPE_VERSION_3;
+ else
+ version = (dt->shared->type == H5T_COMPOUND && has_array) ? H5O_DTYPE_VERSION_2 : H5O_DTYPE_VERSION_1;
+ } /* end else */
/* Encode the type's class, version and bit field */
*hdr++ = ((unsigned)(dt->shared->type) & 0x0f) | (version << 4);
@@ -836,8 +851,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*hdr++ = (flags >> 16) & 0xff;
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dtype_encode_helper() */
/*--------------------------------------------------------------------------
@@ -870,7 +885,7 @@ H5O_dtype_decode(H5F_t *f, hid_t UNUSED dxpl_id, const uint8_t *p)
assert(p);
if(NULL == (dt = H5T_alloc()))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
if (H5O_dtype_decode_helper(f, &p, dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type");
@@ -909,25 +924,25 @@ done:
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_dtype_encode(H5F_t UNUSED *f, uint8_t *p, const void *mesg)
+H5O_dtype_encode(H5F_t *f, uint8_t *p, const void *mesg)
{
- const H5T_t *dt = (const H5T_t *) mesg;
- herr_t ret_value=SUCCEED; /* Return value */
+ const H5T_t *dt = (const H5T_t *) mesg;
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_dtype_encode)
/* check args */
- assert(f);
- assert(p);
- assert(dt);
+ HDassert(f);
+ HDassert(p);
+ HDassert(dt);
/* encode */
- if (H5O_dtype_encode_helper(&p, dt) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type");
+ if(H5O_dtype_encode_helper(f, &p, dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type")
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dtype_encode() */
/*--------------------------------------------------------------------------
@@ -961,7 +976,7 @@ H5O_dtype_copy(const void *_src, void *_dst, unsigned UNUSED update_flags)
/* copy */
if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type")
/* was result already allocated? */
if (_dst) {
@@ -998,18 +1013,23 @@ done:
sized "properties" field.
--------------------------------------------------------------------------*/
static size_t
-H5O_dtype_size(const H5F_t *f, const void *mesg)
+H5O_dtype_size(const H5F_t *f, const void *_mesg)
{
- unsigned i;
- size_t ret_value = 8;
- const H5T_t *dt = (const H5T_t *) mesg;
+ const H5T_t *dt = (const H5T_t *)_mesg;
+ unsigned i; /* Local index variable */
+ size_t ret_value;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_size);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_size)
- assert(mesg);
+ HDassert(f);
+ HDassert(dt);
+
+ /* Set the common size information */
+ ret_value = 4 + /* Type, class & flags */
+ 4; /* Size of datatype */
/* Add in the property field length for each datatype class */
- switch (dt->shared->type) {
+ switch(dt->shared->type) {
case H5T_INTEGER:
ret_value += 4;
break;
@@ -1019,7 +1039,7 @@ H5O_dtype_size(const H5F_t *f, const void *mesg)
break;
case H5T_OPAQUE:
- ret_value += (HDstrlen(dt->shared->u.opaque.tag)+7) & (H5T_OPAQUE_TAG_MAX - 8);
+ ret_value += (HDstrlen(dt->shared->u.opaque.tag) + 7) & (H5T_OPAQUE_TAG_MAX - 8);
break;
case H5T_FLOAT:
@@ -1027,22 +1047,40 @@ H5O_dtype_size(const H5F_t *f, const void *mesg)
break;
case H5T_COMPOUND:
- for (i=0; i<dt->shared->u.compnd.nmembs; i++) {
- ret_value += ((HDstrlen(dt->shared->u.compnd.memb[i].name) + 8) / 8) * 8;
- ret_value += 4 + /*member offset*/
- 1 + /*dimensionality*/
- 3 + /*reserved*/
- 4 + /*permutation*/
- 4 + /*reserved*/
- 16; /*dimensions*/
- ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[i].type);
+ {
+ htri_t has_array; /* Whether a compound datatype has an array inside it */
+ hbool_t use_latest_format; /* Flag indicating the new group format should be used */
+
+ /* Check for an array datatype somewhere within the compound type */
+ has_array = H5T_detect_class(dt, H5T_ARRAY);
+ HDassert(has_array >= 0);
+
+ /* Get the file's 'use the latest version of the format' flag */
+ use_latest_format = H5F_USE_LATEST_FORMAT(f);
+
+ /* Compute the total size needed to encode compound datatype */
+ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ ret_value += ((HDstrlen(dt->shared->u.compnd.memb[i].name) + 8) / 8) * 8;
+
+ /* Check for encoding array datatype or using the latest file format */
+ if(has_array || use_latest_format)
+ ret_value += 4; /*member offset*/
+ else
+ ret_value += 4 + /*member offset*/
+ 1 + /*dimensionality*/
+ 3 + /*reserved*/
+ 4 + /*permutation*/
+ 4 + /*reserved*/
+ 16; /*dimensions*/
+ ret_value += H5O_dtype_size(f, dt->shared->u.compnd.memb[i].type);
+ } /* end for */
}
break;
case H5T_ENUM:
ret_value += H5O_dtype_size(f, dt->shared->parent);
- for (i=0; i<dt->shared->u.enumer.nmembs; i++)
- ret_value += ((HDstrlen(dt->shared->u.enumer.name[i])+8)/8)*8;
+ for(i = 0; i < dt->shared->u.enumer.nmembs; i++)
+ ret_value += ((HDstrlen(dt->shared->u.enumer.name[i]) + 8) / 8) * 8;
ret_value += dt->shared->u.enumer.nmembs * dt->shared->parent->shared->size;
break;
@@ -1056,18 +1094,18 @@ H5O_dtype_size(const H5F_t *f, const void *mesg)
case H5T_ARRAY:
ret_value += 4; /* ndims & reserved bytes*/
- ret_value += 4*dt->shared->u.array.ndims; /* dimensions */
- ret_value += 4*dt->shared->u.array.ndims; /* dimension permutations */
+ ret_value += 4 * dt->shared->u.array.ndims; /* dimensions */
+ ret_value += 4 * dt->shared->u.array.ndims; /* dimension permutations */
ret_value += H5O_dtype_size(f, dt->shared->parent);
break;
default:
/*no properties */
break;
- }
+ } /* end switch */
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5O_dtype_size() */
/*-------------------------------------------------------------------------
diff --git a/src/H5S.c b/src/H5S.c
index b11a2bd..6c52b9e 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -13,7 +13,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define H5S_PACKAGE /*suppress error about including H5Spkg */
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5S_init_interface
@@ -22,7 +21,7 @@
#define _H5S_IN_H5S_C
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
-#include "H5Fpkg.h" /* File access */
+#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
@@ -1701,15 +1700,12 @@ done:
* in a buffer.
*
* Return: Success: non-negative
- *
* Failure: negative
*
* Programmer: Raymond Lu
* slu@ncsa.uiuc.edu
* July 14, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1718,55 +1714,55 @@ H5S_encode(H5S_t *obj, unsigned char *buf, size_t *nalloc)
size_t extent_size; /* Size of serialized dataspace extent */
hssize_t sselect_size; /* Signed size of serialized dataspace selection */
size_t select_size; /* Size of serialized dataspace selection */
- H5F_t f; /* Fake file structure*/
+ H5F_t *f = NULL; /* Fake file structure*/
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5S_encode, FAIL);
+ FUNC_ENTER_NOAPI(H5S_encode, FAIL)
- /* Fake file structure, used only for header message operation */
- f.shared = (H5F_file_t*)H5MM_calloc(sizeof(H5F_file_t));
- HDassert(f.shared);
- f.shared->sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF;
+ /* Allocate "fake" file structure */
+ if(NULL == (f = H5F_fake_alloc(0)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate fake file struct")
/* Find out the size of buffer needed for extent */
- if((extent_size = H5O_raw_size(H5O_SDSPACE_ID, &f, obj)) == 0)
+ if((extent_size = H5O_raw_size(H5O_SDSPACE_ID, f, obj)) == 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, FAIL, "can't find dataspace size")
+ /* Find out the size of buffer needed for selection */
if((sselect_size = H5S_SELECT_SERIAL_SIZE(obj)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADSIZE, FAIL, "can't find dataspace selection size")
H5_ASSIGN_OVERFLOW(select_size, sselect_size, hssize_t, size_t);
/* Verify the size of buffer. If it's not big enough, simply return the
* right size without filling the buffer. */
- if(!buf || *nalloc<(extent_size + select_size + 1 + 1 + 1 + 4)) {
+ if(!buf || *nalloc < (extent_size + select_size + 1 + 1 + 1 + 4))
*nalloc = extent_size + select_size + 1 + 1 + 1 + 4;
- HGOTO_DONE(ret_value)
- } /* end if */
+ else {
+ /* Encode the type of the information */
+ *buf++ = H5O_SDSPACE_ID;
- /* Encode the type of the information */
- *buf++ = H5O_SDSPACE_ID;
+ /* Encode the version of the dataspace information */
+ *buf++ = H5S_ENCODE_VERSION;
- /* Encode the version of the dataspace information */
- *buf++ = H5S_ENCODE_VERSION;
+ /* Encode the "size of size" information */
+ *buf++ = (unsigned char)H5F_SIZEOF_SIZE(f);
- /* Encode the "size of size" information */
- *buf++ = (unsigned char)f.shared->sizeof_size;
+ /* Encode size of extent information. Pointer is actually moved in this macro. */
+ UINT32ENCODE(buf, extent_size);
- /* Encode size of extent information. Pointer is actually moved in this macro. */
- UINT32ENCODE(buf, extent_size);
+ /* Encode the extent part of dataspace */
+ if(H5O_encode(f, buf, obj, H5O_SDSPACE_ID) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode extent space")
+ buf += extent_size;
- /* Encode the extent part of dataspace */
- if(H5O_encode(&f, buf, obj, H5O_SDSPACE_ID) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode extent space")
- buf += extent_size;
-
- /* Encode the selection part of dataspace. */
- if(H5S_SELECT_SERIALIZE(obj, buf) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode select space")
+ /* Encode the selection part of dataspace. */
+ if(H5S_SELECT_SERIALIZE(obj, buf) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTENCODE, FAIL, "can't encode select space")
+ } /* end else */
done:
- if(f.shared)
- H5MM_free(f.shared);
+ /* Release fake file structure */
+ if(f && H5F_fake_free(f) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_encode() */
@@ -1833,15 +1829,13 @@ H5S_decode(const unsigned char *buf)
{
H5S_t *ds;
H5S_extent_t *extent;
- size_t extent_size; /* size of the extent message*/
- H5F_t f; /* fake file structure*/
+ size_t extent_size; /* size of the extent message*/
+ H5F_t *f = NULL; /* Fake file structure*/
+ size_t sizeof_size; /* 'Size of sizes' for file */
H5S_t *ret_value;
FUNC_ENTER_NOAPI(H5S_decode, NULL)
- /* Initialize this before anything goes bad... */
- f.shared = NULL;
-
/* Decode the type of the information */
if(*buf++ != H5O_SDSPACE_ID)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADMESG, NULL, "not an encoded dataspace");
@@ -1850,18 +1844,19 @@ H5S_decode(const unsigned char *buf)
if(*buf++ != H5S_ENCODE_VERSION)
HGOTO_ERROR(H5E_DATASPACE, H5E_VERSION, NULL, "unknown version of encoded dataspace");
- /* Fake file structure, used only for header message operation */
- f.shared = (H5F_file_t*)H5MM_calloc(sizeof(H5F_file_t));
-
/* Decode the "size of size" information */
- f.shared->sizeof_size = *buf++;
+ sizeof_size = *buf++;
+
+ /* Allocate "fake" file structure */
+ if(NULL == (f = H5F_fake_alloc(sizeof_size)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, NULL, "can't allocate fake file struct")
/* Decode size of extent information */
UINT32DECODE(buf, extent_size);
/* Decode the extent part of dataspace */
/* (pass mostly bogus file pointer and bogus DXPL) */
- if((extent = H5O_decode(&f, H5P_DEFAULT, buf, H5O_SDSPACE_ID))==NULL)
+ if((extent = H5O_decode(f, H5P_DEFAULT, buf, H5O_SDSPACE_ID))==NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, NULL, "can't decode object")
buf += extent_size;
@@ -1886,7 +1881,9 @@ H5S_decode(const unsigned char *buf)
ret_value = ds;
done:
- H5MM_xfree(f.shared);
+ /* Release fake file structure */
+ if(f && H5F_fake_free(f) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release fake file struct")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_decode() */
diff --git a/src/H5T.c b/src/H5T.c
index f5e786a..7acf1e9 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -20,7 +20,6 @@
*/
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
/* Interface initialization */
#define H5_INTERFACE_INIT_FUNC H5T_init_interface
@@ -29,7 +28,7 @@
#include "H5private.h" /*generic functions */
#include "H5Dprivate.h" /*datasets (for H5Tcopy) */
#include "H5Eprivate.h" /*error handling */
-#include "H5Fpkg.h" /* File */
+#include "H5Fprivate.h" /* Files */
#include "H5FLprivate.h" /* Free Lists */
#include "H5FOprivate.h" /* File objects */
#include "H5Gprivate.h" /*groups */
@@ -2764,23 +2763,24 @@ herr_t
H5Tencode(hid_t obj_id, void *buf, size_t *nalloc)
{
H5T_t *dtype;
- herr_t ret_value=SUCCEED;
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER_API (H5Tencode, FAIL);
+ FUNC_ENTER_API (H5Tencode, FAIL)
H5TRACE3("e","ix*z",obj_id,buf,nalloc);
/* Check argument and retrieve object */
- if (NULL==(dtype=H5I_object_verify(obj_id, H5I_DATATYPE)))
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if (nalloc==NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer size")
+ if(NULL == (dtype = H5I_object_verify(obj_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(nalloc == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL pointer for buffer size")
- if(H5T_encode(dtype, buf, nalloc)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype");
+ /* Go encode the datatype */
+ if(H5T_encode(dtype, buf, nalloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode datatype")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Tencode() */
/*-------------------------------------------------------------------------
@@ -2842,41 +2842,47 @@ done:
* slu@ncsa.uiuc.edu
* July 14, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc)
{
- size_t buf_size;
- H5F_t f;
+ size_t buf_size; /* Encoded size of datatype */
+ H5F_t *f = NULL; /* Fake file structure*/
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5T_encode, FAIL);
+ FUNC_ENTER_NOAPI(H5T_encode, FAIL)
+
+ /* Allocate "fake" file structure */
+ if(NULL == (f = H5F_fake_alloc(0)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate fake file struct")
/* Find out the size of buffer needed */
- if((buf_size=H5O_raw_size(H5O_DTYPE_ID, &f, obj))==0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "can't find datatype size");
+ if((buf_size = H5O_raw_size(H5O_DTYPE_ID, f, obj)) == 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "can't find datatype size")
/* Don't encode if buffer size isn't big enough or buffer is empty */
- if(!buf || *nalloc<(buf_size+1+1)) {
- *nalloc = buf_size+1+1;
- HGOTO_DONE(ret_value);
- }
-
- /* Encode the type of the information */
- *buf++ = H5O_DTYPE_ID;
+ if(!buf || *nalloc < (buf_size + 1 + 1))
+ *nalloc = buf_size + 1 + 1;
+ else {
+ /* Encode the type of the information */
+ *buf++ = H5O_DTYPE_ID;
- /* Encode the version of the dataspace information */
- *buf++ = H5T_ENCODE_VERSION;
+ /* Encode the version of the dataspace information */
+ *buf++ = H5T_ENCODE_VERSION;
- if(H5O_encode(&f, buf, obj, H5O_DTYPE_ID)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode object");
+ /* Encode into user's buffer */
+ if(H5O_encode(f, buf, obj, H5O_DTYPE_ID) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode object")
+ } /* end else */
done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ /* Release fake file structure */
+ if(f && H5F_fake_free(f) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to release fake file struct")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_encode() */
/*-------------------------------------------------------------------------
@@ -2898,10 +2904,15 @@ done:
static H5T_t *
H5T_decode(const unsigned char *buf)
{
+ H5F_t *f = NULL; /* Fake file structure*/
H5T_t *ret_value;
FUNC_ENTER_NOAPI(H5T_decode, NULL)
+ /* Allocate "fake" file structure */
+ if(NULL == (f = H5F_fake_alloc(0)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "can't allocate fake file struct")
+
/* Decode the type of the information */
if(*buf++ != H5O_DTYPE_ID)
HGOTO_ERROR(H5E_DATATYPE, H5E_BADMESG, NULL, "not an encoded datatype")
@@ -2911,11 +2922,14 @@ H5T_decode(const unsigned char *buf)
HGOTO_ERROR(H5E_DATATYPE, H5E_VERSION, NULL, "unknown version of encoded datatype")
/* Decode the serialized datatype message */
- /* (pass bogus file pointer and DXPL) */
- if((ret_value = H5O_decode(NULL, H5P_DEFAULT, buf, H5O_DTYPE_ID)) == NULL)
+ if((ret_value = H5O_decode(f, H5AC_dxpl_id, buf, H5O_DTYPE_ID)) == NULL)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode object")
done:
+ /* Release fake file structure */
+ if(f && H5F_fake_free(f) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release fake file struct")
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_decode() */
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 8210c82..c2488f8 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -106,7 +106,7 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
H5G_loc_reset(&insertion_loc);
if(H5G_insertion_loc(&loc, name, &insertion_loc, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to locate insertion point")
- insert_loc_valid=TRUE;
+ insert_loc_valid = TRUE;
file = insertion_loc.oloc->file;
/* Record the type's state so that we can revert to it if linking fails */
@@ -116,25 +116,24 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
if(H5T_commit(file, type, H5AC_dxpl_id, H5P_DATATYPE_CREATE_DEFAULT, H5P_DEFAULT) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ /* Get the group location for the newly committed datatype */
if(H5G_loc(type_id, &type_loc) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get committed datatype's location")
/* Link the type into the group hierarchy */
- if( H5L_link(&loc, name, &type_loc, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0)
- {
+ if(H5L_link(&loc, name, &type_loc, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) {
uncommit = TRUE; /* Linking failed, and we need to undo H5T_commit. */
- HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link to type")
- }
+ HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link to type")
+ } /* end if */
done:
- if(insert_loc_valid) {
+ if(insert_loc_valid)
if(H5G_loc_free(&insertion_loc) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to free location")
- }
+
/* If the datatype was committed but couldn't be linked, we need to return it to the state it was in
* before it was committed. */
- if(TRUE == uncommit)
- {
+ if(TRUE == uncommit) {
if(type->shared->state == H5T_STATE_OPEN && H5F_addr_defined(type->oloc.addr)) {
/* Remove the datatype from the list of opened objects in the file */
if(H5FO_top_decr(type->oloc.file, type->oloc.addr) < 0)
@@ -150,7 +149,9 @@ done:
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to return datatype to memory")
type->oloc.addr = HADDR_UNDEF;
type->shared->state = old_state;
- } /* end if */ }
+ } /* end if */
+ } /* end if */
+
FUNC_LEAVE_API(ret_value)
} /* end H5Tcommit() */
@@ -224,13 +225,12 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id,
- hid_t tcpl_id, hid_t UNUSED tapl_id)
+H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id, hid_t tcpl_id, hid_t UNUSED tapl_id)
{
-/* H5F_t *file = NULL; */
H5P_genplist_t *tc_plist; /* Property list created */
H5G_loc_t type_loc; /* Dataset location */
- herr_t ret_value = SUCCEED; /* Return value */
+ size_t dtype_size; /* Size of the datatype message */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5T_commit)
@@ -265,11 +265,15 @@ H5T_commit(H5F_t *file, H5T_t *type, hid_t dxpl_id,
type_loc.path = &(type->path);
H5G_loc_reset(&type_loc);
+ /* Calculate message size infomation, for creating object header */
+ dtype_size = H5O_mesg_size(H5O_DTYPE_ID, file, type, (size_t)0);
+ HDassert(dtype_size);
+
/*
* Create the object header and open it for write access. Insert the data
* type message and then give the object header a name.
*/
- if(H5O_create(file, dxpl_id, (size_t)64, &(type->oloc)) < 0)
+ if(H5O_create(file, dxpl_id, dtype_size, &(type->oloc)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create datatype object header")
if(H5O_modify(&(type->oloc), H5O_DTYPE_ID, 0, H5O_FLAG_CONSTANT, H5O_UPDATE_TIME, type, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message")
diff --git a/src/Makefile.am b/src/Makefile.am
index e8c28da..3076db5 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,7 +46,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \
H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \
H5E.c H5F.c \
- H5Fdbg.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \
+ H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \
H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \
H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \
H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 99a16a2..ffe8d83 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -87,7 +87,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \
H5B2.lo H5B2cache.lo H5B2dbg.lo H5B2int.lo H5B2stat.lo \
H5B2test.lo H5C.lo H5CS.lo H5D.lo H5Dcompact.lo H5Dcontig.lo \
H5Defl.lo H5Dio.lo H5Distore.lo H5Dmpio.lo H5Doh.lo \
- H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo H5Fmount.lo \
+ H5Dselect.lo H5Dtest.lo H5E.lo H5F.lo H5Fdbg.lo H5Ffake.lo H5Fmount.lo \
H5Fsfile.lo H5Fsuper.lo H5FD.lo H5FDcore.lo H5FDfamily.lo \
H5FDlog.lo H5FDmpi.lo H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo \
H5FDsec2.lo H5FDstdio.lo H5FDstream.lo H5FL.lo H5FO.lo H5FS.lo \
@@ -396,7 +396,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5C.c H5CS.c H5D.c H5Dcompact.c H5Dcontig.c \
H5Defl.c H5Dio.c H5Distore.c H5Dmpio.c H5Doh.c H5Dselect.c H5Dtest.c \
H5E.c H5F.c \
- H5Fdbg.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \
+ H5Fdbg.c H5Ffake.c H5Fmount.c H5Fsfile.c H5Fsuper.c H5FD.c H5FDcore.c \
H5FDfamily.c H5FDlog.c H5FDmpi.c H5FDmpio.c \
H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDstdio.c \
H5FDstream.c H5FL.c H5FO.c H5FS.c H5FScache.c H5FSdbg.c H5FSsection.c \
@@ -596,6 +596,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FSdbg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5FSsection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fdbg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ffake.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fmount.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsfile.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Fsuper.Plo@am__quote@
diff --git a/test/dtypes.c b/test/dtypes.c
index 1e082c6..f0d6a35 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -4329,6 +4329,138 @@ test_encode(void)
return 1;
}
+
+/*-------------------------------------------------------------------------
+ * Function: test_latest
+ *
+ * Purpose: Test encoding datatypes with the "use the latest version of
+ * the file format" flag turned on.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * October 2, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_latest(void)
+{
+ struct s1 {
+ int a;
+ float b;
+ long c;
+ double d;
+ };
+ hid_t file = (-1); /* File ID */
+ hid_t tid = (-1); /* Datatype ID */
+ hid_t fapl = (-1); /* File access property list */
+ H5G_stat_t sb; /* Stat buffer for committed datatype */
+ hsize_t old_dtype_oh_size; /* Size of object header with "old" format */
+ hsize_t new_dtype_oh_size; /* Size of object header with "new" format */
+ char filename[1024]; /* Buffer for filename */
+ const char compnd_type[] = "Compound_type"; /* Name of committed datatype */
+
+ TESTING("encoding datatypes with the 'use the latest format' flag");
+
+ /* Create file using default FAPL */
+ h5_fixname(FILENAME[5], H5P_DEFAULT, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a compound datatype */
+ if((tid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0)
+ FAIL_STACK_ERROR
+
+ /* Commit compound datatype */
+ if(H5Tcommit(file, compnd_type, tid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get information about datatype on disk */
+ if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0)
+ FAIL_STACK_ERROR
+ old_dtype_oh_size = sb.ohdr.size;
+
+ /* Close datatype */
+ if(H5Tclose(tid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+
+ /* Set the 'use the latest format' flag in the FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_latest_format(fapl, TRUE) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create file using default FAPL */
+ h5_fixname(FILENAME[5], fapl, filename, sizeof filename);
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Create a compound datatype */
+ if((tid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1))) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "a", HOFFSET(struct s1, a), H5T_NATIVE_INT) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "b", HOFFSET(struct s1, b), H5T_NATIVE_FLOAT) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "c", HOFFSET(struct s1, c), H5T_NATIVE_LONG) < 0)
+ FAIL_STACK_ERROR
+ if(H5Tinsert(tid, "d", HOFFSET(struct s1, d), H5T_NATIVE_DOUBLE) < 0)
+ FAIL_STACK_ERROR
+
+ /* Commit compound datatype */
+ if(H5Tcommit(file, compnd_type, tid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get information about datatype on disk */
+ if(H5Gget_objinfo(file, compnd_type, TRUE, &sb) < 0)
+ FAIL_STACK_ERROR
+ new_dtype_oh_size = sb.ohdr.size;
+
+ /* Check that the new format is smaller than the old format */
+ if(old_dtype_oh_size <= new_dtype_oh_size)
+ TEST_ERROR
+
+ /* Close datatype */
+ if(H5Tclose(tid) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close file */
+ if(H5Fclose(file) < 0)
+ FAIL_STACK_ERROR
+
+ /* Close FAPL */
+ if(H5Pclose(fapl) < 0)
+ FAIL_STACK_ERROR
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ return 1;
+} /* end test_latest() */
+
typedef struct {
unsigned num_range_hi; /* Number of H5T_CONV_EXCEPT_RANGE_HI exceptions seen */
unsigned num_range_low; /* Number of H5T_CONV_EXCEPT_RANGE_LOW exceptions seen */
@@ -4529,7 +4661,7 @@ main(void)
reset_hdf5();
fapl = h5_fileaccess();
- if (ALIGNMENT)
+ if(ALIGNMENT)
printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT);
/* Do the tests */
@@ -4538,9 +4670,10 @@ main(void)
nerrors += test_detect();
nerrors += test_compound_1();
nerrors += test_query();
- nerrors += test_transient (fapl);
- nerrors += test_named (fapl);
+ nerrors += test_transient(fapl);
+ nerrors += test_named(fapl);
nerrors += test_encode();
+ nerrors += test_latest();
nerrors += test_int_float_except();
h5_cleanup(FILENAME, fapl); /*must happen before first reset*/
reset_hdf5();