diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 17:43:14 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 17:43:14 (GMT) |
commit | 9d06256018fbebbefa08879ae9f16696a5bbef19 (patch) | |
tree | db84f4d812d122c8c9fafbcc4b828fc12cbf6a8e /tools/h5repack | |
parent | a4750dfae7e187f95c4515939968e6fce880efed (diff) | |
download | hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.zip hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.gz hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.bz2 |
[svn-r17987] Description:
Bring r17945:17986 from trunk to revise_chunks branch
(needs to have autotools files regenerated before testing, those will
be checked in in a few minutes)
Diffstat (limited to 'tools/h5repack')
-rw-r--r-- | tools/h5repack/h5repack.c | 22 | ||||
-rw-r--r-- | tools/h5repack/h5repack_opttable.c | 18 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 49 |
3 files changed, 57 insertions, 32 deletions
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index c8a3abe..addcea3 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -114,6 +114,7 @@ h5repack_init(pack_opt_t *options, int verbose, int latest, return (options_table_init(&(options->op_tbl))); } + /*------------------------------------------------------------------------- * Function: h5repack_end * @@ -127,6 +128,7 @@ int h5repack_end (pack_opt_t *options) return options_table_free(options->op_tbl); } + /*------------------------------------------------------------------------- * Function: h5repack_addfilter * @@ -137,7 +139,6 @@ int h5repack_end (pack_opt_t *options) * *------------------------------------------------------------------------- */ - int h5repack_addfilter(const char* str, pack_opt_t *options) { @@ -149,38 +150,33 @@ int h5repack_addfilter(const char* str, /* parse the -f option */ - obj_list=parse_filter(str,&n_objs,&filter,options,&is_glb); - if (obj_list==NULL) - { + if(NULL == (obj_list = parse_filter(str, &n_objs, &filter, options, &is_glb))) return -1; - } /* if it applies to all objects */ - if (is_glb) + if(is_glb) { - int n; n = options->n_filter_g++; /* increase # of global filters */ - if (options->n_filter_g > H5_REPACK_MAX_NFILTERS) + if(options->n_filter_g > H5_REPACK_MAX_NFILTERS) { - error_msg(progname, "maximum number of filters exceeded for <%s>\n",str); + error_msg(progname, "maximum number of filters exceeded for <%s>\n", str); + free(obj_list); return -1; - } options->filter_g[n] = filter; } - else - options_add_filter(obj_list,n_objs,filter,options->op_tbl); + options_add_filter(obj_list, n_objs, filter, options->op_tbl); free(obj_list); return 0; } - + /*------------------------------------------------------------------------- * Function: h5repack_addlayout * diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c index 5b6d5d0..7c87359 100644 --- a/tools/h5repack/h5repack_opttable.c +++ b/tools/h5repack/h5repack_opttable.c @@ -136,6 +136,7 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs ) return 0; } + /*------------------------------------------------------------------------- * Function: options_table_init * @@ -145,33 +146,34 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs ) * *------------------------------------------------------------------------- */ - int options_table_init( pack_opttbl_t **tbl ) { unsigned int i; - pack_opttbl_t* table = (pack_opttbl_t*) malloc(sizeof(pack_opttbl_t)); - if (table==NULL) { + pack_opttbl_t *table; + + if(NULL == (table = (pack_opttbl_t *)malloc(sizeof(pack_opttbl_t)))) + { error_msg(progname, "not enough memory for options table\n"); return -1; } table->size = 30; table->nelems = 0; - table->objs = (pack_info_t*) malloc(table->size * sizeof(pack_info_t)); - if (table->objs==NULL) { + if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t)))) + { error_msg(progname, "not enough memory for options table\n"); + free(table); return -1; } - for ( i=0; i<table->size; i++) - { + for(i = 0; i < table->size; i++) init_packobject(&table->objs[i]); - } *tbl = table; return 0; } + /*------------------------------------------------------------------------- * Function: options_table_free * diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index adaef43..aad3df4 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -4105,6 +4105,7 @@ int make_dset_reg_ref(hid_t loc_id) hdset_reg_ref_t *wbuf=NULL; /* buffer to write to disk */ int *dwbuf=NULL; /* Buffer for writing numeric data to disk */ int i; /* counting variables */ + int retval = -1; /* return value */ /* Allocate write & read buffers */ wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); @@ -4160,24 +4161,23 @@ int make_dset_reg_ref(hid_t loc_id) if (H5Dclose(did2) < 0) goto out; - if (wbuf) + retval = 0; + +out: + if(wbuf) free(wbuf); - if (dwbuf) + if(dwbuf) free(dwbuf); - return 0; - -out: H5E_BEGIN_TRY { - H5Sclose(sid1); H5Sclose(sid2); H5Dclose(did1); H5Dclose(did2); - } H5E_END_TRY; - return -1; + + return retval; } /*------------------------------------------------------------------------- @@ -4211,9 +4211,9 @@ int write_attr_in(hid_t loc_id, GREEN } e_t; - hid_t aid; - hid_t sid; - hid_t tid; + hid_t aid = -1; + hid_t sid = -1; + hid_t tid = -1; int val, i, j, k, n; float f; @@ -4295,6 +4295,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_BITFIELD @@ -4324,6 +4325,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_OPAQUE @@ -4350,6 +4352,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_COMPOUND @@ -4387,6 +4390,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_REFERENCE @@ -4435,6 +4439,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_VLEN @@ -4479,10 +4484,13 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; + aid = -1; if (H5Tclose(tid) < 0) goto out; + tid = -1; if (H5Sclose(sid) < 0) goto out; + sid = -1; /*------------------------------------------------------------------------- * H5T_ARRAY @@ -4517,6 +4525,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT @@ -4594,6 +4603,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_BITFIELD @@ -4626,6 +4636,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_OPAQUE @@ -4653,6 +4664,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_COMPOUND @@ -4688,6 +4700,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_REFERENCE @@ -4742,6 +4755,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_VLEN @@ -4791,10 +4805,13 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; + aid = -1; if (H5Tclose(tid) < 0) goto out; + tid = -1; if (H5Sclose(sid) < 0) goto out; + sid = -1; /*------------------------------------------------------------------------- * H5T_ARRAY @@ -4837,6 +4854,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT @@ -4956,6 +4974,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_BITFIELD @@ -5010,6 +5029,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_OPAQUE @@ -5023,6 +5043,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_COMPOUND @@ -5113,6 +5134,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_REFERENCE @@ -5197,6 +5219,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_VLEN @@ -5251,10 +5274,13 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Aclose(aid) < 0) goto out; + aid = -1; if (H5Tclose(tid) < 0) goto out; + tid = -1; if (H5Sclose(sid) < 0) goto out; + sid = -1; /*------------------------------------------------------------------------- * H5T_ARRAY @@ -5288,6 +5314,7 @@ int write_attr_in(hid_t loc_id, goto out; if (H5Tclose(tid) < 0) goto out; + tid = -1; /*------------------------------------------------------------------------- * H5T_INTEGER and H5T_FLOAT |