summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2012-02-23 19:08:09 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2012-02-23 19:08:09 (GMT)
commit0b4463911f951713d00b9c82f98773f147b6c73b (patch)
treec764d5d707278c88c709488aeb9046abafee69b4 /tools/h5repack
parent9974e02bc07585de4fdfc1f0b2803a7370e37b4e (diff)
downloadhdf5-0b4463911f951713d00b9c82f98773f147b6c73b.zip
hdf5-0b4463911f951713d00b9c82f98773f147b6c73b.tar.gz
hdf5-0b4463911f951713d00b9c82f98773f147b6c73b.tar.bz2
[svn-r21974] Update HSIZE_T print statements to use correct macro.
Fix some more HD prefix issues in tools. Tested: local linux
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/h5repack.c38
-rw-r--r--tools/h5repack/h5repack_copy.c88
-rw-r--r--tools/h5repack/h5repack_filters.c6
-rw-r--r--tools/h5repack/h5repack_opttable.c6
-rw-r--r--tools/h5repack/h5repack_parse.c52
-rw-r--r--tools/h5repack/h5repack_refs.c248
-rw-r--r--tools/h5repack/h5repacktst.c80
7 files changed, 259 insertions, 259 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index a5fb47f..3b00327 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -90,7 +90,7 @@ int
h5repack_init(pack_opt_t *options, int verbose, H5F_file_space_type_t strategy, hsize_t threshold)
{
int k, n;
- memset(options,0,sizeof(pack_opt_t));
+ HDmemset(options,0,sizeof(pack_opt_t));
options->min_comp = 1024;
options->verbose = verbose;
@@ -157,7 +157,7 @@ int h5repack_addfilter(const char* str,
if(options->n_filter_g > H5_REPACK_MAX_NFILTERS)
{
error_msg("maximum number of filters exceeded for <%s>\n", str);
- free(obj_list);
+ HDfree(obj_list);
return -1;
}
@@ -166,7 +166,7 @@ int h5repack_addfilter(const char* str,
else
options_add_filter(obj_list, n_objs, filter, options->op_tbl);
- free(obj_list);
+ HDfree(obj_list);
return 0;
}
@@ -232,7 +232,7 @@ int h5repack_addlayout(const char* str,
&pack,
options->op_tbl);
- free(obj_list);
+ HDfree(obj_list);
return 0;
}
@@ -493,24 +493,24 @@ int copy_attr(hid_t loc_in,
type_class = H5Tget_class(wtype_id);
is_ref = (type_class == H5T_REFERENCE);
if (type_class == H5T_VLEN ||type_class == H5T_ARRAY ) {
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- is_ref = (is_ref || (H5Tget_class(base_type)==H5T_REFERENCE));
- H5Tclose(base_type);
+ hid_t base_type = -1;
+ base_type = H5Tget_super(ftype_id);
+ is_ref = (is_ref || (H5Tget_class(base_type)==H5T_REFERENCE));
+ H5Tclose(base_type);
}
if (type_class == H5T_COMPOUND) {
- int nmembers = H5Tget_nmembers(wtype_id) ;
- for (j=0; j<nmembers; j++) {
- hid_t mtid = H5Tget_member_type( wtype_id, j );
- H5T_class_t mtclass = H5Tget_class(mtid);
- H5Tclose(mtid);
-
- if (mtclass==H5T_REFERENCE) {
- is_ref = 1;
- break;
- }
- } /* for (j=0; i<nmembers; j++) */
+ int nmembers = H5Tget_nmembers(wtype_id) ;
+ for (j=0; j<nmembers; j++) {
+ hid_t mtid = H5Tget_member_type( wtype_id, j );
+ H5T_class_t mtclass = H5Tget_class(mtid);
+ H5Tclose(mtid);
+
+ if (mtclass==H5T_REFERENCE) {
+ is_ref = 1;
+ break;
+ }
+ } /* for (j=0; i<nmembers; j++) */
} /* if (type_class == H5T_COMPOUND) */
if(is_ref) {
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 8b2a1aa..d96e08b 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -131,23 +131,23 @@ int copy_objects(const char* fnamein,
goto out;
}
- if(!options->fs_strategy)
- {
- if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0)
- {
- error_msg("failed to retrieve file space strategy\n");
- goto out;
- }
- }
-
- if(!options->fs_threshold)
- {
- if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0)
- {
- error_msg("failed to retrieve file space threshold\n");
- goto out;
- }
- }
+ if(!options->fs_strategy)
+ {
+ if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0)
+ {
+ error_msg("failed to retrieve file space strategy\n");
+ goto out;
+ }
+ }
+
+ if(!options->fs_threshold)
+ {
+ if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0)
+ {
+ error_msg("failed to retrieve file space threshold\n");
+ goto out;
+ }
+ }
if(H5Pclose(fcpl_in) < 0)
{
@@ -348,28 +348,28 @@ int copy_objects(const char* fnamein,
/* either use the FCPL already created or create a new one */
if(fcpl != H5P_DEFAULT)
{
- /* set file space strategy and free space threshold */
- if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
- {
- error_msg("failed to set file space strategy & threshold\n");
- goto out;
- }
+ /* set file space strategy and free space threshold */
+ if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
+ {
+ error_msg("failed to set file space strategy & threshold\n");
+ goto out;
+ }
}
else
{
- /* create a file creation property list */
- if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
- {
- error_msg("fail to create a file creation property list\n");
- goto out;
- }
-
- /* set file space strategy and free space threshold */
- if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
- {
- error_msg("failed to set file space strategy & threshold \n");
- goto out;
- }
+ /* create a file creation property list */
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ {
+ error_msg("fail to create a file creation property list\n");
+ goto out;
+ }
+
+ /* set file space strategy and free space threshold */
+ if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
+ {
+ error_msg("failed to set file space strategy & threshold \n");
+ goto out;
+ }
}
/*-------------------------------------------------------------------------
@@ -618,7 +618,7 @@ int do_copy_objects(hid_t fidin,
{
case H5TRAV_TYPE_UNKNOWN:
- assert(0);
+ HDassert(0);
break;
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_GROUP
@@ -921,7 +921,7 @@ int do_copy_objects(hid_t fidin,
size = 1;
sm_size[k - 1] = MIN(dims[k - 1], size);
sm_nbytes *= sm_size[k - 1];
- assert(sm_nbytes > 0);
+ HDassert(sm_nbytes > 0);
}
sm_buf = HDmalloc((size_t)sm_nbytes);
@@ -929,8 +929,8 @@ int do_copy_objects(hid_t fidin,
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
/* the stripmine loop */
- memset(hs_offset, 0, sizeof hs_offset);
- memset(zero, 0, sizeof zero);
+ HDmemset(hs_offset, 0, sizeof hs_offset);
+ HDmemset(zero, 0, sizeof zero);
for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts)
{
@@ -1345,7 +1345,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
int status = 0; /* Return value */
/* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */
- assert(size > 0);
+ HDassert(size > 0);
/* Open files */
if((infid = HDopen(infile, O_RDONLY, 0)) < 0) {
@@ -1387,13 +1387,13 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size)
status = -1;
goto done;
} /* end if */
- assert(nwritten > 0);
- assert(nwritten <= nbytes);
+ HDassert(nwritten > 0);
+ HDassert(nwritten <= nbytes);
/* Update # of bytes left & offset in buffer */
nbytes -= nwritten;
wbuf += nwritten;
- assert(nbytes == 0 || wbuf < (rbuf + USERBLOCK_XFER_SIZE));
+ HDassert(nbytes == 0 || wbuf < (rbuf + USERBLOCK_XFER_SIZE));
} /* end while */
/* Update size of userblock left to transfer */
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index 7072d2d..6c7bc65 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -19,12 +19,12 @@
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
#endif
/* minimum of two values */
#undef MIN
-#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#define MIN(a,b) (((a)<(b)) ? (a) : (b))
/*-------------------------------------------------------------------------
* Function: aux_find_obj
@@ -330,7 +330,7 @@ int apply_filters(const char* name, /* object name from traverse list */
size = 1;
sm_size[i - 1] = MIN(dims[i - 1], size);
sm_nbytes *= sm_size[i - 1];
- assert(sm_nbytes > 0);
+ HDassert(sm_nbytes > 0);
}
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 57b5fa7..01ee018 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -158,7 +158,7 @@ int options_table_init( pack_opttbl_t **tbl )
if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t))))
{
error_msg("not enough memory for options table\n");
- free(table);
+ HDfree(table);
return -1;
}
@@ -182,8 +182,8 @@ int options_table_init( pack_opttbl_t **tbl )
int options_table_free( pack_opttbl_t *table )
{
- free(table->objs);
- free(table);
+ HDfree(table->objs);
+ HDfree(table);
return 0;
}
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index d3c6014..5258c4e 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -63,7 +63,7 @@ obj_list_t* parse_filter(const char *str,
/* initialize compression info */
- memset(filt,0,sizeof(filter_info_t));
+ HDmemset(filt,0,sizeof(filter_info_t));
*is_glb = 0;
/* check for the end of object list and number of objects */
@@ -105,7 +105,7 @@ obj_list_t* parse_filter(const char *str,
{
if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
HDstrcpy(obj_list[n].obj,sobj);
- memset(sobj,0,sizeof(sobj));
+ HDmemset(sobj,0,sizeof(sobj));
n++;
k=-1;
}
@@ -113,7 +113,7 @@ obj_list_t* parse_filter(const char *str,
/* nothing after : */
if (end_obj+1==(int)len)
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("input Error: Invalid compression type in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -151,7 +151,7 @@ obj_list_t* parse_filter(const char *str,
}
c = str[u];
if (!isdigit(c) && l==-1){
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("compression parameter not digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -211,7 +211,7 @@ obj_list_t* parse_filter(const char *str,
}
c = str[u];
if (!isdigit(c) && l==-1){
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -255,7 +255,7 @@ obj_list_t* parse_filter(const char *str,
{
c = str[u];
if (!isdigit(c)){
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -301,7 +301,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 1;
if (no_param)
{ /*no more parameters, GZIP must have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -317,7 +317,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 2;
if (no_param)
{ /*no more parameters, SZIP must have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -333,7 +333,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 0;
if (m>0)
{ /*shuffle does not have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("extra parameter in SHUF <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -348,7 +348,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 0;
if (m>0)
{ /*shuffle does not have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("extra parameter in FLET <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -363,7 +363,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 0;
if (m>0)
{ /*nbit does not have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("extra parameter in NBIT <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -378,13 +378,13 @@ obj_list_t* parse_filter(const char *str,
filt->cd_nelmts = 2;
if (no_param)
{ /*no more parameters, SOFF must have parameter */
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
else {
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("invalid filter type in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -407,7 +407,7 @@ obj_list_t* parse_filter(const char *str,
case H5Z_FILTER_DEFLATE:
if (filt->cd_values[0]>9 )
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("invalid compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -422,19 +422,19 @@ obj_list_t* parse_filter(const char *str,
pixels_per_block=filt->cd_values[0];
if ((pixels_per_block%2)==1)
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("pixels_per_block is not even in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("pixels_per_block is too large in <%s>\n",str);
exit(EXIT_FAILURE);
}
if ( (HDstrcmp(smask,"NN")!=0) && (HDstrcmp(smask,"EC")!=0) )
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("szip mask must be 'NN' or 'EC' \n");
exit(EXIT_FAILURE);
}
@@ -486,9 +486,9 @@ obj_list_t* parse_layout(const char *str,
char slayout[10];
- memset(sdim, '\0', sizeof(sdim));
- memset(sobj, '\0', sizeof(sobj));
- memset(slayout, '\0', sizeof(slayout));
+ HDmemset(sdim, '\0', sizeof(sdim));
+ HDmemset(sobj, '\0', sizeof(sobj));
+ HDmemset(slayout, '\0', sizeof(slayout));
/* check for the end of object list and number of objects */
for ( i=0, n=0; i<len; i++)
@@ -526,7 +526,7 @@ obj_list_t* parse_layout(const char *str,
{
if ( c==',') sobj[k]='\0'; else sobj[k+1]='\0';
HDstrcpy(obj_list[n].obj,sobj);
- memset(sobj,0,sizeof(sobj));
+ HDmemset(sobj,0,sizeof(sobj));
n++;
k=-1;
}
@@ -535,7 +535,7 @@ obj_list_t* parse_layout(const char *str,
/* nothing after : */
if (end_obj+1==(int)len)
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("in parse layout, no characters after : in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -576,7 +576,7 @@ obj_list_t* parse_layout(const char *str,
if (j>(int)len)
{
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> Chunk dimensions missing\n",str);
exit(EXIT_FAILURE);
}
@@ -590,7 +590,7 @@ obj_list_t* parse_layout(const char *str,
if (!isdigit(c) && c!='x'
&& c!='N' && c!='O' && c!='N' && c!='E'
){
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> Not a valid character in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
@@ -603,7 +603,7 @@ obj_list_t* parse_layout(const char *str,
k=0;
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0) {
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
@@ -621,7 +621,7 @@ obj_list_t* parse_layout(const char *str,
{
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0){
- if (obj_list) free(obj_list);
+ if (obj_list) HDfree(obj_list);
error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c
index 5c292c7..915b0e9 100644
--- a/tools/h5repack/h5repack_refs.c
+++ b/tools/h5repack/h5repack_refs.c
@@ -28,7 +28,7 @@ static const char* MapIdToName(hid_t refobj_id,trav_table_t *travt);
static int copy_refs_attr(hid_t loc_in, hid_t loc_out, pack_opt_t *options,
trav_table_t *travt, hid_t fidout);
static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
- hid_t fid_out, void *ref_out, trav_table_t *travt);
+ hid_t fid_out, void *ref_out, trav_table_t *travt);
/*-------------------------------------------------------------------------
* Function: do_copy_refobjs
@@ -327,7 +327,7 @@ int do_copy_refobjs(hid_t fidin,
goto error;
} /* end else */
- assert(dset_out != FAIL);
+ HDassert(dset_out != FAIL);
/*-------------------------------------------------------------------------
* copy referenced objects in attributes
@@ -432,13 +432,13 @@ error:
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
* Modifier: xcao@hdfgroup.org, 9/12/2011
- * Update values of references(object and region) for the following types:
+ * Update values of references(object and region) for the following types:
* 1) References,
* 2) ARRAY of reference,
* 3) VLEN of references.
* 4) COMPOUND of references.
* This function does not handle references in other complicated structures,
- * such as references in nested compound datatypes.
+ * such as references in nested compound datatypes.
*
* Date: October, 28, 2003
*
@@ -479,7 +479,7 @@ static int copy_refs_attr(hid_t loc_in,
for(u = 0; u < (unsigned)oinfo.num_attrs; u++)
{
- is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
+ is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0;
/* open attribute */
if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -500,39 +500,39 @@ static int copy_refs_attr(hid_t loc_in,
is_ref = (type_class == H5T_REFERENCE);
if (type_class == H5T_VLEN ) {
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- is_ref_vlen = (H5Tget_class(base_type)==H5T_REFERENCE);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
+ hid_t base_type = -1;
+ base_type = H5Tget_super(ftype_id);
+ is_ref_vlen = (H5Tget_class(base_type)==H5T_REFERENCE);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
}
if (type_class == H5T_ARRAY ) {
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- is_ref_array = (H5Tget_class(base_type)==H5T_REFERENCE);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
+ hid_t base_type = -1;
+ base_type = H5Tget_super(ftype_id);
+ is_ref_array = (H5Tget_class(base_type)==H5T_REFERENCE);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
}
if (type_class == H5T_COMPOUND) {
- int nmembers = H5Tget_nmembers(ftype_id) ;
- if (nmembers < 1)
- goto error;
+ int nmembers = H5Tget_nmembers(ftype_id) ;
+ if (nmembers < 1)
+ goto error;
ref_comp_index = (int *)HDmalloc(nmembers*sizeof (int));
ref_comp_size = (size_t *)HDmalloc(nmembers*sizeof(ref_comp_size));
ref_comp_field_n = 0;
- for (i=0; i<(unsigned)nmembers; i++) {
- hid_t mtid = H5Tget_member_type( ftype_id, i );
- if ((H5Tget_class(mtid)==H5T_REFERENCE)) {
- ref_comp_index[ref_comp_field_n] = i;
- ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
- ref_comp_field_n++;
- }
- H5Tclose(mtid);
- }
+ for (i=0; i<(unsigned)nmembers; i++) {
+ hid_t mtid = H5Tget_member_type( ftype_id, i );
+ if ((H5Tget_class(mtid)==H5T_REFERENCE)) {
+ ref_comp_index[ref_comp_field_n] = i;
+ ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid);
+ ref_comp_field_n++;
+ }
+ H5Tclose(mtid);
+ }
/* if compound don't contain reference type member, free the above
* mallocs. Otherwise there can be memory leaks by the 'continue'
@@ -541,14 +541,14 @@ static int copy_refs_attr(hid_t loc_in,
{
if (ref_comp_index)
{
- HDfree(ref_comp_index);
- ref_comp_index = NULL;
+ HDfree(ref_comp_index);
+ ref_comp_index = NULL;
}
if (ref_comp_size)
{
- HDfree(ref_comp_size);
- ref_comp_size = NULL;
+ HDfree(ref_comp_size);
+ ref_comp_size = NULL;
}
}
}
@@ -556,10 +556,10 @@ static int copy_refs_attr(hid_t loc_in,
is_ref_comp = (ref_comp_field_n > 0);
if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) {
- H5Tclose(mtype_id);
- H5Tclose(ftype_id);
- H5Aclose(attr_id);
- continue;
+ H5Tclose(mtype_id);
+ H5Tclose(ftype_id);
+ H5Aclose(attr_id);
+ continue;
}
/* get name */
@@ -584,18 +584,18 @@ static int copy_refs_attr(hid_t loc_in,
nelmts *= dims[j];
if (is_ref_array) {
- unsigned array_rank = 0;
- hsize_t array_size = 1;
- hsize_t array_dims[H5S_MAX_RANK];
- hid_t base_type = -1;
- base_type = H5Tget_super(ftype_id);
- msize = H5Tget_size(base_type);
- H5Tclose(base_type);
-
- array_rank = H5Tget_array_ndims(mtype_id);
- H5Tget_array_dims2(mtype_id, array_dims);
+ unsigned array_rank = 0;
+ hsize_t array_size = 1;
+ hsize_t array_dims[H5S_MAX_RANK];
+ hid_t base_type = -1;
+ base_type = H5Tget_super(ftype_id);
+ msize = H5Tget_size(base_type);
+ H5Tclose(base_type);
+
+ array_rank = H5Tget_array_ndims(mtype_id);
+ H5Tget_array_dims2(mtype_id, array_dims);
for(j = 0; j <array_rank; j++)
- array_size *= array_dims[j];
+ array_size *= array_dims[j];
nelmts *= array_size;
}
@@ -626,7 +626,7 @@ static int copy_refs_attr(hid_t loc_in,
for(i = 0; i < (unsigned)nelmts; i++)
{
if (update_ref_value(attr_id, H5R_OBJECT, &((hobj_ref_t *)buf)[i], fidout, &((hobj_ref_t *)refbuf)[i], travt)<0)
- continue;
+ continue;
if(options->verbose)
printf("object <%s> reference created to <%s>\n", name, refname);
} /* k */
@@ -657,13 +657,13 @@ static int copy_refs_attr(hid_t loc_in,
for(i = 0; i < (unsigned)nelmts; i++)
{
if (update_ref_value(attr_id, H5R_DATASET_REGION, &((hdset_reg_ref_t *)buf)[i], fidout, &((hdset_reg_ref_t *)refbuf)[i], travt)<0)
- continue;
+ continue;
if(options->verbose)
printf("object <%s> region reference created to <%s>\n", name, refname);
}
} /* H5T_STD_REF_DSETREG */
else if (is_ref_vlen) {
- /* handle VLEN of references */
+ /* handle VLEN of references */
buf = (hvl_t *)HDmalloc((unsigned)(nelmts * sizeof(hvl_t)));
refbuf = buf; /* reuse the read buffer for write */
@@ -677,31 +677,31 @@ static int copy_refs_attr(hid_t loc_in,
if(H5Aread(attr_id, mtype_id, buf) < 0)
goto error;
- if (H5R_OBJ_REF_BUF_SIZE==msize) {
- hobj_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
- hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(&(ptr[j]), &ref_out, msize);
- }
- } /* for (i=0; i<nelems; i++) */
- } else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
-
- hdset_reg_ref_t ref_out;
- for (i=0; i<(unsigned)nelmts; i++) {
- hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
- for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
- if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(&(ptr[j]), &ref_out, msize);
- }
- } /* for (i=0; i<nelems; i++) */
- }
+ if (H5R_OBJ_REF_BUF_SIZE==msize) {
+ hobj_ref_t ref_out;
+ for (i=0; i<(unsigned)nelmts; i++) {
+ hobj_ref_t *ptr = (hobj_ref_t *)((hvl_t *)buf)[i].p;
+ for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
+ if (update_ref_value(attr_id, H5R_OBJECT, &(ptr[j]), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(&(ptr[j]), &ref_out, msize);
+ }
+ } /* for (i=0; i<nelems; i++) */
+ } else if (H5R_DSET_REG_REF_BUF_SIZE == msize) {
+
+ hdset_reg_ref_t ref_out;
+ for (i=0; i<(unsigned)nelmts; i++) {
+ hdset_reg_ref_t *ptr = (hdset_reg_ref_t *)((hvl_t *)buf)[i].p;
+ for (j=0; j<((hvl_t *)buf)[i].len; j++ ) {
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, &(ptr[j]), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(&(ptr[j]), &ref_out, msize);
+ }
+ } /* for (i=0; i<nelems; i++) */
+ }
} /* else if (is_ref_vlen) */
else if (is_ref_comp) {
- /* handle ref fields in a compound */
+ /* handle ref fields in a compound */
buf = HDmalloc((unsigned)(nelmts * msize));
refbuf = buf; /* reuse the read buffer for write */
@@ -716,22 +716,22 @@ static int copy_refs_attr(hid_t loc_in,
goto error;
for (i=0; i<(unsigned)nelmts; i++) {
- for (j=0; j<(unsigned)ref_comp_field_n; j++) {
- if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
- int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
- hobj_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
- } /* if */
- else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
- int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
- hdset_reg_ref_t ref_out;
- if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
- continue;
- HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
- } /* else if */
- } /* j */
+ for (j=0; j<(unsigned)ref_comp_field_n; j++) {
+ if (ref_comp_size[j] == H5R_OBJ_REF_BUF_SIZE) {
+ int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
+ hobj_ref_t ref_out;
+ if (update_ref_value(attr_id, H5R_OBJECT, (hobj_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ } /* if */
+ else if (ref_comp_size[j] == H5R_DSET_REG_REF_BUF_SIZE) {
+ int idx = i*msize+H5Tget_member_offset( mtype_id, (unsigned)ref_comp_index[j]);
+ hdset_reg_ref_t ref_out;
+ if (update_ref_value(attr_id, H5R_DATASET_REGION, (hdset_reg_ref_t *)(((char *)buf)+idx), fidout, &ref_out, travt)<0)
+ continue;
+ HDmemcpy(((char *)buf)+idx, &ref_out, ref_comp_size[j]);
+ } /* else if */
+ } /* j */
} /* i */
} /* else if (is_ref_comp) */
@@ -739,11 +739,11 @@ static int copy_refs_attr(hid_t loc_in,
goto error;
if (is_ref_vlen && buf)
- H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf);
+ H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf);
} /* if (nelmts) */
if (refbuf == buf)
- refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
+ refbuf = NULL; /* set it to NULL to avoid double free since buf and refbuf are the same. */
if(buf) {
HDfree(buf);
@@ -756,13 +756,13 @@ static int copy_refs_attr(hid_t loc_in,
}
if (ref_comp_index) {
- HDfree(ref_comp_index);
- ref_comp_index = NULL;
+ HDfree(ref_comp_index);
+ ref_comp_index = NULL;
}
if (ref_comp_size) {
- HDfree(ref_comp_size);
- ref_comp_size = NULL;
+ HDfree(ref_comp_size);
+ ref_comp_size = NULL;
}
if(H5Aclose(attr_out) < 0)
@@ -785,16 +785,16 @@ static int copy_refs_attr(hid_t loc_in,
return 0;
error:
- if(refbuf)
- HDfree(refbuf);
- if(buf)
- HDfree(buf);
+ if(refbuf)
+ HDfree(refbuf);
+ if(buf)
+ HDfree(buf);
if (ref_comp_index)
- HDfree(ref_comp_index);
+ HDfree(ref_comp_index);
if (ref_comp_size)
- HDfree(ref_comp_size);
+ HDfree(ref_comp_size);
H5E_BEGIN_TRY {
H5Tclose(ftype_id);
@@ -808,9 +808,9 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: MapIdToName
+ * Function: MapIdToName
*
- * Purpose: map a ID from a reference to a dataset name
+ * Purpose: map a ID from a reference to a dataset name
*
*-------------------------------------------------------------------------
*/
@@ -843,48 +843,48 @@ out:
}
/*-------------------------------------------------------------------------
- * Function: Update_Ref_value
+ * Function: Update_Ref_value
*
- * Purpose: Update a reference value
+ * Purpose: Update a reference value
*
* Programmer: xcao@hdfgroup.org 9/12/2011
*
*-------------------------------------------------------------------------
*/
static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in,
- hid_t fid_out, void *ref_out, trav_table_t *travt)
+ hid_t fid_out, void *ref_out, trav_table_t *travt)
{
- herr_t ret = -1;
- const char* ref_obj_name;
- hid_t space_id=-1, ref_obj_id=-1;
+ herr_t ret = -1;
+ const char* ref_obj_name;
+ hid_t space_id=-1, ref_obj_id=-1;
- ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in);
- if (ref_obj_id<0)
- goto done;
+ ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in);
+ if (ref_obj_id<0)
+ goto done;
- ref_obj_name = MapIdToName(ref_obj_id, travt);
- if (ref_obj_name == NULL)
- goto done;
+ ref_obj_name = MapIdToName(ref_obj_id, travt);
+ if (ref_obj_name == NULL)
+ goto done;
- if (ref_type == H5R_DATASET_REGION) {
- space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in);
- if (space_id < 0)
- goto done;
- }
+ if (ref_type == H5R_DATASET_REGION) {
+ space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in);
+ if (space_id < 0)
+ goto done;
+ }
ret = H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id);
if (ret < 0)
- goto done;
+ goto done;
- ret = 0;
+ ret = 0;
done:
H5E_BEGIN_TRY {
- H5Sclose(space_id);
- H5Oclose(ref_obj_id);
+ H5Sclose(space_id);
+ H5Oclose(ref_obj_id);
} H5E_END_TRY;
- return ret;
+ return ret;
}
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index d0974b6..156038c 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -170,15 +170,15 @@ int main (void)
{
pack_opt_t pack_options;
diff_opt_t diff_options;
- hsize_t fs_size = 0; /* free space section threshold */
- H5F_file_space_type_t fs_type = H5F_FILE_SPACE_DEFAULT; /* file space handling strategy */
+ hsize_t fs_size = 0; /* free space section threshold */
+ H5F_file_space_type_t fs_type = H5F_FILE_SPACE_DEFAULT; /* file space handling strategy */
#if defined (H5_HAVE_FILTER_SZIP)
int szip_can_encode = 0;
#endif
/* initialize */
- memset(&diff_options, 0, sizeof (diff_opt_t));
- memset(&pack_options, 0, sizeof (pack_opt_t));
+ HDmemset(&diff_options, 0, sizeof (diff_opt_t));
+ HDmemset(&pack_options, 0, sizeof (pack_opt_t));
/* run tests */
puts("Testing h5repack:");
@@ -938,7 +938,7 @@ int main (void)
#if defined (H5_HAVE_FILTER_SZIP)
if (szip_can_encode) {
- /* fs_type = H5F_FILE_SPACE_AGGR_VFD; fs_size = 3 */
+ /* fs_type = H5F_FILE_SPACE_AGGR_VFD; fs_size = 3 */
if (h5repack_init (&pack_options, 0, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0)
GOERROR;
if (h5repack(FNAME7,FNAME7OUT,&pack_options) < 0)
@@ -1255,7 +1255,7 @@ int main (void)
&& defined (H5_HAVE_FILTER_FLETCHER32) && defined (H5_HAVE_FILTER_SHUFFLE)
if (szip_can_encode) {
- /* fs_type = H5F_FILE_SPACE_VFD; fs_size = 4 */
+ /* fs_type = H5F_FILE_SPACE_VFD; fs_size = 4 */
if (h5repack_init (&pack_options, 0, H5_INC_ENUM(H5F_file_space_type_t, fs_type), ++fs_size) < 0)
GOERROR;
if (h5repack_addfilter("dset_deflate:SZIP=8,NN",&pack_options) < 0)
@@ -2956,31 +2956,31 @@ out:
*
* Purpose: create datasets with contiguous and chunked layouts:
*
- * contig_small: < 1k, fixed dims datspace
- * chunked_small_fixed: < 1k, fixed dims dataspace
+ * contig_small: < 1k, fixed dims datspace
+ * chunked_small_fixed: < 1k, fixed dims dataspace
*
*-------------------------------------------------------------------------
*/
-#define S_DIM1 4
-#define S_DIM2 10
-#define CONTIG_S "contig_small"
-#define CHUNKED_S_FIX "chunked_small_fixed"
+#define S_DIM1 4
+#define S_DIM2 10
+#define CONTIG_S "contig_small"
+#define CHUNKED_S_FIX "chunked_small_fixed"
static
int make_layout2(hid_t loc_id)
{
- hid_t contig_dcpl = -1; /* dataset creation property list */
+ hid_t contig_dcpl = -1; /* dataset creation property list */
hid_t chunked_dcpl = -1; /* dataset creation property list */
- int i, j, n; /* Local index variables */
- int ret_value = -1; /* Return value */
- hid_t s_sid = -1; /* dataspace ID */
+ int i, j, n; /* Local index variables */
+ int ret_value = -1; /* Return value */
+ hid_t s_sid = -1; /* dataspace ID */
- hsize_t s_dims[RANK] = {S_DIM1,S_DIM2}; /* Dataspace (< 1 k) */
- hsize_t chunk_dims[RANK] = {S_DIM1/2, S_DIM2/2}; /* Dimension sizes for chunks */
+ hsize_t s_dims[RANK] = {S_DIM1,S_DIM2}; /* Dataspace (< 1 k) */
+ hsize_t chunk_dims[RANK] = {S_DIM1/2, S_DIM2/2}; /* Dimension sizes for chunks */
- int s_buf[S_DIM1][S_DIM2]; /* Temporary buffer */
+ int s_buf[S_DIM1][S_DIM2]; /* Temporary buffer */
for(i = n = 0; i < S_DIM1; i++) {
for (j = 0; j < S_DIM2; j++) {
@@ -3130,7 +3130,7 @@ int make_big(hid_t loc_id)
if (H5Dwrite (did,H5T_NATIVE_SCHAR,m_sid,f_sid,H5P_DEFAULT,buf) < 0)
goto out;
- free(buf);
+ HDfree(buf);
buf=NULL;
/* close */
@@ -3171,8 +3171,8 @@ int make_external(hid_t loc_id)
hid_t sid=-1;
hid_t dcpl;
int buf[2]={1,2};
- hsize_t cur_size[1]; /* data space current size */
- hsize_t max_size[1]; /* data space maximum size */
+ hsize_t cur_size[1]; /* data space current size */
+ hsize_t max_size[1]; /* data space maximum size */
hsize_t size;
cur_size[0] = max_size[0] = 2;
@@ -3255,7 +3255,7 @@ make_userblock(void)
/* Write userblock data */
nwritten = HDwrite(fd, ub, (size_t)USERBLOCK_SIZE);
- assert(nwritten == USERBLOCK_SIZE);
+ HDassert(nwritten == USERBLOCK_SIZE);
/* Close file */
HDclose(fd);
@@ -3319,7 +3319,7 @@ verify_userblock( const char* filename)
/* Read userblock data */
nread = HDread(fd, ub, (size_t)USERBLOCK_SIZE);
- assert(nread == USERBLOCK_SIZE);
+ HDassert(nread == USERBLOCK_SIZE);
/* Verify userblock data */
for(u = 0; u < USERBLOCK_SIZE; u++)
@@ -3368,7 +3368,7 @@ make_userblock_file(void)
/* write userblock data */
nwritten = HDwrite(fd, ub, (size_t)USERBLOCK_SIZE);
- assert(nwritten == USERBLOCK_SIZE);
+ HDassert(nwritten == USERBLOCK_SIZE);
/* close file */
HDclose(fd);
@@ -3693,7 +3693,7 @@ int write_dset_in(hid_t loc_id,
H5Dclose(did);
H5Tclose(tid);
H5Sclose(sid);
- free( dbuf );
+ HDfree( dbuf );
}
/*-------------------------------------------------------------------------
@@ -3728,7 +3728,7 @@ int write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf12, 'z', sizeof buf12);
+ HDmemset(buf12, 'z', sizeof buf12);
}
@@ -3749,7 +3749,7 @@ int write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf22,0,sizeof buf22);
+ HDmemset(buf22,0,sizeof buf22);
}
if ((tid = H5Tcopy(H5T_STD_B8LE)) < 0)
@@ -3779,7 +3779,7 @@ int write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf32,0,sizeof buf32);
+ HDmemset(buf32,0,sizeof buf32);
}
if ((tid = H5Tcreate (H5T_COMPOUND, sizeof(s_t))) < 0)
@@ -3871,7 +3871,7 @@ int write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf62,0,sizeof buf62);
+ HDmemset(buf62,0,sizeof buf62);
}
@@ -3889,8 +3889,8 @@ int write_dset_in(hid_t loc_id,
if(make_diffs) {
- memset(buf72, 0, sizeof buf72);
- memset(buf82, 0, sizeof buf82);
+ HDmemset(buf72, 0, sizeof buf72);
+ HDmemset(buf82, 0, sizeof buf82);
}
@@ -3930,7 +3930,7 @@ int write_dset_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf13,'z',sizeof buf13);
+ HDmemset(buf13,'z',sizeof buf13);
}
if ((tid = H5Tcopy(H5T_C_S1)) < 0)
@@ -4243,9 +4243,9 @@ int make_dset_reg_ref(hid_t loc_id)
out:
if(wbuf)
- free(wbuf);
+ HDfree(wbuf);
if(dwbuf)
- free(dwbuf);
+ HDfree(dwbuf);
H5E_BEGIN_TRY
{
@@ -4650,7 +4650,7 @@ int write_attr_in(hid_t loc_id,
*/
if (make_diffs)
{
- memset(buf12, 'z', sizeof buf12);
+ HDmemset(buf12, 'z', sizeof buf12);
}
/*
@@ -4690,7 +4690,7 @@ int write_attr_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf22,0,sizeof buf22);
+ HDmemset(buf22,0,sizeof buf22);
}
/*
@@ -4750,7 +4750,7 @@ int write_attr_in(hid_t loc_id,
*/
if (make_diffs)
{
- memset(buf32,0,sizeof buf32);
+ HDmemset(buf32,0,sizeof buf32);
}
/*
@@ -4898,7 +4898,7 @@ int write_attr_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf62,0,sizeof buf62);
+ HDmemset(buf62,0,sizeof buf62);
}
/*
buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}};
@@ -4984,7 +4984,7 @@ int write_attr_in(hid_t loc_id,
if (make_diffs)
{
- memset(buf13,'z',sizeof buf13);
+ HDmemset(buf13,'z',sizeof buf13);
}
/*