summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt1
-rw-r--r--tools/lib/Makefile.in3
-rw-r--r--tools/lib/h5diff.c5
-rw-r--r--tools/lib/h5diff.h15
-rw-r--r--tools/lib/h5diff_array.c482
-rw-r--r--tools/lib/h5diff_attr.c220
-rw-r--r--tools/lib/h5diff_dset.c256
-rw-r--r--tools/lib/h5diff_util.c5
-rw-r--r--tools/lib/h5tools.c15
-rw-r--r--tools/lib/h5tools_str.c2
10 files changed, 504 insertions, 500 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index 879e30e..c3662f6 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -31,7 +31,6 @@ SET (H5_TOOLS_LIB_HDRS
${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.h
)
-#-- Always build a static library for linking the ${HDF5_LIB_NAME} tools together
ADD_LIBRARY (${HDF5_TOOLS_LIB_TARGET} ${LIB_TYPE} ${H5_TOOLS_LIB_SRCS} ${H5_TOOLS_LIB_HDRS})
TARGET_LINK_LIBRARIES (${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
SET_GLOBAL_VARIABLE( HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIB_TARGET}")
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
index 5e8ac33..81f362f 100644
--- a/tools/lib/Makefile.in
+++ b/tools/lib/Makefile.in
@@ -139,6 +139,7 @@ DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
DIRECT_VFD = @DIRECT_VFD@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
DYNAMIC_DIRS = @DYNAMIC_DIRS@
@@ -200,6 +201,7 @@ LTLIBOBJS = @LTLIBOBJS@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MPE = @MPE@
MPI_GET_SIZE = @MPI_GET_SIZE@
@@ -256,6 +258,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 640a20a..5f406cf 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -14,11 +14,12 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdlib.h>
+
#include "H5private.h"
-#include "h5diff.h"
-#include "ph5diff.h"
#include "h5tools.h"
#include "h5tools_utils.h"
+#include "h5diff.h"
+#include "ph5diff.h"
/*
* Debug printf macros. The prefix allows output filtering by test scripts.
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index c89b9d3..7e4e016 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -172,6 +172,18 @@ int print_objname(diff_opt_t *options, hsize_t nfound);
void do_print_objname (const char *OBJ, const char *path1, const char *path2);
+/*-------------------------------------------------------------------------
+ * XCAO, 11/10/2010
+ * added to improve performance for compound datasets
+ */
+typedef struct mcomp_t
+{
+ int n; /* number of members */
+ hid_t *ids; /* member type id */
+ unsigned char *flags;
+ size_t *offsets;
+ struct mcomp_t **m; /* members */
+}mcomp_t;
hsize_t diff_datum(void *_mem1,
void *_mem2,
@@ -186,7 +198,8 @@ hsize_t diff_datum(void *_mem1,
const char *obj2,
hid_t container1_id,
hid_t container2_id, /*where the reference came from*/
- int *ph); /*print header */
+ int *ph, /*print header */
+ mcomp_t *members); /*compound members */
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 6005ed8..9a609b5 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -14,14 +14,14 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <math.h>
-#include "h5diff.h"
-#include "ph5diff.h"
+#include <time.h>
+#include <sys/timeb.h>
+
#include "H5private.h"
#include "h5tools.h"
-
-
-#include <sys/timeb.h>
-#include <time.h>
+#include "h5tools_utils.h"
+#include "h5diff.h"
+#include "ph5diff.h"
/*-------------------------------------------------------------------------
@@ -182,6 +182,13 @@ typedef enum dtype_t
static int my_isnan(dtype_t type, void *val);
+/*-------------------------------------------------------------------------
+ * XCAO, 11/10/2010
+ * added to improve performance for compound datasets
+ */
+static void set_comp_members(hid_t tid, mcomp_t *members);
+static void free_comp_members(mcomp_t *members);
+
/*-------------------------------------------------------------------------
@@ -220,10 +227,23 @@ hsize_t diff_array( void *_mem1,
int ph=1; /* print header */
hsize_t i;
int j;
-
+ mcomp_t members;
+ H5T_class_t type_class;
/* get the size. */
size = H5Tget_size( m_type );
+ type_class = H5Tget_class(m_type);
+
+ /* Fast comparison first for atomic type by memcmp().
+ * It is OK not to list non-atomic type here because it will not be caught
+ * by the confition, but it gives more clarity for code planning
+ */
+ if (type_class != H5T_REFERENCE &&
+ type_class != H5T_COMPOUND &&
+ type_class != H5T_STRING &&
+ type_class != H5T_VLEN &&
+ HDmemcmp(mem1, mem2, size*nelmts)==0)
+ return 0;
if ( rank > 0 )
{
@@ -237,13 +257,74 @@ hsize_t diff_array( void *_mem1,
pos[j]=0;
}
- if(H5Tis_variable_str(m_type))
+ switch (type_class)
{
+ default:
+ assert(0);
+ break;
+
+ /*-------------------------------------------------------------------------
+ * float and integer atomic types
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_FLOAT:
+
+ if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
+ nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
+ nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+#if H5_SIZEOF_LONG_DOUBLE !=0
+ else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE))
+ nfound=diff_ldouble(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+#endif
+ break;
+
+ case H5T_INTEGER:
+
+ if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
+ nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
+ nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
+ nfound=diff_short(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
+ nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_INT))
+ nfound=diff_int(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_UINT))
+ nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_LONG))
+ nfound=diff_long(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
+ nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
+ nfound=diff_llong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+ else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
+ nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * Other types than float and integer
+ *-------------------------------------------------------------------------
+ */
+
+ case H5T_COMPOUND:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ case H5T_ENUM:
+ case H5T_ARRAY:
+ case H5T_VLEN:
+ case H5T_REFERENCE:
+ HDmemset(&members, 0, sizeof (mcomp_t));
+ set_comp_members(m_type, &members);
for ( i = 0; i < nelmts; i++)
{
nfound+=diff_datum(
- ((unsigned char**)mem1)[(size_t)i],
- ((unsigned char**)mem2)[(size_t)i],
+ mem1 + i * size,
+ mem2 + i * size, /* offset */
m_type,
i,
rank,
@@ -255,98 +336,15 @@ hsize_t diff_array( void *_mem1,
name2,
container1_id,
container2_id,
- &ph);
+ &ph, &members);
if (options->n && nfound>=options->count)
+ {
+ free_comp_members(&members);
return nfound;
+ }
} /* i */
- }
-
- else
- {
- switch (H5Tget_class(m_type))
- {
- default:
- assert(0);
- break;
-
- /*-------------------------------------------------------------------------
- * float and integer atomic types
- *-------------------------------------------------------------------------
- */
-
- case H5T_FLOAT:
-
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
- nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
- nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-#if H5_SIZEOF_LONG_DOUBLE !=0
- else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE))
- nfound=diff_ldouble(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-#endif
- break;
-
- case H5T_INTEGER:
-
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
- nfound=diff_schar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
- nfound=diff_uchar(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
- nfound=diff_short(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
- nfound=diff_ushort(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
- nfound=diff_int(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
- nfound=diff_uint(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
- nfound=diff_long(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
- nfound=diff_ulong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
- nfound=diff_llong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
- nfound=diff_ullong(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph);
-
- break;
-
- /*-------------------------------------------------------------------------
- * Other types than float and integer
- *-------------------------------------------------------------------------
- */
-
- case H5T_COMPOUND:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- case H5T_ENUM:
- case H5T_ARRAY:
- case H5T_VLEN:
- case H5T_REFERENCE:
-
- for ( i = 0; i < nelmts; i++)
- {
- nfound+=diff_datum(
- mem1 + i * size,
- mem2 + i * size, /* offset */
- m_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- name1,
- name2,
- container1_id,
- container2_id,
- &ph);
- if (options->n && nfound>=options->count)
- return nfound;
- } /* i */
- } /* switch */
- } /* else */
+ free_comp_members(&members);
+ } /* switch */
return nfound;
}
@@ -388,7 +386,6 @@ hsize_t diff_array( void *_mem1,
* Dereference the object and compare the type (basic object type).
*-------------------------------------------------------------------------
*/
-
hsize_t diff_datum(void *_mem1,
void *_mem2,
hid_t m_type,
@@ -402,13 +399,16 @@ hsize_t diff_datum(void *_mem1,
const char *obj2,
hid_t container1_id,
hid_t container2_id, /*where the reference came from*/
- int *ph) /*print header */
+ int *ph, /*print header */
+ mcomp_t *members) /*compound members */
{
unsigned char *mem1 = (unsigned char*)_mem1;
unsigned char *mem2 = (unsigned char*)_mem2;
unsigned u;
hid_t memb_type;
size_t type_size;
+ H5T_sign_t type_sign;
+ H5T_class_t type_class;
size_t offset;
int nmembs;
int j;
@@ -425,6 +425,18 @@ hsize_t diff_datum(void *_mem1,
int both_zero;
type_size = H5Tget_size( m_type );
+ type_class = H5Tget_class(m_type);
+
+ /* Fast comparison first for atomic type by memcmp().
+ * It is OK not to list non-atomic type here because it will not be caught
+ * by the confition, but it gives more clarity for code planning
+ */
+ if (type_class != H5T_REFERENCE &&
+ type_class != H5T_COMPOUND &&
+ type_class != H5T_STRING &&
+ type_class != H5T_VLEN &&
+ HDmemcmp(mem1, mem2, type_size)==0)
+ return 0;
switch (H5Tget_class(m_type))
{
@@ -441,50 +453,29 @@ hsize_t diff_datum(void *_mem1,
*/
case H5T_COMPOUND:
- nmembs = H5Tget_nmembers(m_type);
+ nmembs = members->n;
+
for (j = 0; j < nmembs; j++)
{
- offset = H5Tget_member_offset(m_type, (unsigned)j);
- memb_type = H5Tget_member_type(m_type, (unsigned)j);
- /* if member type is vlen string */
- if(H5Tis_variable_str(memb_type))
- {
- nfound+=diff_datum(
- ((unsigned char**)mem1)[j],
- ((unsigned char**)mem2)[j],
- memb_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- }
- else
- {
- nfound+=diff_datum(
- mem1+offset,
- mem2+offset,
- memb_type,
- i,
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- }
- H5Tclose(memb_type);
+ offset = members->offsets[j];
+ memb_type = members->ids[j];
+
+ nfound+=diff_datum(
+ mem1+offset,
+ mem2+offset,
+ memb_type,
+ i,
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph, members->m[j]);
}
break;
@@ -497,24 +488,61 @@ hsize_t diff_datum(void *_mem1,
{
H5T_str_t pad;
char *s;
+ char *s1;
+ char *s2;
+ size_t size1;
+ size_t size2;
- /* Get pointer to first string to compare */
- s = (char *)mem1;
+ /* if variable length string */
+ if(H5Tis_variable_str(m_type))
+ {
+ /* Get pointer to first string */
+ s1 = *(char**) mem1;
+ size1 = HDstrlen(s1);
+ /* Get pointer to second string */
+ s2 = *(char**) mem2;
+ size2 = HDstrlen(s2);
+ }
+ else
+ {
+ /* Get pointer to first string */
+ s1 = mem1;
+ size1 = H5Tget_size(m_type);
+ /* Get pointer to second string */
+ s2 = mem2;
+ size2 = H5Tget_size(m_type);
+ }
+
+ /*
+ * compare for shorter string
+ * TODO: this code need to be improved to handle the difference
+ * of length of strings.
+ * For now mimic the previous way.
+ */
+ if(size1 < size2)
+ {
+ size = size1;
+ s = s1;
+ }
+ else
+ {
+ size = size2;
+ s = s2;
+ }
/* check for NULL pointer for string */
if(s!=NULL)
{
- if(H5Tis_variable_str(m_type))
- size = HDstrlen(s);
- else
- size = H5Tget_size(m_type);
+ /* try fast compare first */
+ if (HDmemcmp(s1, s2, size)==0)
+ break;
pad = H5Tget_strpad(m_type);
for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
nfound+=character_compare(
- mem1 + u,
- mem2 + u, /* offset */
+ s1 + u,
+ s2 + u, /* offset */
i, /* index position */
u, /* string character position */
rank,
@@ -654,43 +682,21 @@ hsize_t diff_datum(void *_mem1,
nelmts *= adims[u];
for (u = 0; u < nelmts; u++)
{
- /* if member type is vlen string */
- if(H5Tis_variable_str(memb_type))
- {
- nfound+=diff_datum(
- ((unsigned char**)mem1)[u],
- ((unsigned char**)mem2)[u],
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- }
- else
- {
- nfound+=diff_datum(
- mem1 + u * size,
- mem2 + u * size, /* offset */
- memb_type,
- i, /* index position */
- rank,
- dims,
- acc,
- pos,
- options,
- obj1,
- obj2,
- container1_id,
- container2_id,
- ph);
- }
+ nfound+=diff_datum(
+ mem1 + u * size,
+ mem2 + u * size, /* offset */
+ memb_type,
+ i, /* index position */
+ rank,
+ dims,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ container1_id,
+ container2_id,
+ ph, NULL);
}
H5Tclose(memb_type);
}
@@ -719,8 +725,7 @@ hsize_t diff_datum(void *_mem1,
* Dataset region reference
*-------------------------------------------------------------------------
*/
-
- if (H5Tequal(m_type, H5T_STD_REF_DSETREG))
+ if (type_size==H5R_DSET_REG_REF_BUF_SIZE)
{
hid_t region1_id;
hid_t region2_id;
@@ -754,7 +759,7 @@ hsize_t diff_datum(void *_mem1,
* Object references. get the type and OID of the referenced object
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_STD_REF_OBJ))
+ else if (type_size == H5R_OBJ_REF_BUF_SIZE)
{
H5O_type_t obj1_type;
H5O_type_t obj2_type;
@@ -838,7 +843,7 @@ hsize_t diff_datum(void *_mem1,
obj2,
container1_id,
container2_id,
- ph);
+ ph, NULL);
H5Tclose(memb_type);
@@ -852,13 +857,13 @@ hsize_t diff_datum(void *_mem1,
*/
case H5T_INTEGER:
-
+ type_sign = H5Tget_sign(m_type);
/*-------------------------------------------------------------------------
* H5T_NATIVE_SCHAR
*-------------------------------------------------------------------------
*/
- if (H5Tequal(m_type, H5T_NATIVE_SCHAR))
+ if (type_size==1 && type_sign!=H5T_SGN_NONE)
{
char temp1_char;
char temp2_char;
@@ -954,7 +959,7 @@ hsize_t diff_datum(void *_mem1,
* H5T_NATIVE_UCHAR
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_UCHAR))
+ else if (type_size==1 && type_sign==H5T_SGN_NONE)
{
unsigned char temp1_uchar;
unsigned char temp2_uchar;
@@ -1053,7 +1058,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_SHORT))
+ else if (type_size==2 && type_sign!=H5T_SGN_NONE)
{
short temp1_short;
short temp2_short;
@@ -1152,7 +1157,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_USHORT))
+ else if (type_size==2 && type_sign==H5T_SGN_NONE)
{
unsigned short temp1_ushort;
unsigned short temp2_ushort;
@@ -1252,7 +1257,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_INT))
+ else if (type_size==4 && type_sign!=H5T_SGN_NONE)
{
int temp1_int;
int temp2_int;
@@ -1350,7 +1355,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_UINT))
+ else if (type_size==4 && type_sign==H5T_SGN_NONE)
{
unsigned int temp1_uint;
unsigned int temp2_uint;
@@ -1448,7 +1453,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_LONG))
+ else if (type_size==8 && type_sign!=H5T_SGN_NONE)
{
long temp1_long;
long temp2_long;
@@ -1548,7 +1553,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_ULONG))
+ else if (type_size==8 && type_sign==H5T_SGN_NONE)
{
unsigned long temp1_ulong;
unsigned long temp2_ulong;
@@ -1647,7 +1652,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_LLONG))
+ else if (type_size==8 && type_sign!=H5T_SGN_NONE)
{
long long temp1_llong;
long long temp2_llong;
@@ -1745,7 +1750,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_ULLONG))
+ else if (type_size==8 && type_sign==H5T_SGN_NONE)
{
unsigned long long temp1_ullong;
unsigned long long temp2_ullong;
@@ -1862,7 +1867,7 @@ hsize_t diff_datum(void *_mem1,
* H5T_NATIVE_FLOAT
*-------------------------------------------------------------------------
*/
- if (H5Tequal(m_type, H5T_NATIVE_FLOAT))
+ if (type_size==4)
{
float temp1_float;
float temp2_float;
@@ -2075,7 +2080,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE))
+ else if (type_size==8)
{
double temp1_double;
double temp2_double;
@@ -2291,7 +2296,7 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
- else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE))
+ else if (type_size==8)
{
long double temp1_double;
long double temp2_double;
@@ -6046,3 +6051,70 @@ static void h5diff_print_char(char ch)
break;
}
}
+
+
+/*-------------------------------------------------------------------------
+ * XCAO, 11/10/2010
+ * added to improve performance for compound datasets
+ * set up compound datatype structures.
+ */
+static void set_comp_members(hid_t tid, mcomp_t *members)
+{
+ int i;
+
+ if (tid <=0 || !members)
+ return;
+
+ if (H5Tget_class(tid) != H5T_COMPOUND)
+ return;
+
+ members->n = H5Tget_nmembers( tid );
+ if (members->n <=0)
+ return;
+
+ members->ids = HDcalloc(members->n, sizeof(hid_t));
+ members->flags = HDcalloc(members->n, sizeof(unsigned char));
+ members->offsets = HDcalloc(members->n, sizeof(size_t));
+ members->m = HDcalloc(members->n, sizeof(mcomp_t *));
+
+ for (i=0; i< members->n; i++)
+ {
+ members->ids[i] = H5Tget_member_type( tid, i );
+ members->flags[i] = H5Tis_variable_str( members->ids[i] );
+ members->offsets[i] = H5Tget_member_offset( tid, i );
+ if (H5Tget_class( members->ids[i])==H5T_COMPOUND)
+ {
+ members->m[i] = (mcomp_t *)HDmalloc(sizeof(mcomp_t));
+ set_comp_members(members->ids[i], members->m[i]);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * XCAO, 11/10/2010
+ * added to improve performance for compound datasets
+ * clean and close compound members.
+ */
+static void free_comp_members(mcomp_t *members)
+{
+ int i;
+
+ if (!members || members->n<=0 || !members->ids)
+ return;
+
+ for (i=0; i<members->n; i++)
+ {
+ if (members->m[i])
+ {
+ free_comp_members(members->m[i]);
+ HDfree(members->m[i]);
+ }
+ H5Tclose(members->ids[i]);
+ }
+
+ HDfree (members->m);
+ HDfree (members->ids);
+ HDfree (members->flags);
+ HDfree (members->offsets);
+}
+
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 2cf6539..7e5fb04 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -13,9 +13,11 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+#include "H5private.h"
#include "h5tools.h"
+#include "h5tools_utils.h"
#include "h5diff.h"
-#include "H5private.h"
+
/*-------------------------------------------------------------------------
* Function: diff_attr
@@ -79,8 +81,7 @@ hsize_t diff_attr(hid_t loc1_id,
if(oinfo1.num_attrs != oinfo2.num_attrs)
return 1;
- for( u = 0; u < (unsigned)oinfo1.num_attrs; u++)
- {
+ for(u = 0; u < (unsigned)oinfo1.num_attrs; u++) {
/* reset buffers for every attribute, we might goto out and call free */
buf1 = NULL;
buf2 = NULL;
@@ -104,29 +105,29 @@ hsize_t diff_attr(hid_t loc1_id,
goto error;
/* get the datatypes */
- if ((ftype1_id = H5Aget_type(attr1_id)) < 0)
+ if((ftype1_id = H5Aget_type(attr1_id)) < 0)
goto error;
- if ((ftype2_id = H5Aget_type(attr2_id)) < 0)
+ if((ftype2_id = H5Aget_type(attr2_id)) < 0)
goto error;
- if ((mtype1_id = h5tools_get_native_type(ftype1_id))<0)
+ if((mtype1_id = h5tools_get_native_type(ftype1_id))<0)
goto error;
- if ((mtype2_id = h5tools_get_native_type(ftype2_id))<0)
+ if((mtype2_id = h5tools_get_native_type(ftype2_id))<0)
goto error;
- if ((msize1 = H5Tget_size(mtype1_id))==0)
+ if((msize1 = H5Tget_size(mtype1_id))==0)
goto error;
- if ((msize2 = H5Tget_size(mtype2_id))==0)
+ if((msize2 = H5Tget_size(mtype2_id))==0)
goto error;
/* get the dataspace */
- if ((space1_id = H5Aget_space(attr1_id)) < 0)
+ if((space1_id = H5Aget_space(attr1_id)) < 0)
goto error;
- if ((space2_id = H5Aget_space(attr2_id)) < 0)
+ if((space2_id = H5Aget_space(attr2_id)) < 0)
goto error;
/* get dimensions */
- if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 )
+ if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0)
goto error;
- if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 )
+ if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0)
goto error;
@@ -135,43 +136,28 @@ hsize_t diff_attr(hid_t loc1_id,
*----------------------------------------------------------------------
*/
- if ( msize1 != msize2
- ||
- diff_can_type(ftype1_id,
- ftype2_id,
- rank1,
- rank2,
- dims1,
- dims2,
- NULL,
- NULL,
- name1,
- name2,
- options,
- 0)!=1)
+ if(msize1 != msize2 ||
+ diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1,
+ dims2, NULL, NULL, name1, name2, options, 0) != 1)
{
-
-
- if (H5Tclose(ftype1_id)<0)
+ if(H5Tclose(ftype1_id) < 0)
goto error;
- if (H5Tclose(ftype2_id)<0)
+ if(H5Tclose(ftype2_id) < 0)
goto error;
- if (H5Sclose(space1_id)<0)
+ if(H5Sclose(space1_id) < 0)
goto error;
- if (H5Sclose(space2_id)<0)
+ if(H5Sclose(space2_id) < 0)
goto error;
- if (H5Aclose(attr1_id)<0)
+ if(H5Aclose(attr1_id) < 0)
goto error;
- if (H5Aclose(attr2_id)<0)
+ if(H5Aclose(attr2_id) < 0)
goto error;
- if (H5Tclose(mtype1_id)<0)
+ if(H5Tclose(mtype1_id) < 0)
goto error;
- if (H5Tclose(mtype2_id)<0)
+ if(H5Tclose(mtype2_id) < 0)
goto error;
continue;
-
-
}
@@ -179,19 +165,19 @@ hsize_t diff_attr(hid_t loc1_id,
* read
*----------------------------------------------------------------------
*/
- nelmts1=1;
- for (j=0; j<rank1; j++)
- nelmts1*=dims1[j];
+ nelmts1 = 1;
+ for(j = 0; j < rank1; j++)
+ nelmts1 *= dims1[j];
- buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1));
- buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2));
- if ( buf1==NULL || buf2==NULL){
+ buf1 = (void *)HDmalloc((unsigned)(nelmts1 * msize1));
+ buf2 = (void *)HDmalloc((unsigned)(nelmts1 * msize2));
+ if(buf1 == NULL || buf2 == NULL) {
parallel_print( "cannot read into memory\n" );
goto error;
}
- if (H5Aread(attr1_id,mtype1_id,buf1)<0)
+ if(H5Aread(attr1_id,mtype1_id,buf1) < 0)
goto error;
- if (H5Aread(attr2_id,mtype2_id,buf2)<0)
+ if(H5Aread(attr2_id,mtype2_id,buf2) < 0)
goto error;
/* format output string */
@@ -205,63 +191,29 @@ hsize_t diff_attr(hid_t loc1_id,
/* always print name */
/* verbose (-v) and report (-r) mode */
- if(options->m_verbose || options->m_report)
- {
- do_print_objname ("attribute", np1, np2);
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- (hsize_t)0,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
- print_found(nfound);
+ if(options->m_verbose || options->m_report) {
+ do_print_objname("attribute", np1, np2);
+ nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
+ options, np1, np2, mtype1_id, attr1_id, attr2_id);
+ print_found(nfound);
}
/* quiet mode (-q), just count differences */
- else if(options->m_quiet)
- {
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- (hsize_t)0,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
+ else if(options->m_quiet) {
+ nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
+ options, np1, np2, mtype1_id, attr1_id, attr2_id);
}
/* the rest (-c, none, ...) */
- else
- {
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- (hsize_t)0,
- rank1,
- dims1,
- options,
- np1,
- np2,
- mtype1_id,
- attr1_id,
- attr2_id);
+ else {
+ nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
+ options, np1, np2, mtype1_id, attr1_id, attr2_id);
/* not comparable, no display the different number */
- if (!options->not_cmp && nfound)
- {
- do_print_objname ("attribute", np1, np2);
+ if(!options->not_cmp && nfound) {
+ do_print_objname("attribute", np1, np2);
print_found(nfound);
- }
- }
+ } /* end if */
+ } /* end else */
/*----------------------------------------------------------------------
@@ -269,51 +221,61 @@ hsize_t diff_attr(hid_t loc1_id,
*----------------------------------------------------------------------
*/
- if (H5Tclose(ftype1_id)<0)
+ /* Free buf1 and buf2, being careful to reclaim any VL data first */
+ if(TRUE == H5Tdetect_class(mtype1_id, H5T_VLEN))
+ H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
+ HDfree(buf1);
+ buf1 = NULL;
+ if(TRUE == H5Tdetect_class(mtype2_id, H5T_VLEN))
+ H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
+ HDfree(buf2);
+ buf2 = NULL;
+
+ if(H5Tclose(ftype1_id) < 0)
goto error;
- if (H5Tclose(ftype2_id)<0)
+ if(H5Tclose(ftype2_id) < 0)
goto error;
- if (H5Sclose(space1_id)<0)
+ if(H5Sclose(space1_id) < 0)
goto error;
- if (H5Sclose(space2_id)<0)
+ if(H5Sclose(space2_id) < 0)
goto error;
- if (H5Aclose(attr1_id)<0)
+ if(H5Aclose(attr1_id) < 0)
goto error;
- if (H5Aclose(attr2_id)<0)
+ if(H5Aclose(attr2_id) < 0)
goto error;
- if (H5Tclose(mtype1_id)<0)
+ if(H5Tclose(mtype1_id) < 0)
goto error;
- if (H5Tclose(mtype2_id)<0)
+ if(H5Tclose(mtype2_id) < 0)
goto error;
- if (buf1)
- HDfree(buf1);
- if (buf2)
- HDfree(buf2);
-
nfound_total += nfound;
- } /* u */
+ } /* u */
- return nfound_total;
+ return nfound_total;
error:
- H5E_BEGIN_TRY {
- H5Tclose(ftype1_id);
- H5Tclose(ftype2_id);
- H5Tclose(mtype1_id);
- H5Tclose(mtype2_id);
- H5Sclose(space1_id);
- H5Sclose(space2_id);
- H5Aclose(attr1_id);
- H5Aclose(attr2_id);
- if (buf1)
- HDfree(buf1);
- if (buf2)
- HDfree(buf2);
- } H5E_END_TRY;
-
- options->err_stat=1;
- return nfound_total;
+ H5E_BEGIN_TRY {
+ if(buf1) {
+ if(TRUE == H5Tdetect_class(mtype1_id, H5T_VLEN))
+ H5Dvlen_reclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1);
+ HDfree(buf1);
+ } /* end if */
+ if(buf2) {
+ if(TRUE == H5Tdetect_class(mtype2_id, H5T_VLEN))
+ H5Dvlen_reclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2);
+ HDfree(buf2);
+ } /* end if */
+ H5Tclose(ftype1_id);
+ H5Tclose(ftype2_id);
+ H5Tclose(mtype1_id);
+ H5Tclose(mtype2_id);
+ H5Sclose(space1_id);
+ H5Sclose(space2_id);
+ H5Aclose(attr1_id);
+ H5Aclose(attr2_id);
+ } H5E_END_TRY;
+
+ options->err_stat = 1;
+ return nfound_total;
}
-
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index 8e25b6d..f8fc493 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -13,10 +13,11 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "h5diff.h"
-#include "ph5diff.h"
#include "H5private.h"
#include "h5tools.h"
+#include "h5tools_utils.h"
+#include "h5diff.h"
+#include "ph5diff.h"
/*-------------------------------------------------------------------------
@@ -329,100 +330,88 @@ hsize_t diff_datasetid( hid_t did1,
* only attempt to compare if possible
*-------------------------------------------------------------------------
*/
- if (can_compare ) /* it is possible to compare */
+ if(can_compare) /* it is possible to compare */
{
+ unsigned int vl_data = 0; /*contains VL datatypes */
/*-------------------------------------------------------------------------
* get number of elements
*-------------------------------------------------------------------------
*/
nelmts1 = 1;
- for (i = 0; i < rank1; i++)
- {
+ for(i = 0; i < rank1; i++)
nelmts1 *= dims1[i];
- }
nelmts2 = 1;
- for (i = 0; i < rank2; i++)
- {
+ for(i = 0; i < rank2; i++)
nelmts2 *= dims2[i];
- }
- assert(nelmts1==nelmts2);
+ HDassert(nelmts1 == nelmts2);
/*-------------------------------------------------------------------------
* "upgrade" the smaller memory size
*-------------------------------------------------------------------------
*/
- if ( m_size1 != m_size2 )
- {
- if ( m_size1 < m_size2 )
- {
+ if(m_size1 != m_size2) {
+ if(m_size1 < m_size2) {
H5Tclose(m_tid1);
- if ((m_tid1=h5tools_get_native_type(f_tid2)) < 0)
+ if((m_tid1 = h5tools_get_native_type(f_tid2)) < 0)
goto error;
- m_size1 = H5Tget_size( m_tid1 );
- }
- else
- {
+ m_size1 = H5Tget_size(m_tid1);
+ } /* end if */
+ else {
H5Tclose(m_tid2);
- if ((m_tid2=h5tools_get_native_type(f_tid1)) < 0)
+ if((m_tid2 = h5tools_get_native_type(f_tid1)) < 0)
goto error;
- m_size2 = H5Tget_size( m_tid2 );
- }
- }
- assert(m_size1==m_size2);
+ m_size2 = H5Tget_size(m_tid2);
+ } /* end else */
+ } /* end if */
+ HDassert(m_size1 == m_size2);
/* print names */
- if (obj1_name) {
- name1=diff_basename(obj1_name);
- }
- if (obj2_name) {
- name2=diff_basename(obj2_name);
- }
+ if(obj1_name)
+ name1 = diff_basename(obj1_name);
+ if(obj2_name)
+ name2 = diff_basename(obj2_name);
+
+ /* check if we have VL data in the dataset's datatype */
+ if(TRUE == H5Tdetect_class(m_tid1, H5T_VLEN))
+ vl_data = TRUE;
/*-------------------------------------------------------------------------
* read/compare
*-------------------------------------------------------------------------
*/
- need = (size_t)(nelmts1*m_size1); /* bytes needed */
- if ( need < H5TOOLS_MALLOCSIZE)
- {
+ need = (size_t)(nelmts1 * m_size1); /* bytes needed */
+ if(need < H5TOOLS_MALLOCSIZE) {
buf1 = HDmalloc(need);
buf2 = HDmalloc(need);
- }
+ } /* end if */
- if ( buf1!=NULL && buf2!=NULL)
- {
- if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 )
+ if(buf1 != NULL && buf2 != NULL) {
+ if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
goto error;
- if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 )
+ if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
goto error;
/* array diff */
- nfound = diff_array(buf1,
- buf2,
- nelmts1,
- (hsize_t)0,
- rank1,
- dims1,
- options,
- name1,
- name2,
- m_tid1,
- did1,
- did2);
- }
-
+ nfound = diff_array(buf1, buf2, nelmts1, (hsize_t)0, rank1, dims1,
+ options, name1, name2, m_tid1, did1, did2);
+
+ /* reclaim any VL memory, if necessary */
+ if(vl_data) {
+ H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
+ H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
+ } /* end if */
+ } /* end if */
else /* possibly not enough memory, read/compare by hyperslabs */
-
{
size_t p_type_nbytes = m_size1; /*size of memory type */
hsize_t p_nelmts = nelmts1; /*total selected elmts */
@@ -442,25 +431,21 @@ hsize_t diff_datasetid( hid_t did1,
hsize_t hs_nelmts; /*elements in request */
hsize_t zero[8]; /*vector of zeros */
- /* check if we have VL data in the dataset's datatype */
- if (H5Tdetect_class(m_tid1, H5T_VLEN) == TRUE)
- vl_data = TRUE;
-
- /*
- * determine the strip mine size and allocate a buffer. The strip mine is
- * a hyperslab whose size is manageable.
- */
+ /*
+ * determine the strip mine size and allocate a buffer. The strip mine is
+ * a hyperslab whose size is manageable.
+ */
sm_nbytes = p_type_nbytes;
- for (i = rank1; i > 0; --i)
- {
+ for(i = rank1; i > 0; --i) {
hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes;
- if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */
+
+ if(size == 0) /* datum size > H5TOOLS_BUFSIZE */
size = 1;
sm_size[i - 1] = MIN(dims1[i - 1], size);
sm_nbytes *= sm_size[i - 1];
assert(sm_nbytes > 0);
- }
+ } /* end for */
/* malloc return code should be verified.
* If fail, need to handle the error.
@@ -481,63 +466,43 @@ hsize_t diff_datasetid( hid_t did1,
memset(hs_offset, 0, sizeof hs_offset);
memset(zero, 0, sizeof zero);
- for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
- {
+ for(elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
/* calculate the hyperslab size */
- if (rank1 > 0)
- {
- for (i = 0, hs_nelmts = 1; i < rank1; i++)
- {
+ if(rank1 > 0) {
+ for(i = 0, hs_nelmts = 1; i < rank1; i++) {
hs_size[i] = MIN(dims1[i] - hs_offset[i], sm_size[i]);
hs_nelmts *= hs_size[i];
- }
- if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ } /* end for */
+ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
goto error;
- if (H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
+ if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
goto error;
- if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
+ if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
goto error;
- }
+ } /* end if */
else
- {
- H5Sselect_all(sid1);
- H5Sselect_all(sid2);
- H5Sselect_all(sm_space);
hs_nelmts = 1;
- } /* rank */
- if ( H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0 )
+ if(H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0)
goto error;
- if ( H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0 )
+ if(H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0)
goto error;
/* get array differences. in the case of hyperslab read, increment the number of differences
found in each hyperslab and pass the position at the beggining for printing */
- nfound += diff_array(sm_buf1,
- sm_buf2,
- hs_nelmts,
- elmtno,
- rank1,
- dims1,
- options,
- name1,
- name2,
- m_tid1,
- did1,
- did2);
+ nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1,
+ dims1, options, name1, name2, m_tid1, did1, did2);
/* reclaim any VL memory, if necessary */
- if(vl_data)
- {
+ if(vl_data) {
H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1);
H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2);
- }
+ } /* end if */
/* calculate the next hyperslab offset */
- for (i = rank1, carry = 1; i > 0 && carry; --i)
- {
+ for(i = rank1, carry = 1; i > 0 && carry; --i) {
hs_offset[i - 1] += hs_size[i - 1];
- if (hs_offset[i - 1] == dims1[i - 1])
+ if(hs_offset[i - 1] == dims1[i - 1])
hs_offset[i - 1] = 0;
else
carry = 0;
@@ -545,60 +510,53 @@ hsize_t diff_datasetid( hid_t did1,
} /* elmtno */
H5Sclose(sm_space);
- } /* hyperslab read */
- }/*can_compare*/
-
- /*-------------------------------------------------------------------------
- * compare attributes
- * the if condition refers to cases when the dataset is a referenced object
- *-------------------------------------------------------------------------
- */
-
- if (obj1_name)
- {
- nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
- }
+ } /* hyperslab read */
+ } /*can_compare*/
- /*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * compare attributes
+ * the if condition refers to cases when the dataset is a referenced object
+ *-------------------------------------------------------------------------
+ */
+ if(obj1_name)
+ nfound += diff_attr(did1,did2,obj1_name,obj2_name,options);
- /* free */
- if (buf1!=NULL)
- {
- free(buf1);
- buf1=NULL;
- }
- if (buf2!=NULL)
- {
- free(buf2);
- buf2=NULL;
- }
- if (sm_buf1!=NULL)
- {
- free(sm_buf1);
- sm_buf1=NULL;
- }
- if (sm_buf2!=NULL)
- {
- free(sm_buf2);
- sm_buf2=NULL;
- }
+ /*-------------------------------------------------------------------------
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ /* free */
+ if(buf1 != NULL) {
+ free(buf1);
+ buf1 = NULL;
+ } /* end if */
+ if(buf2 != NULL) {
+ free(buf2);
+ buf2 = NULL;
+ } /* end if */
+ if(sm_buf1 != NULL) {
+ free(sm_buf1);
+ sm_buf1 = NULL;
+ } /* end if */
+ if(sm_buf2 != NULL) {
+ free(sm_buf2);
+ sm_buf2 = NULL;
+ } /* end if */
- H5E_BEGIN_TRY {
- H5Sclose(sid1);
- H5Sclose(sid2);
- H5Tclose(f_tid1);
- H5Tclose(f_tid2);
- H5Tclose(m_tid1);
- H5Tclose(m_tid2);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY {
+ H5Sclose(sid1);
+ H5Sclose(sid2);
+ H5Tclose(f_tid1);
+ H5Tclose(f_tid2);
+ H5Tclose(m_tid1);
+ H5Tclose(m_tid2);
+ } H5E_END_TRY;
- return nfound;
+ return nfound;
error:
- options->err_stat=1;
+ options->err_stat=1;
/* free */
if (buf1!=NULL)
diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c
index 5df94fa..6d340d9 100644
--- a/tools/lib/h5diff_util.c
+++ b/tools/lib/h5diff_util.c
@@ -13,10 +13,11 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include "h5diff.h"
-#include "ph5diff.h"
#include "H5private.h"
#include "h5tools.h"
+#include "h5tools_utils.h"
+#include "h5diff.h"
+#include "ph5diff.h"
/* global variables */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 896c310..e7ba801 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -49,7 +49,7 @@ static h5tool_format_t h5tools_dataformat = {
"", /*fmt_raw */
"%d", /*fmt_int */
"%u", /*fmt_uint */
-"%d", /*fmt_schar */
+"%hhd", /*fmt_schar */
"%u", /*fmt_uchar */
"%d", /*fmt_short */
"%u", /*fmt_ushort */
@@ -887,8 +887,6 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
*/
curr_pos = ctx->sm_pos;
- h5tools_simple_prefix(stream, info, ctx, curr_pos, 0);
-
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
void* memref = mem + i * size;
if (region_output && H5Tequal(type, H5T_STD_REF_DSETREG)) {
@@ -1081,14 +1079,11 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
*/
/*
- * Added the info->skip_first because the dumper does not want
- * this check to happen for the first line
+ * check for displaying prefix for each section
*/
- if ((!info->skip_first || local_elmt_counter) &&
- (ctx->cur_column +
- strlen(section) +
- strlen(OPT(info->elmt_suf2, " ")) +
- strlen(OPT(info->line_suf, ""))) > ncols)
+ if ( (ctx->cur_column + strlen(section) +
+ strlen(OPT(info->elmt_suf2, " ")) +
+ strlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index c5f10b8..8c9960f 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -789,7 +789,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
}
else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp);
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), *cp_vp);
}
else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp);