mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-12-15 07:40:23 +08:00
Merge pull request #718 in HDFFV/hdf5 from ~BYRN/hdf5_adb:hdf5_1_10 to hdf5_1_10
* commit 'cb3eb13da469b8df90ed29a974f41e3999ac411d': Fix typos HDFFv-10297 Free buffer inside loop HDFFV-10297 - Cleanup, initialize variables
This commit is contained in:
commit
62633db9c2
@ -189,7 +189,7 @@ hsize_t diff_datasetid(hid_t did1,
|
||||
void *buf2 = NULL;
|
||||
void *sm_buf1 = NULL;
|
||||
void *sm_buf2 = NULL;
|
||||
hid_t sm_space; /*stripmine data space */
|
||||
hid_t sm_space = -1; /*stripmine data space */
|
||||
size_t need; /* bytes needed for malloc */
|
||||
int i;
|
||||
unsigned int vl_data = 0; /*contains VL datatypes */
|
||||
|
@ -77,18 +77,13 @@ typedef enum {
|
||||
#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Initialize the H5 Tools library
|
||||
* Description:
|
||||
* This should be called before any other h5tools function is called.
|
||||
* Function: h5tools_init
|
||||
*
|
||||
* Purpose: This should be called before any other h5tools function is called.
|
||||
* Effect of any h5tools function called before this has been called is
|
||||
* undetermined.
|
||||
* Return:
|
||||
* None
|
||||
* Programmer:
|
||||
* Albert Cheng, 2000-10-31
|
||||
* Modifications:
|
||||
*
|
||||
* Return None
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
@ -121,19 +116,14 @@ h5tools_init(void)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Close the H5 Tools library
|
||||
* Description:
|
||||
* Close or release resources such as files opened by the library. This
|
||||
* Function: h5tools_close
|
||||
*
|
||||
* Purpose: Close or release resources such as files opened by the library. This
|
||||
* should be called after all other h5tools functions have been called.
|
||||
* Effect of any h5tools function called after this has been called is
|
||||
* undetermined.
|
||||
* Return:
|
||||
* None
|
||||
* Programmer:
|
||||
* Albert Cheng, 2000-10-31
|
||||
* Modifications:
|
||||
*
|
||||
* Return: None
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
@ -200,12 +190,6 @@ h5tools_close(void)
|
||||
*
|
||||
* Return: 0 -- succeeded
|
||||
* negative -- failed
|
||||
*
|
||||
* Programmer: Albert Cheng, 2000/09/30
|
||||
*
|
||||
* Modifications:
|
||||
* pvn June, 1, 2006. Add a switch for binary output
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
@ -254,7 +238,6 @@ h5tools_set_data_output_file(const char *fname, int is_bin)
|
||||
*
|
||||
* Return: 0 -- succeeded
|
||||
* negative -- failed
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
@ -399,7 +382,6 @@ h5tools_set_output_file(const char *fname, int is_bin)
|
||||
*
|
||||
* Return: 0 -- succeeded
|
||||
* negative -- failed
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
@ -441,33 +423,28 @@ h5tools_set_error_file(const char *fname, int is_bin)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Private
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Get a FAPL for a driver
|
||||
* Description:
|
||||
* Get a FAPL for a given VFL driver name.
|
||||
* Return:
|
||||
* None
|
||||
* Programmer:
|
||||
* Quincey Koziol, 2004-02-04
|
||||
* Modifications:
|
||||
* Pedro Vicente Nunes, Thursday, July 27, 2006
|
||||
* Added error return conditions for the H5Pset_fapl calls
|
||||
* Function: h5tools_get_fapl
|
||||
*
|
||||
* Purpose: Get a FAPL for a given VFL driver name.
|
||||
*
|
||||
* Return: positive - succeeded
|
||||
* negative - failed
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static hid_t
|
||||
h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
{
|
||||
hid_t new_fapl; /* Copy of file access property list passed in, or new property list */
|
||||
hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */
|
||||
int ret_value = SUCCEED;
|
||||
|
||||
/* Make a copy of the FAPL, for the file open call to use, eventually */
|
||||
if (fapl == H5P_DEFAULT) {
|
||||
if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed");
|
||||
} /* end if */
|
||||
else {
|
||||
if ((new_fapl = H5Pcopy(fapl)) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed");
|
||||
} /* end else */
|
||||
|
||||
/* Determine which driver the user wants to open the file with. Try
|
||||
@ -475,7 +452,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
|
||||
/* SEC2 driver */
|
||||
if (H5Pset_fapl_sec2(new_fapl) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_sec2 failed");
|
||||
|
||||
if (drivernum)
|
||||
*drivernum = SEC2_IDX;
|
||||
@ -487,7 +464,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
* is the member size.
|
||||
*/
|
||||
if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_family failed");
|
||||
|
||||
if (drivernum)
|
||||
*drivernum = FAMILY_IDX;
|
||||
@ -495,7 +472,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
|
||||
/* SPLIT Driver */
|
||||
if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_split failed");
|
||||
|
||||
if (drivernum)
|
||||
*drivernum = SPLIT_IDX;
|
||||
@ -503,7 +480,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
|
||||
/* MULTI Driver */
|
||||
if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_multi failed");
|
||||
|
||||
if(drivernum)
|
||||
*drivernum = MULTI_IDX;
|
||||
@ -519,29 +496,28 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
||||
|
||||
if(mpi_initialized && !mpi_finalized) {
|
||||
if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
|
||||
goto error;
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_mpio failed");
|
||||
if(drivernum)
|
||||
*drivernum = MPIO_IDX;
|
||||
} /* end if */
|
||||
}
|
||||
#endif /* H5_HAVE_PARALLEL */
|
||||
else
|
||||
goto error;
|
||||
ret_value = -1;
|
||||
|
||||
done:
|
||||
if((new_fapl != H5P_DEFAULT) && (ret_value < 0)) {
|
||||
H5Pclose(new_fapl);
|
||||
new_fapl = -1;
|
||||
}
|
||||
|
||||
return(new_fapl);
|
||||
|
||||
error:
|
||||
if(new_fapl != H5P_DEFAULT)
|
||||
H5Pclose(new_fapl);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Open a file with various VFL drivers.
|
||||
* Description:
|
||||
* Loop through the various types of VFL drivers trying to open FNAME.
|
||||
* Function: h5tools_fopen
|
||||
*
|
||||
* Purpose: Loop through the various types of VFL drivers trying to open FNAME.
|
||||
* If the HDF5 library is version 1.2 or less, then we have only the SEC2
|
||||
* driver to try out. If the HDF5 library is greater than version 1.2,
|
||||
* then we have the FAMILY, SPLIT, and MULTI drivers to play with.
|
||||
@ -549,6 +525,7 @@ error:
|
||||
* If DRIVER is non-NULL, then it will try to open the file with that
|
||||
* driver first. We assume that the user knows what they are doing so, if
|
||||
* we fail, then we won't try other file drivers.
|
||||
*
|
||||
* Return:
|
||||
* On success, returns a file id for the opened file. If DRIVERNAME is
|
||||
* non-null then the first DRIVERNAME_SIZE-1 characters of the driver
|
||||
@ -556,38 +533,6 @@ error:
|
||||
*
|
||||
* Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
|
||||
* the first byte is set to the null terminator.
|
||||
* Programmer:
|
||||
* Lost in the mists of time.
|
||||
* Modifications:
|
||||
* Robb Matzke, 2000-06-23
|
||||
* We only have to initialize driver[] on the first call, thereby
|
||||
* preventing memory leaks from repeated calls to H5Pcreate().
|
||||
*
|
||||
* Robb Matzke, 2000-06-23
|
||||
* Added DRIVERNAME_SIZE arg to prevent overflows when writing to
|
||||
* DRIVERNAME.
|
||||
*
|
||||
* Robb Matzke, 2000-06-23
|
||||
* Added test to prevent coredump when the file could not be opened by
|
||||
* any driver.
|
||||
*
|
||||
* Robb Matzke, 2000-06-23
|
||||
* Changed name from H5ToolsFopen() so it jives better with the names we
|
||||
* already have at the top of this source file.
|
||||
*
|
||||
* Thomas Radke, 2000-09-12
|
||||
* Added Stream VFD to the driver[] array.
|
||||
*
|
||||
* Bill Wendling, 2001-01-10
|
||||
* Changed macro behavior so that if we have a version other than 1.2.x
|
||||
* (i.e., > 1.2), then we do the drivers check.
|
||||
*
|
||||
* Bill Wendling, 2001-07-30
|
||||
* Added DRIVER parameter so that the user can specify "try this driver"
|
||||
* instead of the default behaviour. If it fails to open the file with
|
||||
* that driver, this will fail completely (i.e., we won't try the other
|
||||
* drivers). We're assuming the user knows what they're doing. How UNIX
|
||||
* of us.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hid_t
|
||||
@ -652,18 +597,13 @@ done:
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Count the number of columns in a string.
|
||||
* Description:
|
||||
* Count the number of columns in a string. This is the number of
|
||||
* Function: h5tools_count_ncols
|
||||
*
|
||||
* Purpose: Count the number of columns in a string. This is the number of
|
||||
* characters in the string not counting line-control characters.
|
||||
* Return:
|
||||
* On success, returns the width of the string. Otherwise this function
|
||||
* returns 0.
|
||||
* Programmer:
|
||||
* Robb Matzke, Tuesday, April 27, 1999
|
||||
* Modifications:
|
||||
*
|
||||
* Return: success - returns the width of the string.
|
||||
* failure - 0.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5_ATTR_PURE static size_t
|
||||
@ -683,18 +623,15 @@ h5tools_count_ncols(const char *s)
|
||||
*
|
||||
* Purpose: Recursive check for any variable length data in given type.
|
||||
*
|
||||
* Return:
|
||||
* TRUE : type conatains any variable length data
|
||||
* Return: TRUE : type contains any variable length data
|
||||
* FALSE : type doesn't contain any variable length data
|
||||
* Negative value: error occur
|
||||
*
|
||||
* Programmer: Jonathan Kim March 18, 2011
|
||||
* Negative value: failed
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
htri_t
|
||||
h5tools_detect_vlen(hid_t tid)
|
||||
{
|
||||
htri_t ret;
|
||||
htri_t ret = FALSE;
|
||||
|
||||
/* recursive detect any vlen data values in type (compound, array ...) */
|
||||
ret = H5Tdetect_class(tid, H5T_VLEN);
|
||||
@ -715,11 +652,9 @@ done:
|
||||
*
|
||||
* Purpose: Recursive check for variable length string of a datatype.
|
||||
*
|
||||
* Return:
|
||||
* TRUE : type conatains any variable length string
|
||||
* Return: TRUE : type contains any variable length string
|
||||
* FALSE : type doesn't contain any variable length string
|
||||
* Negative value: error occur
|
||||
*
|
||||
* Negative value: failed
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
htri_t
|
||||
@ -774,25 +709,13 @@ done:
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Emit a simple prefix to STREAM.
|
||||
* Description:
|
||||
* If /ctx->need_prefix/ is set then terminate the current line (if
|
||||
* Function: h5tools_simple_prefix
|
||||
*
|
||||
* Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
|
||||
* applicable), calculate the prefix string, and display it at the start
|
||||
* of a line.
|
||||
* Return:
|
||||
* None
|
||||
* Programmer:
|
||||
* Robb Matzke, Monday, April 26, 1999
|
||||
* Modifications:
|
||||
* Robb Matzke, 1999-09-29
|
||||
* If a new prefix is printed then the current element number is set back
|
||||
* to zero.
|
||||
* pvn, 2004-07-08
|
||||
* Added support for printing array indices:
|
||||
* the indentation is printed before the prefix (printed one indentation
|
||||
* level before)
|
||||
*
|
||||
* Return: None
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
@ -871,15 +794,13 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Emit a simple prefix to STREAM.
|
||||
* Description:
|
||||
* If /ctx->need_prefix/ is set then terminate the current line (if
|
||||
* Function: h5tools_region_simple_prefix
|
||||
*
|
||||
* Purpose: If /ctx->need_prefix/ is set then terminate the current line (if
|
||||
* applicable), calculate the prefix string, and display it at the start
|
||||
* of a line. Calls region specific function.
|
||||
* Return:
|
||||
* None
|
||||
*
|
||||
* Return: None
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
@ -958,16 +879,14 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Render an element to output STREAM.
|
||||
* Description:
|
||||
* Prints the string buffer to the output STREAM. The string is
|
||||
* Function: h5tools_render_element
|
||||
*
|
||||
* Purpose: Prints the string buffer to the output STREAM. The string is
|
||||
* printed according to the format described in INFO. The CTX struct
|
||||
* contains context information shared between calls to this function.
|
||||
*
|
||||
* Return:
|
||||
* False if a dimension end is reached, otherwise true
|
||||
* Return: False if a dimension end is reached
|
||||
* True otherwise
|
||||
*
|
||||
* In/Out:
|
||||
* h5tools_context_t *ctx
|
||||
@ -988,10 +907,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
|
||||
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
||||
{
|
||||
hbool_t dimension_break = TRUE;
|
||||
char *s;
|
||||
char *section; /*a section of output */
|
||||
int secnum; /*section sequence number */
|
||||
int multiline; /*datum was multiline */
|
||||
char *s = NULL;
|
||||
char *section = NULL; /* a section of output */
|
||||
int secnum; /* section sequence number */
|
||||
int multiline; /* datum was multiline */
|
||||
|
||||
if (stream == NULL)
|
||||
return dimension_break;
|
||||
@ -1114,16 +1033,15 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Render a region element to output STREAM.
|
||||
* Description:
|
||||
* Prints the string buffer to the output STREAM. The string is
|
||||
* Function: h5tools_render_region_element
|
||||
*
|
||||
* Purpose: Prints the string buffer to the output STREAM. The string is
|
||||
* printed according to the format described in INFO. The CTX struct
|
||||
* contains context information shared between calls to this function.
|
||||
*
|
||||
* Return:
|
||||
* False if a dimension end is reached, otherwise true
|
||||
* False if a dimension end is reached
|
||||
* True otherwise
|
||||
*
|
||||
* In/Out:
|
||||
* h5tools_context_t *ctx
|
||||
@ -1145,10 +1063,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
|
||||
size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
||||
{
|
||||
hbool_t dimension_break = TRUE;
|
||||
char *s;
|
||||
char *section; /*a section of output */
|
||||
int secnum; /*section sequence number */
|
||||
int multiline; /*datum was multiline */
|
||||
char *s = NULL;
|
||||
char *section = NULL; /* a section of output */
|
||||
int secnum; /* section sequence number */
|
||||
int multiline; /* datum was multiline */
|
||||
|
||||
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
|
||||
|
||||
@ -1344,7 +1262,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
|
||||
{
|
||||
unsigned int i;
|
||||
H5T_str_t pad;
|
||||
char *s;
|
||||
char *s = NULL;
|
||||
unsigned char tempuchar;
|
||||
|
||||
pad = H5Tget_strpad(tid);
|
||||
@ -1384,7 +1302,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
|
||||
|
||||
mem = ((unsigned char*)_mem) + block_index * size;
|
||||
for (j = 0; j < nmembs; j++) {
|
||||
hid_t memb;
|
||||
hid_t memb = -1;
|
||||
size_t offset;
|
||||
|
||||
offset = H5Tget_member_offset(tid, j);
|
||||
@ -1404,7 +1322,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
|
||||
{
|
||||
int k, ndims;
|
||||
hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
|
||||
hid_t memb;
|
||||
hid_t memb = -1;
|
||||
|
||||
/* get the array's base datatype for each element */
|
||||
memb = H5Tget_super(tid);
|
||||
@ -1437,7 +1355,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
|
||||
case H5T_VLEN:
|
||||
{
|
||||
hsize_t nelmts;
|
||||
hid_t memb;
|
||||
hid_t memb = -1;
|
||||
|
||||
/* get the VL sequences's base datatype for each element */
|
||||
memb = H5Tget_super(tid);
|
||||
@ -1462,7 +1380,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
|
||||
/* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
|
||||
if (region_output) {
|
||||
/* region data */
|
||||
hid_t region_id, region_space;
|
||||
hid_t region_id = -1;
|
||||
hid_t region_space = -1;
|
||||
H5S_sel_type region_type;
|
||||
|
||||
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
||||
@ -1512,15 +1431,13 @@ CATCH
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Print the data values from a dataset referenced by region blocks.
|
||||
* Function: render_bin_output_region_data_blocks
|
||||
*
|
||||
* Description:
|
||||
* Purpose: Print the data values from a dataset referenced by region blocks.
|
||||
* This is a special case subfunction to print the data in a region reference of type blocks.
|
||||
*
|
||||
* Return:
|
||||
* The function returns FAIL if there was an error, otherwise SUCEED
|
||||
* Return: FAIL if there was an error
|
||||
* SUCCEED otherwise
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1609,16 +1526,13 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Purpose: Print some values from a dataset referenced by region blocks.
|
||||
* Function: render_bin_output_region_blocks
|
||||
*
|
||||
* Description:
|
||||
* Purpose: Print some values from a dataset referenced by region blocks.
|
||||
* This is a special case subfunction to dump a region reference using blocks.
|
||||
*
|
||||
* Return:
|
||||
* The function returns False if ERROR, otherwise True
|
||||
*
|
||||
* Return: False if ERROR
|
||||
* True otherwise
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hbool_t
|
||||
@ -1629,7 +1543,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
|
||||
hssize_t snblocks;
|
||||
hsize_t nblocks;
|
||||
hsize_t alloc_size;
|
||||
hsize_t *ptdata;
|
||||
hsize_t *ptdata = NULL;
|
||||
int sndims;
|
||||
unsigned ndims;
|
||||
hid_t dtype = -1;
|
||||
@ -1675,8 +1589,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Function: H5Tools Library
|
||||
* Purpose: Print the data values from a dataset referenced by region points.
|
||||
*
|
||||
* Description:
|
||||
@ -1736,16 +1649,13 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Audience: Public
|
||||
* Chapter: H5Tools Library
|
||||
* Function: render_bin_output_region_points
|
||||
*
|
||||
* Purpose: Print some values from a dataset referenced by region points.
|
||||
* This is a special case function to dump a region reference using points.
|
||||
*
|
||||
* Description:
|
||||
* This is a special case subfunction to dump a region reference using points.
|
||||
*
|
||||
* Return:
|
||||
* The function returns False if the last dimension has been reached, otherwise True
|
||||
*
|
||||
* Return: False if the last dimension has been reached
|
||||
* True otherwise
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hbool_t
|
||||
@ -1795,7 +1705,8 @@ CATCH
|
||||
*
|
||||
* Purpose: Determines if memory is initialized to all zero bytes.
|
||||
*
|
||||
* Return: TRUE if all bytes are zero; FALSE otherwise
|
||||
* Return: TRUE if all bytes are zero
|
||||
* FALSE otherwise
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5_ATTR_PURE hbool_t
|
||||
@ -1823,11 +1734,8 @@ h5tools_is_zero(const void *_mem, size_t size)
|
||||
* char *name1: link name of the first object.
|
||||
* Use "." or NULL if loc_id2 is the object to be compared.
|
||||
*
|
||||
* Return: TRUE if it is the same object; FALSE otherwise.
|
||||
*
|
||||
* Programmer: Peter Cao
|
||||
* 4/27/2011
|
||||
*
|
||||
* Return: TRUE if it is the same object
|
||||
* FALSE otherwise.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
hbool_t
|
||||
|
@ -2888,7 +2888,7 @@ void
|
||||
h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id)
|
||||
{
|
||||
size_t size;
|
||||
hid_t n_type;
|
||||
hid_t n_type = -1;
|
||||
void *buf = NULL;
|
||||
|
||||
n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT);
|
||||
@ -3638,7 +3638,8 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info,
|
||||
error_msg("unable to open attribute \"%s\"\n", attr_name);
|
||||
}
|
||||
else {
|
||||
hid_t type, space;
|
||||
hid_t type = -1;
|
||||
hid_t space = -1;
|
||||
|
||||
ctx->indent_level++;
|
||||
|
||||
@ -3857,9 +3858,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info,
|
||||
H5S_class_t space_type;
|
||||
int ndims;
|
||||
int i;
|
||||
hid_t space;
|
||||
hid_t type;
|
||||
hid_t p_type;
|
||||
hid_t space = -1;
|
||||
hid_t type = -1;
|
||||
hid_t p_type = -1;
|
||||
hsize_t size[64];
|
||||
hsize_t alloc_size;
|
||||
hsize_t nelmts = 1;
|
||||
|
@ -715,10 +715,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
|
||||
{
|
||||
size_t nsize, offset, size=0, nelmts, start;
|
||||
H5T_sign_t nsign;
|
||||
char *name;
|
||||
char *name = NULL;
|
||||
unsigned char *ucp_vp = (unsigned char *)vp;
|
||||
char *cp_vp = (char *)vp;
|
||||
hid_t memb, obj;
|
||||
hid_t memb = -1;
|
||||
hid_t obj = -1;
|
||||
static char fmt_llong[8], fmt_ullong[8];
|
||||
H5T_str_t pad;
|
||||
H5T_class_t type_class;
|
||||
@ -1306,7 +1307,8 @@ void
|
||||
h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
|
||||
hid_t container, void *vp)
|
||||
{
|
||||
hid_t obj, region;
|
||||
hid_t obj = -1;
|
||||
hid_t region = -1;
|
||||
char ref_name[1024];
|
||||
H5S_sel_type region_type;
|
||||
|
||||
|
@ -482,8 +482,7 @@ search_obj(table_t *table, haddr_t objno)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen,
|
||||
void *op_data)
|
||||
find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, void *op_data)
|
||||
{
|
||||
find_objs_t *info = (find_objs_t*)op_data;
|
||||
herr_t ret_value = 0;
|
||||
@ -496,7 +495,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
|
||||
|
||||
case H5O_TYPE_DATASET:
|
||||
if(NULL == already_seen) {
|
||||
hid_t dset;
|
||||
hid_t dset = -1;
|
||||
|
||||
/* Add the dataset to the list of objects */
|
||||
add_obj(info->dset_table, oinfo->addr, name, TRUE);
|
||||
|
@ -374,7 +374,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p,
|
||||
if ((is_named = H5Tcommitted(ftype_id)) < 0)
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed");
|
||||
if (is_named && travt) {
|
||||
hid_t fidout;
|
||||
hid_t fidout = -1;
|
||||
|
||||
/* Create out file id */
|
||||
if ((fidout = H5Iget_file_id(loc_out)) < 0)
|
||||
@ -707,9 +707,9 @@ done:
|
||||
*/
|
||||
static int check_objects(const char* fname, pack_opt_t *options) {
|
||||
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
|
||||
hid_t fid;
|
||||
hid_t did;
|
||||
hid_t sid;
|
||||
hid_t fid = -1;
|
||||
hid_t did = -1;
|
||||
hid_t sid = -1;
|
||||
unsigned int i;
|
||||
unsigned int uf;
|
||||
trav_table_t *travt = NULL;
|
||||
|
@ -927,6 +927,11 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
|
||||
if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN))
|
||||
if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0)
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed");
|
||||
/* free */
|
||||
if (buf != NULL) {
|
||||
HDfree(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
}
|
||||
else { /* possibly not enough memory, read/write by hyperslabs */
|
||||
size_t p_type_nbytes = msize; /*size of memory type */
|
||||
@ -1097,7 +1102,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
else {
|
||||
hid_t pid;
|
||||
hid_t pid = -1;
|
||||
|
||||
/* create property to pass copy options */
|
||||
if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0)
|
||||
@ -1435,51 +1440,51 @@ void
|
||||
print_user_block(const char *filename, hid_t fid)
|
||||
{
|
||||
int ret_value = 0;
|
||||
int fh; /* file handle */
|
||||
int fh = -1; /* file handle */
|
||||
hsize_t ub_size; /* user block size */
|
||||
hsize_t size; /* size read */
|
||||
hid_t fcpl; /* file creation property list ID for HDF5 file */
|
||||
hid_t fcpl = -1; /* file creation property list ID for HDF5 file */
|
||||
int i;
|
||||
|
||||
/* get user block size */
|
||||
if(( fcpl = H5Fget_create_plist(fid)) < 0) {
|
||||
if ((fcpl = H5Fget_create_plist(fid)) < 0) {
|
||||
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
|
||||
}
|
||||
|
||||
if(H5Pget_userblock(fcpl, &ub_size) < 0) {
|
||||
if (H5Pget_userblock(fcpl, &ub_size) < 0) {
|
||||
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size");
|
||||
}
|
||||
|
||||
if(H5Pclose(fcpl) < 0) {
|
||||
if (H5Pclose(fcpl) < 0) {
|
||||
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed to close property list");
|
||||
}
|
||||
|
||||
/* open file */
|
||||
if((fh = HDopen(filename, O_RDONLY)) < 0) {
|
||||
if ((fh = HDopen(filename, O_RDONLY)) < 0) {
|
||||
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed to open file <%s>", filename);
|
||||
}
|
||||
|
||||
size = ub_size;
|
||||
|
||||
/* read file */
|
||||
while(size > 0) {
|
||||
while (size > 0) {
|
||||
ssize_t nread; /* # of bytes read */
|
||||
char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */
|
||||
|
||||
/* read buffer */
|
||||
if(size > USERBLOCK_XFER_SIZE)
|
||||
if (size > USERBLOCK_XFER_SIZE)
|
||||
nread = HDread(fh, rbuf, (size_t)USERBLOCK_XFER_SIZE);
|
||||
else
|
||||
nread = HDread(fh, rbuf, (size_t)size);
|
||||
|
||||
for(i = 0; i < nread; i++) {
|
||||
for (i = 0; i < nread; i++) {
|
||||
|
||||
printf("%c ", rbuf[i]);
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if(nread < 0) {
|
||||
if (nread < 0) {
|
||||
HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0");
|
||||
}
|
||||
|
||||
@ -1488,7 +1493,7 @@ print_user_block(const char *filename, hid_t fid)
|
||||
}
|
||||
|
||||
done:
|
||||
if(fh > 0)
|
||||
if (fh > 0)
|
||||
HDclose(fh);
|
||||
|
||||
return;
|
||||
|
@ -145,7 +145,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
|
||||
hid_t refobj_id;
|
||||
hid_t refobj_id = -1;
|
||||
hobj_ref_t *refbuf = NULL; /* buffer for object references */
|
||||
hobj_ref_t *buf = NULL;
|
||||
const char* refname;
|
||||
@ -221,7 +221,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
|
||||
hid_t refobj_id;
|
||||
hid_t refobj_id = -1;
|
||||
hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
|
||||
hdset_reg_ref_t *buf = NULL; /* output buffer */
|
||||
const char* refname;
|
||||
@ -260,7 +260,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
* in the second traversal of the file
|
||||
*/
|
||||
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
|
||||
hid_t region_id; /* region id of the referenced dataset */
|
||||
hid_t region_id = -1; /* region id of the referenced dataset */
|
||||
|
||||
if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0)
|
||||
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed");
|
||||
@ -481,18 +481,16 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
is_ref = (type_class == H5T_REFERENCE);
|
||||
|
||||
if(type_class == H5T_VLEN ) {
|
||||
hid_t base_type;
|
||||
hid_t base_type = H5Tget_super(ftype_id);
|
||||
|
||||
base_type = H5Tget_super(ftype_id);
|
||||
is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE);
|
||||
msize = H5Tget_size(base_type);
|
||||
if (H5Tclose(base_type) < 0)
|
||||
H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
|
||||
}
|
||||
else if(type_class == H5T_ARRAY ) {
|
||||
hid_t base_type;
|
||||
hid_t base_type = H5Tget_super(ftype_id);
|
||||
|
||||
base_type = H5Tget_super(ftype_id);
|
||||
is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE);
|
||||
msize = H5Tget_size(base_type);
|
||||
if (H5Tclose(base_type) < 0)
|
||||
@ -573,9 +571,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
unsigned array_rank = 0;
|
||||
hsize_t array_size = 1;
|
||||
hsize_t array_dims[H5S_MAX_RANK];
|
||||
hid_t base_type;
|
||||
hid_t base_type = H5Tget_super(ftype_id);
|
||||
|
||||
base_type = H5Tget_super(ftype_id);
|
||||
msize = H5Tget_size(base_type);
|
||||
if (H5Tclose(base_type) < 0)
|
||||
H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed");
|
||||
|
Loading…
Reference in New Issue
Block a user