[svn-r7833] Purpose:

bug fix, clean code

Description:
a malloced buffer was not release
cleaned some compiler warnings


Platforms tested:
linux
solaris 2.7
IRIX

Misc. update:
This commit is contained in:
Pedro Vicente Nunes 2003-11-10 15:59:32 -05:00
parent 823619b1f8
commit b00b2d31e7
10 changed files with 58 additions and 33 deletions

View File

@ -42,8 +42,8 @@ static void print_options(pack_opt_t *options);
*
*-------------------------------------------------------------------------
*/
int h5repack(char* infile,
char* outfile,
int h5repack(const char* infile,
const char* outfile,
pack_opt_t *options)
{
options->trip=0;
@ -113,7 +113,7 @@ int h5repack_end (pack_opt_t *options)
*-------------------------------------------------------------------------
*/
int h5repack_addcomp(char* str,
int h5repack_addcomp(const char* str,
pack_opt_t *options)
{
obj_list_t *obj_list=NULL; /*one object list for the -t and -c option entry */
@ -128,6 +128,8 @@ int h5repack_addcomp(char* str,
/* parse the -t option */
obj_list=parse_comp(str,&n_objs,&comp);
if (obj_list==NULL)
return -1;
/* searh for the "*" all objects character */
for (i = 0; i < n_objs; i++)
@ -150,6 +152,8 @@ int h5repack_addcomp(char* str,
if (options->all_comp==0)
options_add_comp(obj_list,n_objs,comp,options->op_tbl);
free(obj_list);
return 0;
}
@ -166,7 +170,7 @@ int h5repack_addcomp(char* str,
*/
int h5repack_addchunk(char* str,
int h5repack_addchunk(const char* str,
pack_opt_t *options)
{
@ -183,6 +187,8 @@ int h5repack_addchunk(char* str,
/* parse the -c option */
obj_list=parse_chunk(str,&n_objs,chunk_lengths,&chunk_rank);
if (obj_list==NULL)
return -1;
/* searh for the "*" all objects character */
for (i = 0; i < n_objs; i++)
@ -339,7 +345,7 @@ void print_options(pack_opt_t *options)
*-------------------------------------------------------------------------
*/
void read_info(char *filename,
void read_info(const char *filename,
pack_opt_t *options)
{
char stype[10];

View File

@ -101,9 +101,9 @@ typedef struct {
extern "C" {
#endif
int h5repack (char* infile, char* outfile, pack_opt_t *options);
int h5repack_addcomp (char* str, pack_opt_t *options);
int h5repack_addchunk(char* str, pack_opt_t *options);
int h5repack (const char* infile, const char* outfile, pack_opt_t *options);
int h5repack_addcomp (const char* str, pack_opt_t *options);
int h5repack_addchunk(const char* str, pack_opt_t *options);
int h5repack_init (pack_opt_t *options, int verbose);
int h5repack_end (pack_opt_t *options);
@ -117,7 +117,7 @@ int h5repack_end (pack_opt_t *options);
*/
void read_info(char *filename,pack_opt_t *options);
void read_info(const char *filename,pack_opt_t *options);

View File

@ -37,7 +37,8 @@
*/
int get_objlist(char* fname, pack_opt_t *options)
int get_objlist(const char* fname,
pack_opt_t *options)
{
hid_t fid;
int nobjects, i;
@ -139,8 +140,8 @@ int get_objlist(char* fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
int copy_file(char* fnamein,
char* fnameout,
int copy_file(const char* fnamein,
const char* fnameout,
pack_opt_t *options)
{
hid_t fidin;
@ -231,7 +232,7 @@ int copy_file(char* fnamein,
*
*-------------------------------------------------------------------------
*/
void print_objlist(char *filename,
void print_objlist(const char *filename,
int nobjects,
trav_info_t *info )
{

View File

@ -27,14 +27,14 @@
*/
int get_objlist(char* infname,
int get_objlist(const char* infname,
pack_opt_t *options);
int copy_file(char* fnamein,
char* fnameout,
int copy_file(const char* fnamein,
const char* fnameout,
pack_opt_t *options);
void print_objlist(char *filename,
void print_objlist(const char *filename,
int nobjects,
trav_info_t *info );

View File

@ -272,7 +272,7 @@ int options_add_comp( obj_list_t *obj_list,
*-------------------------------------------------------------------------
*/
pack_info_t* options_get_object( char *path,
pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table )
{
int i;

View File

@ -36,7 +36,7 @@ int options_add_comp ( obj_list_t *obj_list,
int n_objs,
comp_info_t comp,
pack_opttbl_t *table );
pack_info_t* options_get_object( char *path,
pack_info_t* options_get_object( const char *path,
pack_opttbl_t *table);

View File

@ -25,10 +25,11 @@
* Purpose: read compression info
*
* Return: a list of names, the number of names and its compression type
* NULL, on error
*
* Examples:
* "AA,B,CDE:RLE"
* "*:GZIP 6"
* "GZIP 6"
* "A,B:NONE"
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
@ -39,7 +40,9 @@
*/
obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
obj_list_t* parse_comp(const char *str,
int *n_objs,
comp_info_t *comp)
{
unsigned i, u;
char c;
@ -74,6 +77,11 @@ obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
n++;
obj_list=malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
printf("Could not alloc object list\n");
return NULL;
}
*n_objs=n;
/* get object list */
@ -114,6 +122,7 @@ obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp)
for ( m=0,u=i+1; u<len; u++,m++) {
c = str[u];
if (!isdigit(c)){
if (obj_list) free(obj_list);
printf("Input Error: Compression parameter not digit in <%s>\n",str);
exit(1);
}
@ -221,10 +230,11 @@ char* get_scomp(int code)
* Purpose: read chunkink info
*
* Return: a list of names, the number of names and its chunking info
* NULL, on error
*
* Examples:
* "AA,B,CDE:10X10
* "*:10X10"
* "10X10"
*
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
@ -234,7 +244,7 @@ char* get_scomp(int code)
*/
obj_list_t* parse_chunk(char *str,
obj_list_t* parse_chunk(const char *str,
int *n_objs,
hsize_t *chunk_lengths,
int *chunk_rank)
@ -268,6 +278,11 @@ obj_list_t* parse_chunk(char *str,
n++;
obj_list=malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
printf("Could not alloc object list\n");
return NULL;
}
*n_objs=n;
/* get object list */

View File

@ -25,10 +25,15 @@
*-------------------------------------------------------------------------
*/
obj_list_t* parse_comp (const char *str,
int *n_objs,
comp_info_t *comp);
obj_list_t* parse_chunk (const char *str,
int *n_objs,
hsize_t *chunk_lengths,
int *chunk_rank);
char* get_scomp (int code);
int parse_number(char *str);
obj_list_t* parse_comp(char *str, int *n_objs, comp_info_t *comp);
char* get_scomp(int code);
obj_list_t* parse_chunk(char *str, int *n_objs, hsize_t *chunk_lengths, int *chunk_rank);
#endif /* H5REPACK_PARSE_H__ */

View File

@ -41,7 +41,7 @@ make_deflate(hid_t fid)
int rank=2;
hsize_t dims[2]={4,2};
hsize_t chunk_dims[2]={2,1};
int buf[4][2]={1,2,3,4,5,6,7,8};
int buf[4][2]={{1,2},{3,4},{5,6},{7,8}};
/* create a space */
if((sid = H5Screate_simple(rank, dims, NULL))<0)
@ -103,7 +103,7 @@ make_szip(hid_t fid)
int rank=2;
hsize_t dims[2]={4,2};
hsize_t chunk_dims[2]={2,1};
int buf[4][2]={1,2,3,4,5,6,7,8};
int buf[4][2]={{1,2},{3,4},{5,6},{7,8}};
unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK;
unsigned szip_pixels_per_block;
@ -177,9 +177,7 @@ int make_dsets()
TEST_ERROR;
nerrors += make_deflate(fid);
#if 1
nerrors += make_szip(fid);
#endif
/* close */
if(H5Fclose(fid)<0)

View File

@ -18,9 +18,6 @@
#include "h5diff.h"
#include "test_h5repack_add.h"
/*-------------------------------------------------------------------------
* Function: test
*
@ -48,6 +45,9 @@ test()
diff_opt_t diff_options;
memset(&diff_options, 0, sizeof (diff_opt_t));
/* compare attributes in h5diff */
diff_options.attr=1;
TESTING(" deflate filter");
if (h5repack_init (&pack_options, 0)<0)