From bddc59c0ead7bc5e6cf5cc832a8281580c9e1208 Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Thu, 12 Oct 2000 17:52:28 -0500 Subject: [svn-r2675] Purpose: fix "zero memory" routine and change dimensional scale name size to MAX_DIM_NAME Description: change bzero into h4toh5_ZeroMemory change dimensional scale name size(orginally MAX_NC_NAME) to MAX_DIM_NAME at converter. Solution: see description Platforms tested: arabica,baldric,gondolin(DEC),opus(HP 11),eirene(Linux),paz(IRIX6.5) --- tools/h4toh5anno.c | 8 ++++---- tools/h4toh5main.c | 12 ++++++------ tools/h4toh5sds.c | 33 +++++++++++++++++---------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/tools/h4toh5anno.c b/tools/h4toh5anno.c index 6f11594..199d5f1 100644 --- a/tools/h4toh5anno.c +++ b/tools/h4toh5anno.c @@ -79,7 +79,7 @@ int Annofil_h4_to_h5(int32 file_id,hid_t h5group){ printf("error in allocating memory. \n"); return FAIL; } - bzero(ann_buf,(ann_length+1)*sizeof(char)); + h4toh5_ZeroMemory(ann_buf,(ann_length+1)*sizeof(char)); istat = ANreadann(ann_id,ann_buf,ann_length+1); if(istat==FAIL) { @@ -176,7 +176,7 @@ int Annofil_h4_to_h5(int32 file_id,hid_t h5group){ ANendaccess(ann_id); return FAIL; } - bzero(ann_buf,ann_length+1); + h4toh5_ZeroMemory(ann_buf,ann_length+1); istat = ANreadann(ann_id,ann_buf,ann_length+1); @@ -357,7 +357,7 @@ int Annoobj_h4_to_h5(int32 file_id,int32 obj_ref, int32 obj_tag, ANend(an_id); return FAIL; } - bzero(ann_buf,(ann_length+1)*sizeof(char)); + h4toh5_ZeroMemory(ann_buf,(ann_length+1)*sizeof(char)); status = ANreadann(ann_id,ann_buf,ann_length+1); if(status == FAIL) { printf("error in reading data.\n"); @@ -466,7 +466,7 @@ int Annoobj_h4_to_h5(int32 file_id,int32 obj_ref, int32 obj_tag, return FAIL; } - bzero(ann_buf,(ann_length+1)*sizeof(char)); + h4toh5_ZeroMemory(ann_buf,(ann_length+1)*sizeof(char)); ANreadann(ann_id,ann_buf,ann_length+1); if ((sh5str_type = mkstr(ann_length+1,H5T_STR_NULLTERM))<0) { diff --git a/tools/h4toh5main.c b/tools/h4toh5main.c index ca8d7fd..0947bb8 100644 --- a/tools/h4toh5main.c +++ b/tools/h4toh5main.c @@ -705,7 +705,7 @@ int h4toh5lonevgs(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5 } /*obtain group name and class name.*/ - bzero(vgroup_class,VGNAMELENMAX); + h4toh5_ZeroMemory(vgroup_class,VGNAMELENMAX); istat = Vgetclass(vgroup_id,vgroup_class); if(istat == FAIL) { printf("error in getting vgroup class.\n"); @@ -714,7 +714,7 @@ int h4toh5lonevgs(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5 return FAIL; } - bzero(vgroup_name,VGNAMELENMAX); + h4toh5_ZeroMemory(vgroup_name,VGNAMELENMAX); istat = Vgetname(vgroup_id,vgroup_name); if(istat == FAIL ) { printf("error in getting vgroup name. \n"); @@ -863,7 +863,7 @@ int h4toh5vgrings(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5 return FAIL; } - bzero(vgroup_name,VGNAMELENMAX); + h4toh5_ZeroMemory(vgroup_name,VGNAMELENMAX); istat = Vgetname(vgroup_id,vgroup_name); if(istat ==FAIL) { printf("error in obtaining vgroup names. \n"); @@ -871,7 +871,7 @@ int h4toh5vgrings(int32 file_id,int32 sd_id,hid_t h5group,hid_t h5_dimg,hid_t h5 return FAIL; } - bzero(vgroup_class,VGNAMELENMAX); + h4toh5_ZeroMemory(vgroup_class,VGNAMELENMAX); if(Vgetclass(vgroup_id,vgroup_class) == FAIL) { printf("error in obtaining vgroup class name. \n"); Vdetach(vgroup_id); @@ -1061,7 +1061,7 @@ int h4toh5lonevds(int32 file_id, hid_t h5group){ return FAIL; } - bzero(vdata_class,VGNAMELENMAX); + h4toh5_ZeroMemory(vdata_class,VGNAMELENMAX); istat = VSgetclass(vdata_id,vdata_class); if(istat == FAIL) { printf("error in getting vdata class name.\n"); @@ -1070,7 +1070,7 @@ int h4toh5lonevds(int32 file_id, hid_t h5group){ return FAIL; } - bzero(vdata_name,VGNAMELENMAX); + h4toh5_ZeroMemory(vdata_name,VGNAMELENMAX); istat = VSQueryname(vdata_id,vdata_name); if(istat == FAIL) { printf("error in getting vdata name. \n"); diff --git a/tools/h4toh5sds.c b/tools/h4toh5sds.c index 6d16938..a2592bb 100644 --- a/tools/h4toh5sds.c +++ b/tools/h4toh5sds.c @@ -26,7 +26,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){ int32 sds_ref; int32 istat; int i; - int empty; int32 num_sdsattrs; void* sds_data; @@ -44,8 +43,6 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){ hid_t h5d_sid; hid_t h5ty_id; hid_t h5_memtype; - hid_t h5str_type; - hid_t h5str_memtype; hsize_t h5dims[MAX_VAR_DIMS]; char* h5csds_name; @@ -555,7 +552,6 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, int32 sdsdim_id; int32 sdsdim_type = 0; int32 sds_dimscasize[1]; - int32 sds_dimrank; int32 istat; int i; int j; @@ -563,12 +559,10 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, int check_gloattr; int32 num_sdsdimattrs; - int empty; int check_sdsdim; void* dim_scadata; - char sdsdim_name[MAX_NC_NAME]; - char sds_name[MAX_NC_NAME]; + char sdsdim_name[MAX_NC_NAME+1]; char* cor_sdsdimname; size_t h4dim_memsize; size_t h4dim_size; @@ -593,13 +587,15 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, hsize_t h5dimscas[1]; hsize_t h5dim_dims[1]; hsize_t attr_refDims[1]; - hobj_ref_t dim_refdat; - hobj_ref_t* alldim_refdat; + + hobj_ref_t dim_refdat; + hobj_ref_t* alldim_refdat; + char* h5sdsdim_name; - char h5sdsdim_allname[MAX_VAR_DIMS * MAX_NC_NAME]; - char h5newsdsdim_name[MAX_NC_NAME]; - char h5dimpath_name[MAX_NC_NAME]; + char h5sdsdim_allname[MAX_VAR_DIMS * MAX_DIM_NAME]; + char h5newsdsdim_name[MAX_DIM_NAME]; + char h5dimpath_name[MAX_DIM_NAME]; herr_t ret; h5dim_dims[0] = (hsize_t)sds_rank; @@ -653,7 +649,7 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, return FAIL; } free(cor_sdsdimname); - strcpy(&h5sdsdim_allname[k*MAX_NC_NAME],h5sdsdim_name); + strcpy(&h5sdsdim_allname[k*MAX_DIM_NAME],h5sdsdim_name); /*if it is not touched, get name of the dimensional scale data. */ if (check_sdsdim == 1){/* the dimension is touched. */ @@ -784,8 +780,9 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, } for(i=0;i