summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-08 19:30:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-08 19:30:19 (GMT)
commit64b045691c065c18bdf233349074dc4b7fac9f5a (patch)
treea250384b1b43558f6f04a7bf7b983af68bdc03e8 /tools
parent21c1f05808c8a28b73daf2d22c1533b6e89405f4 (diff)
downloadhdf5-64b045691c065c18bdf233349074dc4b7fac9f5a.zip
hdf5-64b045691c065c18bdf233349074dc4b7fac9f5a.tar.gz
hdf5-64b045691c065c18bdf233349074dc4b7fac9f5a.tar.bz2
[svn-r7322] Purpose:
Refactored code Description: Use H5E_BEGIN_TRY/H5E_END_TRY macros around blocks where errors shouldn't be printed, instead of managing 'automatic error' information. Use new 'flags' field in table objects where appropriate Chase changes to 'fileno' and 'objno' fields of H5G_stat_t Platforms tested: h5committested
Diffstat (limited to 'tools')
-rw-r--r--tools/h5diff/h5trav.c96
1 files changed, 69 insertions, 27 deletions
diff --git a/tools/h5diff/h5trav.c b/tools/h5diff/h5trav.c
index f4ce00f..ba51285 100644
--- a/tools/h5diff/h5trav.c
+++ b/tools/h5diff/h5trav.c
@@ -1,4 +1,3 @@
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
@@ -37,9 +36,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
herr_t get_nobjects( hid_t loc_id, const char *group_name );
herr_t get_name_type( hid_t loc_id, const char *group_name, int idx, char **name, int *type );
-
-
-
/*-------------------------------------------------------------------------
* Function: H5get_object_info
*
@@ -237,8 +233,6 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
H5G_stat_t statbuf;
int inserted_objs=0;
int j;
- void *edata;
- H5E_auto_t func;
if (( nobjs = get_nobjects( loc_id, group_name )) < 0 )
return -1;
@@ -259,12 +253,11 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
strcat( path, name );
/* disable error reporting */
- H5Eget_auto(H5E_DEFAULT, &func, &edata);
- H5Eset_auto(H5E_DEFAULT, NULL, NULL);
+ H5E_BEGIN_TRY {
/* get info */
H5Gget_objinfo( loc_id, path, TRUE, &statbuf);
- H5Eset_auto(H5E_DEFAULT, &func, edata);
+ } H5E_END_TRY;
/* add to array */
if ( info )
@@ -289,10 +282,10 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
inserted_objs++;
/* nlink is number of hard links to object */
- if (statbuf.nlink > 0 && table_search(statbuf.objno, table ) == FAIL)
+ if (statbuf.nlink > 0 && table_search_obj(statbuf.objno, table ) == FAIL)
{
/* add object to table */
- table_add(statbuf.objno, path, H5G_GROUP, table );
+ table_add_obj(statbuf.objno, path, H5G_GROUP, table );
/* recurse with the absolute name */
inserted_objs += traverse( loc_id, path, table, info, idx );
@@ -302,7 +295,7 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
group with more than one link to it */
if (statbuf.nlink > 1)
{
- if ((j = table_search(statbuf.objno, table )) < 0 )
+ if ((j = table_search_obj(statbuf.objno, table )) < 0 )
return -1;
if ( table->objs[j].displayed == 0 )
@@ -329,17 +322,17 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
inserted_objs++;
/* nlink is number of hard links to object */
- if (statbuf.nlink > 0 && table_search(statbuf.objno, table ) == FAIL)
+ if (statbuf.nlink > 0 && table_search_obj(statbuf.objno, table ) == FAIL)
{
/* add object to table */
- table_add(statbuf.objno, path, H5G_DATASET, table );
+ table_add_obj(statbuf.objno, path, H5G_DATASET, table );
}
/* search table
dataset with more than one link to it */
if (statbuf.nlink > 1)
{
- if ((j = table_search(statbuf.objno, table )) < 0 )
+ if ((j = table_search_obj(statbuf.objno, table )) < 0 )
return -1;
if ( table->objs[j].displayed == 0 )
@@ -367,10 +360,10 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
inserted_objs++;
/* nlink is number of hard links to object */
- if (statbuf.nlink > 0 && table_search(statbuf.objno, table ) == FAIL)
+ if (statbuf.nlink > 0 && table_search_obj(statbuf.objno, table ) == FAIL)
{
/* add object to table */
- table_add(statbuf.objno, path, H5G_TYPE, table );
+ table_add_obj(statbuf.objno, path, H5G_TYPE, table );
}
break;
@@ -415,7 +408,7 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
/*-------------------------------------------------------------------------
- * Function: table_search
+ * Function: table_search_obj
*
* Purpose:
*
@@ -432,12 +425,12 @@ int traverse( hid_t loc_id, const char *group_name, table_t *table, info_t *info
*-------------------------------------------------------------------------
*/
-int table_search(unsigned long *objno, table_t *table )
+int table_search_obj(haddr_t objno, table_t *table )
{
int i;
for (i = 0; i < table->nobjs; i++)
- if (table->objs[i].objno[0] == *objno && table->objs[i].objno[1] == *(objno + 1))
+ if (table->objs[i].objno == objno)
return i;
return FAIL;
@@ -445,7 +438,52 @@ int table_search(unsigned long *objno, table_t *table )
/*-------------------------------------------------------------------------
- * Function: table_add
+ * Function: table_add_obj
+ *
+ * Purpose:
+ *
+ * Return:
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: November 4, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+table_add_obj(haddr_t objno, char *objname, int type, table_t *table)
+{
+ int i;
+
+ if (table->nobjs == table->size) {
+ table->size *= 2;
+ table->objs = (obj_t*)realloc(table->objs, table->size * sizeof(obj_t));
+
+ for (i = table->nobjs; i < table->size; i++) {
+ table->objs[i].objno = 0;
+ table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
+ table->objs[i].displayed = 0;
+ table->objs[i].type = H5G_UNKNOWN;
+ table->objs[i].objname = NULL;
+ }
+ }
+
+ i = table->nobjs++;
+ table->objs[i].objno = objno;
+ table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
+ free(table->objs[i].objname);
+ table->objs[i].objname = (char *)HDstrdup(objname);
+ table->objs[i].type = type;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: table_add_flags
*
* Purpose:
*
@@ -462,7 +500,8 @@ int table_search(unsigned long *objno, table_t *table )
*-------------------------------------------------------------------------
*/
-void table_add(unsigned long *objno, char *objname, int type, table_t *table)
+void
+table_add_flags(unsigned *flags, char *objname, int type, table_t *table)
{
int i;
@@ -471,7 +510,8 @@ void table_add(unsigned long *objno, char *objname, int type, table_t *table)
table->objs = (obj_t*)realloc(table->objs, table->size * sizeof(obj_t));
for (i = table->nobjs; i < table->size; i++) {
- table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
+ table->objs[i].objno = 0;
+ table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].type = H5G_UNKNOWN;
table->objs[i].objname = NULL;
@@ -479,11 +519,12 @@ void table_add(unsigned long *objno, char *objname, int type, table_t *table)
}
i = table->nobjs++;
- table->objs[i].objno[0] = objno[0];
- table->objs[i].objno[1] = objno[1];
+ table->objs[i].objno = 0;
+ table->objs[i].flags[0] = flags[0];
+ table->objs[i].flags[1] = flags[1];
free(table->objs[i].objname);
table->objs[i].objname = (char *)HDstrdup(objname);
- table->objs[i].type = type;
+ table->objs[i].type = type;
}
@@ -515,7 +556,8 @@ void table_init( table_t **tbl )
table->objs = (obj_t*) malloc(table->size * sizeof(obj_t));
for (i = 0; i < table->size; i++) {
- table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
+ table->objs[i].objno = 0;
+ table->objs[i].flags[0] = table->objs[i].flags[1] = 0;
table->objs[i].displayed = 0;
table->objs[i].type = H5G_UNKNOWN;
table->objs[i].objname = NULL;