summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_ref.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools_ref.c')
-rw-r--r--tools/lib/h5tools_ref.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index 8c869c8..d6e5f01 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -5,16 +5,12 @@
* *
* 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://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
#include "h5tools_ref.h"
#include "H5private.h"
#include "H5SLprivate.h"
@@ -111,19 +107,21 @@ static int
init_ref_path_table(void)
{
/* Sanity check */
- HDassert(thefile > 0);
-
- /* Create skip list to store reference path information */
- if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ if(thefile > 0) {
+ /* Create skip list to store reference path information */
+ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ return (-1);
+
+ /* Iterate over objects in this file */
+ if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
+ error_msg("unable to construct reference path table\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ } /* end if */
+
+ return(0);
+ }
+ else
return (-1);
-
- /* Iterate over objects in this file */
- if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
- error_msg("unable to construct reference path table\n");
- h5tools_setstatus(EXIT_FAILURE);
- } /* end if */
-
- return(0);
}
/*-------------------------------------------------------------------------
@@ -169,6 +167,8 @@ ref_path_table_lookup(const char *thepath)
{
H5O_info_t oi;
+ if((thepath == NULL) || (HDstrlen(thepath) == 0))
+ return HADDR_UNDEF;
/* Allow lookups on the root group, even though it doesn't have any link info */
if(HDstrcmp(thepath, "/")) {
H5L_info_t li;
@@ -215,16 +215,17 @@ ref_path_table_put(const char *path, haddr_t objno)
{
ref_path_node_t *new_node;
- HDassert(ref_path_table);
- HDassert(path);
+ if(ref_path_table && path) {
+ if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
+ return(-1);
- if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
- return(-1);
+ new_node->objno = objno;
+ new_node->path = HDstrdup(path);
- new_node->objno = objno;
- new_node->path = HDstrdup(path);
-
- return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ }
+ else
+ return (-1);
}
/*